25 namespace MediaWiki\Languages;
118 $this->langObjCache =
new MapCacheLRU( self::LANG_CACHE_SIZE );
130 $code = $this->options->get(
MainConfigNames::DummyLanguageCodes )[$code] ?? $code;
131 return $this->langObjCache->getWithSetCallback(
133 function () use ( $code ) {
147 if ( !$this->langNameUtils->isValidCode( $code ) ) {
148 throw new MWException(
"Invalid language code \"$code\"" );
153 $this->namespaceInfo,
154 $this->localisationCache,
155 $this->langNameUtils,
157 $this->langConverterFactory,
158 $this->hookContainer,
162 if ( !$this->langNameUtils->isValidBuiltInCode( $code ) ) {
165 return new Language( ...$constructorArgs );
169 $class = $this->classFromCode( $code,
$fallback );
171 if ( class_exists( $class ) && is_a( $class,
'Language',
true ) ) {
172 return new $class( ...$constructorArgs );
176 $fallbacks = $this->langFallback->getAll( $code );
177 foreach ( $fallbacks as $fallbackCode ) {
178 $class = $this->classFromCode( $fallbackCode );
179 if ( class_exists( $class ) ) {
181 return new $class( ...$constructorArgs );
185 throw new MWException(
"Invalid fallback sequence for language '$code'" );
197 return 'Language' . str_replace(
'-',
'_', ucfirst( $code ) );
211 if ( !array_key_exists( $code, $this->parentLangCache ) ) {
212 if ( !$this->langNameUtils->isValidBuiltInCode( $code ) ) {
213 $this->parentLangCache[$code] =
null;
217 $lang = $this->getLanguage( $mainCode );
218 $converter = $this->langConverterFactory->getLanguageConverter(
$lang );
219 if ( $converter->hasVariant( $code ) ) {
220 $this->parentLangCache[$code] =
$lang;
224 $this->parentLangCache[$code] =
null;
227 return $this->parentLangCache[$code];
if(!defined('MW_SETUP_CALLBACK'))
The persistent session ID (if any) loaded at startup.
Base class for multi-variant language conversion.
static array $languagesWithVariants
languages supporting variants
Internationalisation code See https://www.mediawiki.org/wiki/Special:MyLanguage/Localisation for more...
Class for caching the contents of localisation files, Messages*.php and *.i18n.php.
Handles a simple LRU key/value map with a maximum number of entries.
A class containing constants representing the names of configuration variables.
const DummyLanguageCodes
Name constant for the DummyLanguageCodes setting, for use with Config::get()
This is a utility class for dealing with namespaces that encodes all the "magic" behaviors of them ba...
Interface for configuration instances.
if(!isset( $args[0])) $lang