MediaWiki
1.34.4
|
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 | getNonstandardLanguageCodeMapping () |
Returns a mapping of non-standard language codes used by (current and previous version of) MediaWiki, mapped to standard BCP 47 names. 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... | |
static array | $nonstandardLanguageCodeMapping |
Mapping of non-standard language codes used in MediaWiki to standardized BCP 47 codes. More... | |
|
static |
Get the normalised IETF language tag See unit test for examples.
See mediawiki.language.bcp47 for the JavaScript implementation.
string | $code | The language code. |
Definition at line 178 of file LanguageCode.php.
References replaceDeprecatedCodes().
Referenced by ApiQuerySiteinfo\appendLanguages(), SkinTemplate\buildContentNavigationUrls(), ImagePage\createXmlOptionStringForLanguage(), ApiQueryLanguageinfo\execute(), MediaWiki\Rest\ResponseFactory\formatMessage(), OutputPage\getHeadLinksArray(), Language\getHtmlCode(), FeedItem\getLanguage(), SkinTemplate\getLanguages(), getNonstandardLanguageCodeMapping(), LanguageConverter\getVarSeparatorPattern(), CoreParserFunctions\language(), MediaWiki\Preferences\DefaultPreferencesFactory\profilePreferences(), and LanguageConverter\validateVariant().
|
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.
Definition at line 127 of file LanguageCode.php.
References $deprecatedLanguageCodeMapping.
Referenced by LanguageConverter\getVarSeparatorPattern().
|
static |
Returns a mapping of non-standard language codes used by (current and previous version of) MediaWiki, mapped to standard BCP 47 names.
This array is exported to JavaScript to ensure mediawiki.language.bcp47 stays in sync with LanguageCode::bcp47().
Definition at line 143 of file LanguageCode.php.
References bcp47().
Referenced by ResourceLoaderLanguageDataModule\getData().
|
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.
string | $code | Old language code |
Definition at line 164 of file LanguageCode.php.
Referenced by bcp47(), User\loadOptions(), and LanguageConverter\validateVariant().
|
staticprivate |
Mapping of deprecated language codes that were used in previous versions of MediaWiki to up-to-date, current language codes.
These may or may not be valid BCP 47 codes; they are included here because MediaWiki renamed these particular codes at some point.
Mapping from deprecated MediaWiki-internal language code to replacement MediaWiki-internal language code.
Definition at line 41 of file LanguageCode.php.
Referenced by getDeprecatedCodeMapping().
|
staticprivate |
Mapping of non-standard language codes used in MediaWiki to standardized BCP 47 codes.
These are not deprecated (yet?): IANA may eventually recognize the subtag, in which case the -x-
infix could be removed, or else we could rename the code in MediaWiki, in which case they'd move up to the above mapping of deprecated codes.
As a rule, we preserve all distinctions made by MediaWiki internally. For example, de-formal
becomes de-x-formal
instead of just de
because MediaWiki distinguishes de-formal
from de
(for example, for interface translations). Similarly, BCP 47 indicates that kk-Cyrl
SHOULD not be used because it "typically does not add information", but in our case MediaWiki LanguageConverter distinguishes kk
(render content in a mix of Kurdish variants) from kk-Cyrl
(convert content to be uniformly Cyrillic). As the BCP 47 requirement is a SHOULD not a MUST, kk-Cyrl
is a valid code, although some validators may emit a warning note.
Mapping from nonstandard MediaWiki-internal codes to BCP 47 codes
Definition at line 81 of file LanguageCode.php.