MediaWiki REL1_34
|
A service that provides utilities to do with language names and codes. More...
Public Member Functions | |
__construct (ServiceOptions $options) | |
getFileName ( $prefix, $code, $suffix='.php') | |
Get the name of a file for a certain language code. | |
getJsonMessagesFileName ( $code) | |
getLanguageName ( $code, $inLanguage=self::AUTONYMS, $include=self::ALL) | |
getLanguageNames ( $inLanguage=self::AUTONYMS, $include=self::DEFINED) | |
Get an array of language names, indexed by code. | |
getMessagesFileName ( $code) | |
isKnownLanguageTag ( $tag) | |
Returns true if a language code is an IETF tag known to MediaWiki. | |
isSupportedLanguage ( $code) | |
Checks whether any localisation is available for that language tag in MediaWiki (MessagesXx.php or xx.json exists). | |
isValidBuiltInCode ( $code) | |
Returns true if a language code is of a valid form for the purposes of internal customisation of MediaWiki, via Messages*.php or *.json. | |
isValidCode ( $code) | |
Returns true if a language code string is of a valid form, whether or not it exists. | |
Public Attributes | |
const | ALL = 'all' |
Return all known languages in getLanguageName(s). | |
const | AUTONYMS = null |
Return autonyms in getLanguageName(s). | |
const | CONSTRUCTOR_OPTIONS |
const | DEFINED = 'mw' |
Return in getLanguageName(s) only the languages that are defined by MediaWiki. | |
const | SUPPORTED = 'mwfile' |
Return in getLanguageName(s) only the languages for which we have at least some localisation. | |
Private Member Functions | |
getLanguageNamesUncached ( $inLanguage, $include) | |
Uncached helper for getLanguageNames. | |
Private Attributes | |
HashBagOStuff null | $languageNameCache |
Cache for language names. | |
ServiceOptions | $options |
array | $validCodeCache = [] |
Cache for validity of language codes. | |
A service that provides utilities to do with language names and codes.
Definition at line 45 of file LanguageNameUtils.php.
MediaWiki\Languages\LanguageNameUtils::__construct | ( | ServiceOptions | $options | ) |
ServiceOptions | $options |
Definition at line 89 of file LanguageNameUtils.php.
References MediaWiki\Languages\LanguageNameUtils\$options, and MediaWiki\Config\ServiceOptions\assertRequiredOptions().
MediaWiki\Languages\LanguageNameUtils::getFileName | ( | $prefix, | |
$code, | |||
$suffix = '.php' ) |
Get the name of a file for a certain language code.
string | $prefix | Prepend this to the filename |
string | $code | Language code |
string | $suffix | Append this to the filename |
MWException |
Definition at line 286 of file LanguageNameUtils.php.
References MediaWiki\Languages\LanguageNameUtils\isValidBuiltInCode().
Referenced by MediaWiki\Languages\LanguageNameUtils\getMessagesFileName().
MediaWiki\Languages\LanguageNameUtils::getJsonMessagesFileName | ( | $code | ) |
string | $code |
MWException |
Definition at line 310 of file LanguageNameUtils.php.
References $IP, and MediaWiki\Languages\LanguageNameUtils\isValidBuiltInCode().
Referenced by MediaWiki\Languages\LanguageNameUtils\getLanguageNamesUncached(), and MediaWiki\Languages\LanguageNameUtils\isSupportedLanguage().
MediaWiki\Languages\LanguageNameUtils::getLanguageName | ( | $code, | |
$inLanguage = self::AUTONYMS, | |||
$include = self::ALL ) |
string | $code | The code of the language for which to get the name |
null | string | $inLanguage | Code of language in which to return the name (self::AUTONYMS for autonyms) |
string | $include | See getLanguageNames(), except this defaults to self::ALL instead of self::DEFINED |
Definition at line 272 of file LanguageNameUtils.php.
References MediaWiki\Languages\LanguageNameUtils\getLanguageNames().
Referenced by MediaWiki\Languages\LanguageNameUtils\isKnownLanguageTag().
MediaWiki\Languages\LanguageNameUtils::getLanguageNames | ( | $inLanguage = self::AUTONYMS, | |
$include = self::DEFINED ) |
Get an array of language names, indexed by code.
null | string | $inLanguage | Code of language in which to return the names Use self::AUTONYMS for autonyms (native names) |
string | $include | One of: self::ALL all available languages self::DEFINED only if the language is defined in MediaWiki or wgExtraLanguageNames (default) self::SUPPORTED only if the language is in self::DEFINED and has a message file |
Definition at line 182 of file LanguageNameUtils.php.
References MediaWiki\Languages\LanguageNameUtils\getLanguageNamesUncached().
Referenced by MediaWiki\Languages\LanguageNameUtils\getLanguageName().
|
private |
Uncached helper for getLanguageNames.
null | string | $inLanguage | As getLanguageNames |
string | $include | As getLanguageNames |
Definition at line 203 of file LanguageNameUtils.php.
References MediaWiki\Languages\LanguageNameUtils\getJsonMessagesFileName(), MediaWiki\Languages\LanguageNameUtils\getMessagesFileName(), and MediaWiki\Languages\LanguageNameUtils\isValidCode().
Referenced by MediaWiki\Languages\LanguageNameUtils\getLanguageNames().
MediaWiki\Languages\LanguageNameUtils::getMessagesFileName | ( | $code | ) |
string | $code |
Definition at line 298 of file LanguageNameUtils.php.
References $file, $IP, and MediaWiki\Languages\LanguageNameUtils\getFileName().
Referenced by MediaWiki\Languages\LanguageNameUtils\getLanguageNamesUncached(), and MediaWiki\Languages\LanguageNameUtils\isSupportedLanguage().
MediaWiki\Languages\LanguageNameUtils::isKnownLanguageTag | ( | $tag | ) |
Returns true if a language code is an IETF tag known to MediaWiki.
string | $tag |
Definition at line 157 of file LanguageNameUtils.php.
References MediaWiki\Languages\LanguageNameUtils\getLanguageName(), and MediaWiki\Languages\LanguageNameUtils\isValidBuiltInCode().
MediaWiki\Languages\LanguageNameUtils::isSupportedLanguage | ( | $code | ) |
Checks whether any localisation is available for that language tag in MediaWiki (MessagesXx.php or xx.json exists).
string | $code | Language tag (in lower case) |
Definition at line 101 of file LanguageNameUtils.php.
References MediaWiki\Languages\LanguageNameUtils\getJsonMessagesFileName(), MediaWiki\Languages\LanguageNameUtils\getMessagesFileName(), and MediaWiki\Languages\LanguageNameUtils\isValidBuiltInCode().
MediaWiki\Languages\LanguageNameUtils::isValidBuiltInCode | ( | $code | ) |
Returns true if a language code is of a valid form for the purposes of internal customisation of MediaWiki, via Messages*.php or *.json.
string | $code |
Definition at line 144 of file LanguageNameUtils.php.
Referenced by MediaWiki\Languages\LanguageNameUtils\getFileName(), MediaWiki\Languages\LanguageNameUtils\getJsonMessagesFileName(), MediaWiki\Languages\LanguageNameUtils\isKnownLanguageTag(), MediaWiki\Languages\LanguageNameUtils\isSupportedLanguage(), and Language\newFromCode().
MediaWiki\Languages\LanguageNameUtils::isValidCode | ( | $code | ) |
Returns true if a language code string is of a valid form, whether or not it exists.
This includes codes which are used solely for customisation via the MediaWiki namespace.
string | $code |
Definition at line 123 of file LanguageNameUtils.php.
References MediaWikiTitleCodec\getTitleInvalidRegex().
Referenced by MediaWiki\Languages\LanguageNameUtils\getLanguageNamesUncached(), and Language\newFromCode().
|
private |
Cache for language names.
Definition at line 73 of file LanguageNameUtils.php.
|
private |
Definition at line 67 of file LanguageNameUtils.php.
Referenced by MediaWiki\Languages\LanguageNameUtils\__construct().
|
private |
Cache for validity of language codes.
Definition at line 79 of file LanguageNameUtils.php.
const MediaWiki\Languages\LanguageNameUtils::ALL = 'all' |
Return all known languages in getLanguageName(s).
Definition at line 54 of file LanguageNameUtils.php.
const MediaWiki\Languages\LanguageNameUtils::AUTONYMS = null |
Return autonyms in getLanguageName(s).
Definition at line 49 of file LanguageNameUtils.php.
const MediaWiki\Languages\LanguageNameUtils::CONSTRUCTOR_OPTIONS |
Definition at line 81 of file LanguageNameUtils.php.
const MediaWiki\Languages\LanguageNameUtils::DEFINED = 'mw' |
Return in getLanguageName(s) only the languages that are defined by MediaWiki.
Definition at line 59 of file LanguageNameUtils.php.
const MediaWiki\Languages\LanguageNameUtils::SUPPORTED = 'mwfile' |
Return in getLanguageName(s) only the languages for which we have at least some localisation.
Definition at line 64 of file LanguageNameUtils.php.