diff options
author | 2021-07-19 15:20:22 -0400 | |
---|---|---|
committer | 2021-07-19 15:20:22 -0400 | |
commit | 9f092345e6bbecfde8c19e6d1490a6031a35f61f (patch) | |
tree | 2abb2398cd0df686e8608e15097ddc58b8995615 /MLEB/cldr/rebuild.php | |
parent | OAuth: Update for fixes and security (diff) | |
download | extensions-9f092345e6bbecfde8c19e6d1490a6031a35f61f.tar.gz extensions-9f092345e6bbecfde8c19e6d1490a6031a35f61f.tar.bz2 extensions-9f092345e6bbecfde8c19e6d1490a6031a35f61f.zip |
Update to MLEB 2021.06
Signed-off-by: Brian Evans <grknight@gentoo.org>
Diffstat (limited to 'MLEB/cldr/rebuild.php')
-rw-r--r-- | MLEB/cldr/rebuild.php | 68 |
1 files changed, 38 insertions, 30 deletions
diff --git a/MLEB/cldr/rebuild.php b/MLEB/cldr/rebuild.php index 745d7553..9aa439f4 100644 --- a/MLEB/cldr/rebuild.php +++ b/MLEB/cldr/rebuild.php @@ -11,6 +11,8 @@ * @license GPL-2.0-or-later */ +use MediaWiki\MediaWikiServices; + // Standard boilerplate to define $IP if ( getenv( 'MW_INSTALL_PATH' ) !== false ) { $IP = getenv( 'MW_INSTALL_PATH' ); @@ -49,8 +51,10 @@ class CLDRRebuild extends Maintenance { $this->error( "CLDR data not found at $DATA\n", 1 ); } + $langNameUtils = MediaWikiServices::getInstance()->getLanguageNameUtils(); + // Get an array of all MediaWiki languages ( $wgLanguageNames + $wgExtraLanguageNames ) - $languages = Language::fetchLanguageNames(); + $languages = $langNameUtils->getLanguageNames(); # hack to get pt-pt too $languages['pt-pt'] = 'Foo'; ksort( $languages ); @@ -80,7 +84,11 @@ class CLDRRebuild extends Maintenance { // If the file exists, parse it, otherwise display an error if ( file_exists( $input ) ) { - $outputFileName = Language::getFileName( 'CldrNames', getRealCode( $code ), '.php' ); + $outputFileName = $langNameUtils->getFileName( + 'CldrNames', + $this->getRealCode( $code ), + '.php' + ); $p = new CLDRParser(); $p->parse( $input, "$OUTPUT/CldrNames/$outputFileName" ); } else { @@ -106,36 +114,36 @@ class CLDRRebuild extends Maintenance { $p->parse_currency_symbols( $DATA, "$OUTPUT/CldrCurrency/Symbols.php" ); $this->output( "Done parsing currency symbols.\n" ); } -} -/** - * Get the code for the MediaWiki localisation, - * these are same as the fallback. - * - * @param string $code - * @return string - */ -function getRealCode( $code ) { - $realCode = $code; - if ( !strcmp( $code, 'kk' ) ) { - $realCode = 'kk-cyrl'; - } elseif ( !strcmp( $code, 'ku' ) ) { - $realCode = 'ku-latn'; - } elseif ( !strcmp( $code, 'sr' ) ) { - $realCode = 'sr-ec'; - } elseif ( !strcmp( $code, 'tg' ) ) { - $realCode = 'tg-cyrl'; - } elseif ( !strcmp( $code, 'zh' ) ) { - $realCode = 'zh-hans'; - } elseif ( !strcmp( $code, 'pt' ) ) { - $realCode = 'pt-br'; - } elseif ( !strcmp( $code, 'pt-pt' ) ) { - $realCode = 'pt'; - } elseif ( !strcmp( $code, 'az-arab' ) ) { - $realCode = 'azb'; - } + /** + * Get the code for the MediaWiki localisation, + * these are same as the fallback. + * + * @param string $code + * @return string + */ + private function getRealCode( $code ) { + $realCode = $code; + if ( !strcmp( $code, 'kk' ) ) { + $realCode = 'kk-cyrl'; + } elseif ( !strcmp( $code, 'ku' ) ) { + $realCode = 'ku-latn'; + } elseif ( !strcmp( $code, 'sr' ) ) { + $realCode = 'sr-ec'; + } elseif ( !strcmp( $code, 'tg' ) ) { + $realCode = 'tg-cyrl'; + } elseif ( !strcmp( $code, 'zh' ) ) { + $realCode = 'zh-hans'; + } elseif ( !strcmp( $code, 'pt' ) ) { + $realCode = 'pt-br'; + } elseif ( !strcmp( $code, 'pt-pt' ) ) { + $realCode = 'pt'; + } elseif ( !strcmp( $code, 'az-arab' ) ) { + $realCode = 'azb'; + } - return $realCode; + return $realCode; + } } $maintClass = CLDRRebuild::class; |