Locales implements SingletonInterface
Locales. Used to define TYPO3- system languages When adding new keys, remember to: - Update 'setup' extension labels (sysext/setup/Resources/Private/Language/locallang.xlf) That's it!
Table of Contents
Interfaces
- SingletonInterface
- "empty" interface for singletons (marker interface pattern)
Properties
- $isoReverseMapping : array<string|int, mixed>
- Reversed mapping for backward compatibility codes
- $languages : array<string|int, mixed>
- Supported TYPO3 languages with locales
- $localeDependencies : array<string|int, mixed>
- Dependencies for locales This is a reverse mapping for the built-in languages within $this->languages that contain 5-letter codes.
Methods
- __construct() : mixed
- getIsoMapping() : array<string|int, mixed>
- Returns the mapping between TYPO3 (old) language codes and ISO codes.
- getLanguages() : array<string|int, mixed>
- Returns the supported languages indexed by their corresponding locale.
- getLocaleDependencies() : array<string|int, mixed>
- Returns the dependencies of a given locale, if any.
- getLocales() : array<string|int, mixed>
- Returns the locales.
- getPreferredClientLanguage() : string
- Converts the language codes that we get from the client (usually HTTP_ACCEPT_LANGUAGE) into a TYPO3-readable language code
- setSystemLocaleFromSiteLanguage() : bool
- Setting locale based on a SiteLanguage's defined locale.
- setLocale() : bool
- Internal method, which calls itself again, in order to avoid multiple logging issues.
Properties
$isoReverseMapping
Reversed mapping for backward compatibility codes
protected
array<string|int, mixed>
$isoReverseMapping
= [
'bs' => 'ba',
// Bosnian
'cs' => 'cz',
// Czech
'da' => 'dk',
// Danish
'el' => 'gr',
// Greek
'fr_CA' => 'qc',
// French (Canada)
'gl' => 'ga',
// Galician
'ja' => 'jp',
// Japanese
'ka' => 'ge',
// Georgian
'kl' => 'gl',
// Greenlandic
'ko' => 'kr',
// Korean
'ms' => 'my',
// Malay
'pt_BR' => 'br',
// Portuguese (Brazil)
'sl' => 'si',
// Slovenian
'sv' => 'se',
// Swedish
'uk' => 'ua',
// Ukrainian
'vi' => 'vn',
// Vietnamese
'zh' => 'hk',
// Chinese (China)
'zh_CN' => 'ch',
// Chinese (Simplified)
'zh_HK' => 'hk',
// Chinese (Simplified Hong Kong)
'zh_Hans_CN' => 'ch',
]
$languages
Supported TYPO3 languages with locales
protected
array<string|int, mixed>
$languages
= ['default' => 'English', 'af' => 'Afrikaans', 'ar' => 'Arabic', 'bs' => 'Bosnian', 'bg' => 'Bulgarian', 'ca' => 'Catalan', 'ch' => 'Chinese (Simple)', 'cs' => 'Czech', 'cy' => 'Welsh', 'da' => 'Danish', 'de' => 'German', 'el' => 'Greek', 'eo' => 'Esperanto', 'es' => 'Spanish', 'et' => 'Estonian', 'eu' => 'Basque', 'fa' => 'Persian', 'fi' => 'Finnish', 'fo' => 'Faroese', 'fr' => 'French', 'fr_CA' => 'French (Canada)', 'gl' => 'Galician', 'he' => 'Hebrew', 'hi' => 'Hindi', 'hr' => 'Croatian', 'hu' => 'Hungarian', 'is' => 'Icelandic', 'it' => 'Italian', 'ja' => 'Japanese', 'ka' => 'Georgian', 'kl' => 'Greenlandic', 'km' => 'Khmer', 'ko' => 'Korean', 'lt' => 'Lithuanian', 'lv' => 'Latvian', 'mi' => 'Maori', 'mk' => 'Macedonian', 'ms' => 'Malay', 'nl' => 'Dutch', 'no' => 'Norwegian', 'pl' => 'Polish', 'pt' => 'Portuguese', 'pt_BR' => 'Brazilian Portuguese', 'ro' => 'Romanian', 'ru' => 'Russian', 'rw' => 'Kinyarwanda', 'sk' => 'Slovak', 'sl' => 'Slovenian', 'sn' => 'Shona (Bantu)', 'sq' => 'Albanian', 'sr' => 'Serbian', 'sv' => 'Swedish', 'th' => 'Thai', 'tr' => 'Turkish', 'uk' => 'Ukrainian', 'vi' => 'Vietnamese', 'zh' => 'Chinese (Trad)']
$localeDependencies
Dependencies for locales This is a reverse mapping for the built-in languages within $this->languages that contain 5-letter codes.
protected
array<string|int, mixed>
$localeDependencies
= ['pt_BR' => ['pt'], 'fr_CA' => ['fr']]
Methods
__construct()
public
__construct() : mixed
getIsoMapping()
Returns the mapping between TYPO3 (old) language codes and ISO codes.
public
getIsoMapping() : array<string|int, mixed>
Return values
array<string|int, mixed>getLanguages()
Returns the supported languages indexed by their corresponding locale.
public
getLanguages() : array<string|int, mixed>
Return values
array<string|int, mixed>getLocaleDependencies()
Returns the dependencies of a given locale, if any.
public
getLocaleDependencies(string $locale) : array<string|int, mixed>
Parameters
- $locale : string
Return values
array<string|int, mixed>getLocales()
Returns the locales.
public
getLocales() : array<string|int, mixed>
Return values
array<string|int, mixed>getPreferredClientLanguage()
Converts the language codes that we get from the client (usually HTTP_ACCEPT_LANGUAGE) into a TYPO3-readable language code
public
getPreferredClientLanguage(string $languageCodesList) : string
Parameters
- $languageCodesList : string
-
List of language codes. something like 'de,en-us;q=0.9,de-de;q=0.7,es-cl;q=0.6,en;q=0.4,es;q=0.3,zh;q=0.1'
Return values
string —A preferred language that TYPO3 supports, or "default" if none found
setSystemLocaleFromSiteLanguage()
Setting locale based on a SiteLanguage's defined locale.
public
static setSystemLocaleFromSiteLanguage(SiteLanguage $siteLanguage) : bool
Used for frontend rendering, previously set within TSFE->settingLocale
Parameters
- $siteLanguage : SiteLanguage
Return values
bool —whether the locale was found on the system (and could be set properly) or not
setLocale()
Internal method, which calls itself again, in order to avoid multiple logging issues.
protected
static setLocale(string $locale, string $localeStringForTrigger) : bool
The main reason for this method is that it calls itself again by trying again to set the locale. Due to sensible defaults, people used the locale "de_AT.utf-8" with the POSIX platform (see https://en.wikipedia.org/wiki/Locale_(computer_software)#POSIX_platforms) in their site configuration, even though the target system has "de_AT" and not "de_AT.UTF-8" defined. "setLocale()" is now called again without the POSIX platform suffix and is checked again if the locale is then available, and then logs the failed information.
Parameters
- $locale : string
- $localeStringForTrigger : string