language: Clean up $separatorTransformTable in km/la/my

LanguageKm and LanguageMy defined overrides for ::formatNum()
which did nothing -- but what they really wanted to do was just to
suppress separators.  Do that in the 'modern' way by invoking
::formatNumNoSeparators().

MessagesLa and MessagesKm defined $separatorTransformTable for one but
not both of the keys `.` and `,`.  Add defaults to
Language::formatNum() to handle this case without burping out a PHP
notice.  Use belt and suspenders by also defining an identity mapping
for '.' in MessagesLa::$separatorTransformTable.

Bug: T267091
Change-Id: I0169606ca1e211d241fa71f23ee0a16edc64b7ae
This commit is contained in:
C. Scott Ananian 2020-11-04 16:10:47 -05:00 committed by C. Scott Ananian
parent a6ab1f9ac0
commit d7b2fe4d46
4 changed files with 25 additions and 13 deletions

View file

@ -3334,11 +3334,23 @@ class Language {
// supports. Example: arq. Also, languages like pl has
// customisation. So manually set it.
if ( $noTranslate ) {
$fmt->setSymbol( NumberFormatter::DECIMAL_SEPARATOR_SYMBOL, '.' );
$fmt->setSymbol( NumberFormatter::GROUPING_SEPARATOR_SYMBOL, ',' );
$fmt->setSymbol(
NumberFormatter::DECIMAL_SEPARATOR_SYMBOL,
'.'
);
$fmt->setSymbol(
NumberFormatter::GROUPING_SEPARATOR_SYMBOL,
','
);
} elseif ( $separatorTransformTable ) {
$fmt->setSymbol( NumberFormatter::DECIMAL_SEPARATOR_SYMBOL, $separatorTransformTable[ '.' ] );
$fmt->setSymbol( NumberFormatter::GROUPING_SEPARATOR_SYMBOL, $separatorTransformTable[ ',' ] );
$fmt->setSymbol(
NumberFormatter::DECIMAL_SEPARATOR_SYMBOL,
$separatorTransformTable[ '.' ] ?? '.'
);
$fmt->setSymbol(
NumberFormatter::GROUPING_SEPARATOR_SYMBOL,
$separatorTransformTable[ ',' ] ?? ','
);
}
// Maintain # of digits before and after the decimal point

View file

@ -30,16 +30,16 @@
class LanguageKm extends Language {
/**
* @param string $_
* @param bool|null $noSeparator
* @param string $number
* @param bool|null $noSeparators
* @return string
*/
public function formatNum( $_, $noSeparator = null ) {
public function formatNum( $number, $noSeparators = null ) {
/* NO-op for Khmer. Cannot use
* $separatorTransformTable = [ ',' => '' ]
* That would break when parsing and doing strstr '' => 'foo';
*/
return $_;
return $this->formatNumNoSeparators( $number );
}
}

View file

@ -30,15 +30,15 @@
class LanguageMy extends Language {
/**
* @param string $_
* @param bool|null $noSeparator
* @param string $number
* @param bool|null $noSeparators
* @return string
*/
public function formatNum( $_, $noSeparator = null ) {
public function formatNum( $number, $noSeparators = null ) {
/* NO-op. Cannot use
* $separatorTransformTable = [ ',' => '' ]
* That would break when parsing and doing strstr '' => 'foo';
*/
return $_;
return $this->formatNumNoSeparators( $number );
}
}

View file

@ -51,7 +51,7 @@ $namespaceAliases = [
'Disputatio_Imaginis' => NS_FILE_TALK,
];
$separatorTransformTable = [ ',' => "\u{00A0}" ];
$separatorTransformTable = [ ',' => "\u{00A0}", '.' => '.' ];
$dateFormats = [
'mdy time' => 'H:i',