src/i18n/i18n.php
public static function get_closest_translation($locale)
    {
        // Check if exact match
        $pool = self::getSources()->getKnownLocales();
        if (isset($pool[$locale])) {
            return $locale;
        }

        // Fallback to best locale for common language
        $localesData = static::getData();
        $lang = $localesData->langFromLocale($locale);
        $candidate = $localesData->localeFromLang($lang);
        if (isset($pool[$candidate])) {
            return $candidate;
        }
        return null;
    }
public static function get_closest_translation($locale)
    {
        // Check if exact match
        $pool = self::getSources()->getKnownLocales();
        if (isset($pool[$locale])) {
            return $locale;
        }

        // Fallback to best locale for common language
        $localesData = static::getData();
        $lang = $localesData->langFromLocale($locale);
        $candidate = $localesData->localeFromLang($lang);
        if (isset($pool[$candidate])) {
            return $candidate;
        }
        return null;
    }
public static function get_closest_translation ( $ locale ) { // Check if exact match $ pool = self :: getSources ( ) -> getKnownLocales ( ) ; if ( isset ( $ pool [ $ locale ] ) ) { return $ locale ; } // Fallback to best locale for common language $ localesData = static :: getData ( ) ; $ lang = $ localesData -> langFromLocale ( $ locale ) ; $ candidate = $ localesData -> localeFromLang ( $ lang ) ; if ( isset ( $ pool [ $ candidate ] ) ) { return $ candidate ; } return null ; }
Matches a given locale with the closest translation available in the system

@param string $locale locale code
@return string Locale of closest available translation, if available
Matches a given locale with the closest translation available in the system