Language Converter
Finite-State Transducer implementation of MediaWiki LanguageConverter
|
A machine to convert and/or replace text. More...
Public Member Functions | |
__construct () | |
ReplacementMachine constructor. | |
getCodes () | |
Return the set of language codes supported. | |
isValidCodePair ( $destCode, $invertCode) | |
Override this method in subclass if you want to limit the possible code pairs bracketed. | |
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. | |
convert ( $document, $s, $destCode, $invertCode) | |
Convert a string of text. | |
jsonEncode (array $obj) | |
Allow client to customize the JSON encoding of data-mw-variant attributes. | |
A machine to convert and/or replace text.
Wikimedia\LangConv\ReplacementMachine::__construct | ( | ) |
ReplacementMachine constructor.
Reimplemented in Wikimedia\LangConv\ZhReplacementMachine.
|
abstract |
Convert a string of text.
DOMDocument | $document | |
string | $s | text to convert |
string | $destCode | destination language code |
string | $invertCode |
Reimplemented in Wikimedia\LangConv\FstReplacementMachine, and Wikimedia\LangConv\NullReplacementMachine.
|
abstract |
Return the set of language codes supported.
Both key and value are set in order to facilitate inclusion testing.
Reimplemented in Wikimedia\LangConv\FstReplacementMachine, and Wikimedia\LangConv\NullReplacementMachine.
Wikimedia\LangConv\ReplacementMachine::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.)
string | $destCode | |
string | $invertCode |
Reimplemented in Wikimedia\LangConv\NullReplacementMachine, and Wikimedia\LangConv\ZhReplacementMachine.
Wikimedia\LangConv\ReplacementMachine::jsonEncode | ( | array | $obj | ) |
Allow client to customize the JSON encoding of data-mw-variant attributes.
array | $obj | The structured attribute value to encode |
Wikimedia\LangConv\ReplacementMachine::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.
DOMNode | $textNode | |
string | $destCode | |
string | $invertCode |