MediaWiki  REL1_31
LanguageCode Class Reference

Methods for dealing with language codes. More...

Static Public Member Functions

static bcp47 ( $code)
 Get the normalised IETF language tag See unit test for examples. More...
 
static getDeprecatedCodeMapping ()
 Returns a mapping of deprecated language codes that were used in previous versions of MediaWiki to up-to-date, current language codes. More...
 
static replaceDeprecatedCodes ( $code)
 Replace deprecated language codes that were used in previous versions of MediaWiki to up-to-date, current language codes. More...
 

Static Private Attributes

static array $deprecatedLanguageCodeMapping
 Mapping of deprecated language codes that were used in previous versions of MediaWiki to up-to-date, current language codes. More...
 

Detailed Description

Methods for dealing with language codes.

Todo:
Move some of the code-related static methods out of Language into this class
Since
1.29

Definition at line 29 of file LanguageCode.php.

Member Function Documentation

◆ bcp47()

static LanguageCode::bcp47 (   $code)
static

Get the normalised IETF language tag See unit test for examples.

See mediawiki.language.bcp47 for the JavaScript implementation.

Parameters
string$codeThe language code.
Returns
string The language code which complying with BCP 47 standards.
Since
1.31

Definition at line 94 of file LanguageCode.php.

References $code, and as.

Referenced by OutputPage\addAcceptLanguage(), SkinTemplate\buildContentNavigationUrls(), ImagePage\createXmlOptionStringForLanguage(), WebInstallerOutput\getHeadAttribs(), OutputPage\getHeadLinksArray(), Language\getHtmlCode(), FeedItem\getLanguage(), SkinTemplate\getLanguages(), CoreParserFunctions\language(), MediaWiki\Preferences\DefaultPreferencesFactory\profilePreferences(), LanguageCodeTest\testBcp47(), and wfBCP47().

◆ getDeprecatedCodeMapping()

static LanguageCode::getDeprecatedCodeMapping ( )
static

Returns a mapping of deprecated language codes that were used in previous versions of MediaWiki to up-to-date, current language codes.

This array is merged into $wgDummyLanguageCodes in Setup.php, along with the fake language codes 'qqq' and 'qqx', which are used internally by MediaWiki's localisation system.

Returns
string[]
Since
1.29

Definition at line 63 of file LanguageCode.php.

References $deprecatedLanguageCodeMapping.

Referenced by WebInstallerLanguage\getLanguageSelector(), and LanguageCodeTest\testGetDeprecatedCodeMapping().

◆ replaceDeprecatedCodes()

static LanguageCode::replaceDeprecatedCodes (   $code)
static

Replace deprecated language codes that were used in previous versions of MediaWiki to up-to-date, current language codes.

Other values will returned unchanged.

Parameters
string$codeOld language code
Returns
string New language code
Since
1.30

Definition at line 77 of file LanguageCode.php.

References $code.

Referenced by LanguageCodeTest\testReplaceDeprecatedCodes().

Member Data Documentation

◆ $deprecatedLanguageCodeMapping

array LanguageCode::$deprecatedLanguageCodeMapping
staticprivate
Initial value:
= [
'als' => 'gsw',
'bat-smg' => 'sgs',
'be-x-old' => 'be-tarask',
'fiu-vro' => 'vro',
'roa-rup' => 'rup',
'zh-classical' => 'lzh',
'zh-min-nan' => 'nan',
'zh-yue' => 'yue',
]

Mapping of deprecated language codes that were used in previous versions of MediaWiki to up-to-date, current language codes.

Mapping from language code to language code

Since
1.30

Definition at line 38 of file LanguageCode.php.

Referenced by getDeprecatedCodeMapping().


The documentation for this class was generated from the following file: