function Request::formatLocale
Strips the locale to only keep the canonicalized language value.
Depending on the $locale value, this method can return values like :
- language_Script_REGION: "fr_Latn_FR", "zh_Hans_TW"
- language_Script: "fr_Latn", "zh_Hans"
- language_REGION: "fr_FR", "zh_TW"
- language: "fr", "zh"
Invalid locale values are returned as is.
See also
https://wikipedia.org/wiki/IETF_language_tag
https://datatracker.ietf.org/doc/html/rfc5646
2 calls to Request::formatLocale()
- Request::getLanguages in vendor/
symfony/ http-foundation/ Request.php - Gets a list of languages acceptable by the client browser ordered in the user browser preferences.
- Request::getPreferredLanguage in vendor/
symfony/ http-foundation/ Request.php - Returns the preferred language.
File
-
vendor/
symfony/ http-foundation/ Request.php, line 1608
Class
- Request
- Request represents an HTTP request.
Namespace
Symfony\Component\HttpFoundationCode
private static function formatLocale(string $locale) : string {
[
$language,
$script,
$region,
] = self::getLanguageComponents($locale);
return implode('_', array_filter([
$language,
$script,
$region,
]));
}