[TYPO3-english] Get language code

Jigal van Hemert jigal.van.hemert at typo3.org
Thu Jan 15 14:34:36 CET 2015


Hi,

On 15/01/2015 07:51, Bernhard Schenkenfelder wrote:
> As far as I know, there are two ways to retrieve the current (front-end)
> language:
>
> $GLOBALS['TSFE']->config['config']['language']
> $GLOBALS['TSFE']->sys_language_uid
>
> If the latter is 2, then the config value is, say, 'dk'. However, if the
> language UID is 0, then the first variable returns '' (empty string).
>
> Is there a mapping between sys_language_uid and the language code, or in
> other words, where/how can I find the default language (code)?

For sys_language_uid > 0 you can look in the database records in 
'sys_language'. sys_language_uid has no record associated, but in many 
installations there is page TSconfig like:
mod.SHARED {
    defaultLanguageFlag = de
    defaultLanguageLabel = deutsch
}

You could look at the flag name (if set) and conclude which language is 
meant.

-- 
Jigal van Hemert
TYPO3 CMS Active Contributor

TYPO3 .... inspiring people to share!
Get involved: typo3.org


More information about the TYPO3-english mailing list