Language: hard deprecate the noSeparators parameter to ::formatNum
Code should use Language::formatNumNoSeparators() instead, which has existed since MW 1.21. Code search: https://codesearch.wmcloud.org/search/?q=formatNum%5C%28%5B%5E%29%5D*%2C&i=nope&files=&repos= Depends-On: I95c365e2535bb3c47bed69a9b702c8f13d9fab87 Depends-On: I012434d5f6c749fec45a6c160e8d5d03686192e9 Depends-On: If3de5645a92514f605d4117fea3a820ed6c86624 Change-Id: I58a66975e505f16d8db5d663a9ca225535277983
This commit is contained in:
parent
ce8d0e9599
commit
1c9bbfc14e
5 changed files with 23 additions and 17 deletions
|
|
@ -361,7 +361,7 @@ class IcuCollation extends Collation {
|
|||
$digits = [ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' ];
|
||||
$letters = array_diff( $letters, $digits );
|
||||
foreach ( $digits as $digit ) {
|
||||
$letters[] = $this->digitTransformLanguage->formatNum( $digit, true );
|
||||
$letters[] = $this->digitTransformLanguage->formatNumNoSeparators( $digit );
|
||||
}
|
||||
} elseif ( $this->locale === 'root' ) {
|
||||
$letters = require "$IP/includes/collation/data/first-letters-root.php";
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ class PatrolLogFormatter extends LogFormatter {
|
|||
|
||||
$target = $this->entry->getTarget();
|
||||
$oldid = $params[3];
|
||||
$revision = $this->context->getLanguage()->formatNum( $oldid, true );
|
||||
$revision = $this->context->getLanguage()->formatNumNoSeparators( $oldid );
|
||||
|
||||
if ( $this->plaintext ) {
|
||||
$revlink = $revision;
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ class TagLogFormatter extends LogFormatter {
|
|||
];
|
||||
}
|
||||
|
||||
$formattedNumber = $this->context->getLanguage()->formatNum( $id, true );
|
||||
$formattedNumber = $this->context->getLanguage()->formatNumNoSeparators( $id );
|
||||
if ( $this->plaintext ) {
|
||||
$link = $formattedNumber;
|
||||
} elseif ( !$isRevLink || $target->exists() ) {
|
||||
|
|
|
|||
|
|
@ -62,9 +62,9 @@ class CoreMagicVariables {
|
|||
case '!':
|
||||
return '|';
|
||||
case 'currentmonth':
|
||||
return $pageLang->formatNum( MWTimestamp::getInstance( $ts )->format( 'm' ), true );
|
||||
return $pageLang->formatNumNoSeparators( MWTimestamp::getInstance( $ts )->format( 'm' ) );
|
||||
case 'currentmonth1':
|
||||
return $pageLang->formatNum( MWTimestamp::getInstance( $ts )->format( 'n' ), true );
|
||||
return $pageLang->formatNumNoSeparators( MWTimestamp::getInstance( $ts )->format( 'n' ) );
|
||||
case 'currentmonthname':
|
||||
return $pageLang->getMonthName( MWTimestamp::getInstance( $ts )->format( 'n' ) );
|
||||
case 'currentmonthnamegen':
|
||||
|
|
@ -72,13 +72,13 @@ class CoreMagicVariables {
|
|||
case 'currentmonthabbrev':
|
||||
return $pageLang->getMonthAbbreviation( MWTimestamp::getInstance( $ts )->format( 'n' ) );
|
||||
case 'currentday':
|
||||
return $pageLang->formatNum( MWTimestamp::getInstance( $ts )->format( 'j' ), true );
|
||||
return $pageLang->formatNumNoSeparators( MWTimestamp::getInstance( $ts )->format( 'j' ) );
|
||||
case 'currentday2':
|
||||
return $pageLang->formatNum( MWTimestamp::getInstance( $ts )->format( 'd' ), true );
|
||||
return $pageLang->formatNumNoSeparators( MWTimestamp::getInstance( $ts )->format( 'd' ) );
|
||||
case 'localmonth':
|
||||
return $pageLang->formatNum( MWTimestamp::getLocalInstance( $ts )->format( 'm' ), true );
|
||||
return $pageLang->formatNumNoSeparators( MWTimestamp::getLocalInstance( $ts )->format( 'm' ) );
|
||||
case 'localmonth1':
|
||||
return $pageLang->formatNum( MWTimestamp::getLocalInstance( $ts )->format( 'n' ), true );
|
||||
return $pageLang->formatNumNoSeparators( MWTimestamp::getLocalInstance( $ts )->format( 'n' ) );
|
||||
case 'localmonthname':
|
||||
return $pageLang->getMonthName( MWTimestamp::getLocalInstance( $ts )->format( 'n' ) );
|
||||
case 'localmonthnamegen':
|
||||
|
|
@ -86,9 +86,9 @@ class CoreMagicVariables {
|
|||
case 'localmonthabbrev':
|
||||
return $pageLang->getMonthAbbreviation( MWTimestamp::getLocalInstance( $ts )->format( 'n' ) );
|
||||
case 'localday':
|
||||
return $pageLang->formatNum( MWTimestamp::getLocalInstance( $ts )->format( 'j' ), true );
|
||||
return $pageLang->formatNumNoSeparators( MWTimestamp::getLocalInstance( $ts )->format( 'j' ) );
|
||||
case 'localday2':
|
||||
return $pageLang->formatNum( MWTimestamp::getLocalInstance( $ts )->format( 'd' ), true );
|
||||
return $pageLang->formatNumNoSeparators( MWTimestamp::getLocalInstance( $ts )->format( 'd' ) );
|
||||
case 'pagename':
|
||||
return wfEscapeWikiText( $title->getText() );
|
||||
case 'pagenamee':
|
||||
|
|
@ -236,11 +236,11 @@ class CoreMagicVariables {
|
|||
case 'currentdayname':
|
||||
return $pageLang->getWeekdayName( (int)MWTimestamp::getInstance( $ts )->format( 'w' ) + 1 );
|
||||
case 'currentyear':
|
||||
return $pageLang->formatNum( MWTimestamp::getInstance( $ts )->format( 'Y' ), true );
|
||||
return $pageLang->formatNumNoSeparators( MWTimestamp::getInstance( $ts )->format( 'Y' ) );
|
||||
case 'currenttime':
|
||||
return $pageLang->time( wfTimestamp( TS_MW, $ts ), false, false );
|
||||
case 'currenthour':
|
||||
return $pageLang->formatNum( MWTimestamp::getInstance( $ts )->format( 'H' ), true );
|
||||
return $pageLang->formatNumNoSeparators( MWTimestamp::getInstance( $ts )->format( 'H' ) );
|
||||
case 'currentweek':
|
||||
// @bug T6594 PHP5 has it zero padded, PHP4 does not, cast to
|
||||
// int to remove the padding
|
||||
|
|
@ -252,7 +252,7 @@ class CoreMagicVariables {
|
|||
(int)MWTimestamp::getLocalInstance( $ts )->format( 'w' ) + 1
|
||||
);
|
||||
case 'localyear':
|
||||
return $pageLang->formatNum( MWTimestamp::getLocalInstance( $ts )->format( 'Y' ), true );
|
||||
return $pageLang->formatNumNoSeparators( MWTimestamp::getLocalInstance( $ts )->format( 'Y' ) );
|
||||
case 'localtime':
|
||||
return $pageLang->time(
|
||||
MWTimestamp::getLocalInstance( $ts )->format( 'YmdHis' ),
|
||||
|
|
@ -260,7 +260,7 @@ class CoreMagicVariables {
|
|||
false
|
||||
);
|
||||
case 'localhour':
|
||||
return $pageLang->formatNum( MWTimestamp::getLocalInstance( $ts )->format( 'H' ), true );
|
||||
return $pageLang->formatNumNoSeparators( MWTimestamp::getLocalInstance( $ts )->format( 'H' ) );
|
||||
case 'localweek':
|
||||
// @bug T6594 PHP5 has it zero padded, PHP4 does not, cast to
|
||||
// int to remove the padding
|
||||
|
|
|
|||
|
|
@ -3253,11 +3253,17 @@ class Language {
|
|||
*
|
||||
* @param string|int|float $number Expected to be a pre-formatted (e.g. leading zeros, number
|
||||
* of decimal places) numeric string. Any non-string will be cast to string.
|
||||
* @param bool $noSeparators Set to true for special numbers like dates
|
||||
* @param bool|null $noSeparators Set to true for special numbers like dates
|
||||
* (deprecated: use ::formatNumNoSeparators instead of this param)
|
||||
* @return string
|
||||
*/
|
||||
public function formatNum( $number, $noSeparators = false ) {
|
||||
public function formatNum( $number, $noSeparators = null ) {
|
||||
if ( $noSeparators !== null ) {
|
||||
wfDeprecated( __METHOD__ . ' with $noSeparators parameter', '1.36' );
|
||||
} else {
|
||||
// The legacy default value.
|
||||
$noSeparators = false;
|
||||
}
|
||||
return $this->formatNumInternal( (string)$number, false, $noSeparators );
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue