Language Converter
Finite-State Transducer implementation of MediaWiki LanguageConverter
Loading...
Searching...
No Matches
Wikimedia\LangConv\NullReplacementMachine Class Reference

A replacement machine that leaves text untouched. More...

+ Inheritance diagram for Wikimedia\LangConv\NullReplacementMachine:

Public Member Functions

 __construct (string $baseLanguage)
 Create a NullReplacementMachine.
 
 getCodes ()
 Return the set of language codes supported.Both key and value are set in order to facilitate inclusion testing.
Returns
array<string,string>

 
 isValidCodePair ( $destCode, $invertCode)
 Override this method in subclass if you want to limit the possible code pairs bracketed.(For example, zh has a large number of variants, but we typically want to use only a limited number of these as possible invert codes.)

Parameters
string$destCode
string$invertCode
Returns
bool whether this is a valid bracketing pair.

 
 convert ( $document, $s, $destCode, $invertCode)
 Convert a string of text.
Parameters
DOMDocument$document
string$stext to convert
string$destCodedestination language code
string$invertCode
Returns
DOMDocumentFragment DocumentFragment containing converted text

 
- Public Member Functions inherited from Wikimedia\LangConv\ReplacementMachine
 __construct ()
 ReplacementMachine constructor.
 
 replace ( $textNode, $destCode, $invertCode)
 Replace the given text Node with converted text, protecting any markup which can't be round-tripped back to invertCode with appropriate synthetic language-converter markup.
 
 jsonEncode (array $obj)
 Allow client to customize the JSON encoding of data-mw-variant attributes.
 

Detailed Description

A replacement machine that leaves text untouched.

Constructor & Destructor Documentation

◆ __construct()

Wikimedia\LangConv\NullReplacementMachine::__construct ( string $baseLanguage)

Create a NullReplacementMachine.

Parameters
string$baseLanguageA base language code

Member Function Documentation

◆ convert()

Wikimedia\LangConv\NullReplacementMachine::convert ( $document,
$s,
$destCode,
$invertCode )

Convert a string of text.

Parameters
DOMDocument$document
string$stext to convert
string$destCodedestination language code
string$invertCode
Returns
DOMDocumentFragment DocumentFragment containing converted text

Reimplemented from Wikimedia\LangConv\ReplacementMachine.

◆ getCodes()

Wikimedia\LangConv\NullReplacementMachine::getCodes ( )

Return the set of language codes supported.Both key and value are set in order to facilitate inclusion testing.

Returns
array<string,string>

Reimplemented from Wikimedia\LangConv\ReplacementMachine.

◆ isValidCodePair()

Wikimedia\LangConv\NullReplacementMachine::isValidCodePair ( $destCode,
$invertCode )

Override this method in subclass if you want to limit the possible code pairs bracketed.(For example, zh has a large number of variants, but we typically want to use only a limited number of these as possible invert codes.)

Parameters
string$destCode
string$invertCode
Returns
bool whether this is a valid bracketing pair.

Reimplemented from Wikimedia\LangConv\ReplacementMachine.


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