MediaWiki REL1_31
LanguageCode Class Reference

Methods for dealing with language codes. More...

Collaboration diagram for LanguageCode:

Static Public Member Functions

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

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.
 

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.

Referenced by MediaWiki\Preferences\DefaultPreferencesFactory\profilePreferences().

◆ 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.

◆ 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.

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.


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