49 private $titleFormatter;
64 $this->language = $langobj;
65 $this->titleFormatter = $titleFormatter ?? MediaWikiServices::getInstance()->getTitleFormatter();
73 return [ $this->language->getCode() => $text ];
80 public function convertTo( $text, $variant,
bool $clearState =
true ) {
90 $mainText = $this->titleFormatter->getText( $title );
92 $index = $title->getNamespace();
94 $nsWithUnderscores = $this->titleFormatter->getNamespaceName( $index, $mainText );
95 }
catch ( InvalidArgumentException $e ) {
97 $nsWithUnderscores = $this->language->getNsText(
NS_SPECIAL );
98 $mainText =
"Badtitle/NS$index:$mainText";
100 $nsText = str_replace(
'_',
' ', $nsWithUnderscores );
102 return [ $nsText,
':', $mainText ];
110 return $this->titleFormatter->getPrefixedText( $title );
114 return $this->language->getFormattedNsText( $index );
121 return [ $this->language->getCode() ];
125 return $this->language->getCode();
129 return $this->language->getCode();
133 return $this->language->getCode();
164 if ( $variant ===
null ) {
167 $variant = strtolower( $variant );
168 return $variant === $this->language->getCode() ? $variant :
null;
183 private function reloadTables() {
208 return $variant && ( $variant === $this->
validateVariant( $variant ) );
220 return htmlspecialchars( $this->
convert( $text ) );
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.
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.
convertTo( $text, $variant, bool $clearState=true)
Same as convert() except a extra parameter to custom variant.
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.