MediaWiki master
MediaWiki\Language\LanguageFactory Class Reference

Internationalisation code See https://www.mediawiki.org/wiki/Special:MyLanguage/Localisation for more information. More...

Public Member Functions

 __construct (private readonly ServiceOptions $options, private readonly NamespaceInfo $namespaceInfo, private readonly LocalisationCache $localisationCache, private readonly LanguageNameUtils $langNameUtils, private readonly LanguageFallback $langFallback, private readonly LanguageConverterFactory $langConverterFactory, private readonly HookContainer $hookContainer, private readonly Config $config, private readonly LeximorphFactory $leximorphFactory,)
 
 getLanguage ( $code)
 Get a cached or new language object for a given language code with normalization of the language code.
 
 getLanguageCode (string $code)
 
 getParentLanguage ( $code)
 Get the "parent" language which has a converter to convert a "compatible" language (in another variant) to this language (eg., zh for zh-cn, but not en for en-gb).
 
 getRawLanguage ( $code)
 Get a cached or new language object for a given language code without normalization of the language code.
 

Public Attributes

const CONSTRUCTOR_OPTIONS
 

Detailed Description

Internationalisation code See https://www.mediawiki.org/wiki/Special:MyLanguage/Localisation for more information.

Since
1.35

Definition at line 26 of file LanguageFactory.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Language\LanguageFactory::__construct ( private readonly ServiceOptions $options,
private readonly NamespaceInfo $namespaceInfo,
private readonly LocalisationCache $localisationCache,
private readonly LanguageNameUtils $langNameUtils,
private readonly LanguageFallback $langFallback,
private readonly LanguageConverterFactory $langConverterFactory,
private readonly HookContainer $hookContainer,
private readonly Config $config,
private readonly LeximorphFactory $leximorphFactory )

Definition at line 43 of file LanguageFactory.php.

Member Function Documentation

◆ getLanguage()

MediaWiki\Language\LanguageFactory::getLanguage ( $code)

Get a cached or new language object for a given language code with normalization of the language code.

If the language code comes from user input, check LanguageNameUtils::isValidCode() before calling this method.

The language code is presumed to be a MediaWiki-internal code, unless you pass a Bcp47Code opaque object, in which case it is presumed to be a standard BCP-47 code. (There are, regrettably, some ambiguous codes where this makes a difference.)

As the Language class itself implements Bcp47Code, this method is an efficient and safe downcast if you pass in a Language object.

Parameters
string | Bcp47Code$code
Returns
Language

Definition at line 80 of file LanguageFactory.php.

Referenced by MediaWiki\User\TempUser\LocalizedNumericSerialMapping\__construct(), MediaWiki\Collation\CollationCkb\__construct(), MediaWiki\Collation\UppercaseCollation\__construct(), MediaWiki\Collation\NumericUppercaseCollation\__construct(), MediaWiki\Collation\IcuCollation\__construct(), and MediaWiki\Collation\CustomUppercaseCollation\__construct().

◆ getLanguageCode()

MediaWiki\Language\LanguageFactory::getLanguageCode ( string $code)

Definition at line 96 of file LanguageFactory.php.

◆ getParentLanguage()

MediaWiki\Language\LanguageFactory::getParentLanguage ( $code)

Get the "parent" language which has a converter to convert a "compatible" language (in another variant) to this language (eg., zh for zh-cn, but not en for en-gb).

Note
This method does not contain the deprecated and compatibility mappings of Language::getLanguage(string).
Parameters
string | Bcp47Code$codeThe language to convert to; can be an internal MediaWiki language code or a Bcp47Code object (which includes Language, which implements Bcp47Code).
Returns
Language|null A base language which has a converter to the given language, or null if none exists.
Since
1.22

Definition at line 201 of file LanguageFactory.php.

◆ getRawLanguage()

MediaWiki\Language\LanguageFactory::getRawLanguage ( $code)

Get a cached or new language object for a given language code without normalization of the language code.

If the language code comes from user input, check LanguageNameUtils::isValidCode() before calling this method.

Parameters
string$code
Returns
Language
Since
1.39

Definition at line 115 of file LanguageFactory.php.

Referenced by MediaWiki\Specials\Pager\AllMessagesTablePager\__construct().

Member Data Documentation

◆ CONSTRUCTOR_OPTIONS

const MediaWiki\Language\LanguageFactory::CONSTRUCTOR_OPTIONS
Initial value:
= [
]
const DummyLanguageCodes
Name constant for the DummyLanguageCodes setting, for use with Config::get()
Access: internal
For use by ServiceWiring

Definition at line 36 of file LanguageFactory.php.


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