Locales implements SingletonInterface

Defines all available TYPO3 system languages, as they differ from actual ISO 639-1 codes.

User-defined system languages can be added to $GLOBALS['TYPO3_CONF_VARS']['SYS']['localization']['locales']['user']

These system languages are used for determining the proper language labels of XLF files.

Table of Contents

Interfaces

SingletonInterface
"empty" interface for singletons (marker interface pattern)

Properties

$isoReverseMapping  : array<non-empty-string, non-empty-string>
Reversed mapping for backward compatibility codes
$languages  : array<non-empty-string, non-empty-string>
Supported TYPO3 languages with locales
$localeDependencies  : array<string|int, mixed>
Dependencies for locales.

Methods

__construct()  : mixed
createLocale()  : Locale
createLocaleFromRequest()  : Locale
createLocaleFromUserPreferences()  : Locale
getActiveLanguages()  : array<int, non-empty-string>
Returns a list of all ISO codes / TYPO3 languages that have active language packs, but also includes "default".
getAllSystemLocales()  : array<string|int, mixed>
getIsoMapping()  : array<non-empty-string, non-empty-string>
Returns the mapping between TYPO3 (old) language codes and ISO codes.
getLanguages()  : array<non-empty-string, non-empty-string>
Returns the supported languages indexed by their corresponding locale.
getLocaleDependencies()  : array<int, non-empty-string>
Returns the dependencies of a given locale, if any.
getLocales()  : array<int, non-empty-string>
Returns the locales.
getPreferredClientLanguage()  : non-empty-string
Converts the language codes that we get from the client (usually HTTP_ACCEPT_LANGUAGE) into a TYPO3-readable language code
isLanguageKeyAvailable()  : bool
isValidLanguageKey()  : bool
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

Deprecated

will be removed in TYPO3 v13.0. backwards-compatibility is not needed anymore.

protected array<non-empty-string, non-empty-string> $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', ]

Key => real ISO code value => the value that TYPO3 understands (which is wrong, obviously)

Example: "da" => official ISO 639-1 code "dk" (wrong)" => the shortcut that TYPO3 uses for danish within the system for labels.

$languages

Supported TYPO3 languages with locales

protected array<non-empty-string, non-empty-string> $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', 'lb' => 'Luxembourgish', '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 (Traditional)', 'zh_CN' => 'Chinese (Simplified)', 'zh_HK' => 'Chinese (Simplified Hong Kong)', 'zh_Hans_CN' => 'Chinese (Simplified Han)']

$localeDependencies

Dependencies for locales.

protected array<string|int, mixed> $localeDependencies = ['lb' => ['de']]

By default, locales with a country/region suffix such as "de_AT" will automatically have the "de" locale as fallback. This way TYPO3 only needs to know about the actual "base" language, however also allows to use country-specific languages. However, when a specific locale such as "lb" has a dependency to a different "de" suffix, this should is defined here. With $GLOBALS['TYPO3_CONF_VARS']['SYS']['localization']['locales']['dependencies'] it is possible to extend the dependency list.

Example: If "lb" is chosen, but no label was found, a fallback to the label in "de" is used.

Methods

createLocale()

public createLocale(string $localeKey[, array<string|int, mixed>|null $alternativeDependencies = null ]) : Locale
Parameters
$localeKey : string
$alternativeDependencies : array<string|int, mixed>|null = null
Return values
Locale

createLocaleFromRequest()

public createLocaleFromRequest(ServerRequestInterface|null $request) : Locale
Parameters
$request : ServerRequestInterface|null
Return values
Locale

getActiveLanguages()

Returns a list of all ISO codes / TYPO3 languages that have active language packs, but also includes "default".

public getActiveLanguages() : array<int, non-empty-string>
Return values
array<int, non-empty-string>

getAllSystemLocales()

public static getAllSystemLocales() : array<string|int, mixed>
Internal

not part of TYPO3 Core API, don't use outside of TYPO3 Core

Return values
array<string|int, mixed>

getIsoMapping()

Returns the mapping between TYPO3 (old) language codes and ISO codes.

public getIsoMapping() : array<non-empty-string, non-empty-string>
Deprecated

will be removed in TYPO3 v13.0.

Return values
array<non-empty-string, non-empty-string>

getLanguages()

Returns the supported languages indexed by their corresponding locale.

public getLanguages() : array<non-empty-string, non-empty-string>
Return values
array<non-empty-string, non-empty-string>

getLocaleDependencies()

Returns the dependencies of a given locale, if any.

public getLocaleDependencies(string $locale) : array<int, non-empty-string>
Parameters
$locale : string
Return values
array<int, non-empty-string>

getLocales()

Returns the locales.

public getLocales() : array<int, non-empty-string>
Return values
array<int, non-empty-string>

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) : non-empty-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
non-empty-string

A preferred language that TYPO3 supports, or "default" if none found

isLanguageKeyAvailable()

public isLanguageKeyAvailable(string $languageKey) : bool
Parameters
$languageKey : string
Return values
bool

isValidLanguageKey()

public isValidLanguageKey(string $locale) : bool
Parameters
$locale : string
Return values
bool

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
Return values
bool

        
On this page

Search results