/** * @dataProvider provideGetNumberRegexMatch */ public function testGetNumberRegexMatch($value, $lang = 'en') { $lang = Language::factory($lang); $unlocalizer = new MediaWikiNumberUnlocalizer($lang); $regex = $unlocalizer->getNumberRegex(); $hex = utf8ToHexSequence($regex); $match = (bool) preg_match("/^(?:{$regex})\$/u", $value, $m); $this->assertTrue($match, "Hex {$value}: {$hex}"); $this->assertCount(1, $m, 'There should be no capturing groups'); }
public function execute() { foreach ($this->mLangs as $code) { $filename = Language::getMessagesFileName($code); $this->output("Loading language [{$code}] ... "); unset($digitTransformTable); require_once $filename; if (!isset($digitTransformTable)) { $this->error("\$digitTransformTable not found for lang: {$code}"); continue; } $this->output("OK\n\$digitTransformTable = array(\n"); foreach ($digitTransformTable as $latin => $translation) { $htmlent = utf8ToHexSequence($translation); $this->output("'{$latin}' => '{$translation}', # &#x{$htmlent};\n"); } $this->output(");\n"); } }
<?php /** * @file * @ingroup MaintenanceLanguage */ require '../commandLine.inc'; # A list of unicode numerals is available at: # http://www.fileformat.info/info/unicode/category/Nd/list.htm $langs = array('Ar', 'As', 'Bh', 'Bo', 'Dz', 'Fa', 'Gu', 'Hi', 'Km', 'Kn', 'Ks', 'Lo', 'Ml', 'Mr', 'Ne', 'New', 'Or', 'Pa', 'Pi', 'Sa'); foreach ($langs as $code) { $filename = Language::getMessagesFileName($code); echo "Loading language [{$code}] ... "; unset($digitTransformTable); require_once $filename; if (!isset($digitTransformTable)) { print "\$digitTransformTable not found\n"; continue; } print "OK\n\$digitTransformTable = array(\n"; foreach ($digitTransformTable as $latin => $translation) { $htmlent = utf8ToHexSequence($translation); print "'{$latin}' => '{$translation}', # &#x{$htmlent};\n"; } print ");\n"; }
/** * @ignore * @param string $string * @return string */ function pretty($string) { return strtoupper(utf8ToHexSequence($string)); }