47 private $titleFormatter;
62 $this->language = $langobj;
63 $this->titleFormatter = $titleFormatter ?? MediaWikiServices::getInstance()->getTitleFormatter();
71 return [ $this->language->getCode() => $text ];
88 $mainText = $this->titleFormatter->getText(
$title );
90 $index =
$title->getNamespace();
92 $nsWithUnderscores = $this->titleFormatter->getNamespaceName( $index, $mainText );
93 }
catch ( InvalidArgumentException $e ) {
95 $nsWithUnderscores = $this->language->getNsText(
NS_SPECIAL );
96 $mainText =
"Badtitle/NS$index:$mainText";
98 $nsText = str_replace(
'_',
' ', $nsWithUnderscores );
100 return [ $nsText,
':', $mainText ];
108 return $this->titleFormatter->getPrefixedText(
$title );
112 return $this->language->getFormattedNsText( $index );
119 return [ $this->language->getCode() ];
123 return $this->language->getCode();
127 return $this->language->getCode();
131 return $this->language->getCode();
162 if ( $variant ===
null ) {
165 $variant = strtolower( $variant );
166 return $variant === $this->language->getCode() ? $variant :
null;
181 private function reloadTables() {
206 return $variant && ( $variant === $this->
validateVariant( $variant ) );
218 return htmlspecialchars( $this->
convert( $text ) );
Base class for language-specific code.
A trivial language converter.
convertHtml( $text)
Perform output conversion on a string, and encode for safe HTML output.
translate( $text, $variant)
Translate a string to a variant.
hasVariants()
Check if this is a language with variants.
convert( $t)
Convert text to different variants of a language.
getURLVariant()
Get the variant specified in the URL.
__construct( $langobj, TitleFormatter $titleFormatter=null)
Creates a converter for languages that don't have variants.
getPreferredVariant()
Get preferred language variant.
markNoConversion( $text, $noParse=false)
Enclose a string with the "no conversion" tag.
autoConvertToAllVariants( $text)
Call translate() to convert text to all valid variants.
getConvRuleTitle()
Get the title produced by the conversion rule.
convertSplitTitle( $title)
getDefaultVariant()
This function would not be affected by user's settings.
findVariantLink(&$l, &$n, $ignoreOtherCond=false)
If a language supports multiple variants, it is possible that non-existing link in one variant actual...
autoConvert( $text, $variant=false)
Dictionary-based conversion.
convertTo( $text, $variant)
Same as convert() except a extra parameter to custom variant.
getExtraHashOptions()
Returns language specific hash options.
guessVariant( $text, $variant)
Guess if a text is written in a variant.
updateConversionTable(LinkTarget $linkTarget)
Refresh the cache of conversion tables when MediaWiki:Conversiontable* is updated.
validateVariant( $variant=null)
Validate the variant and return an appropriate strict internal variant code if one exists.
convertCategoryKey( $key)
Convert the sorting key for category links.
convertNamespace( $index, $variant=null)
Get the namespace display name in the preferred variant.
hasVariant( $variant)
Strict check if the language has the specific variant.
getVariantFallbacks( $variant)
In case some variant is not defined in the markup, we need to have some fallback.
The shared interface for all language converters.