Page MenuHomePhabricator

Verify that deprecated language codes are identical to their replacements in the WMF interwiki map

Authored By
Lucas_Werkmeister_WMDE
Jan 27 2023, 2:28 PM
Size
1 KB
Referenced Files
None
Subscribers
None

Verify that deprecated language codes are identical to their replacements in the WMF interwiki map

<?php
$deprecatedMapping = [ // LanguageCode::DEPRECATED_LANGUAGE_CODE_MAPPING
// Note that als is actually a valid ISO 639 code (Tosk Albanian), but it
// was previously used in MediaWiki for Alsatian, which comes under gsw
'als' => 'gsw', // T25215
'bat-smg' => 'sgs', // T27522
'be-x-old' => 'be-tarask', // T11823
'fiu-vro' => 'vro', // T31186
'roa-rup' => 'rup', // T17988
'zh-classical' => 'lzh', // T30443
'zh-min-nan' => 'nan', // T30442
'zh-yue' => 'yue', // T30441
];
$interwikiCache = eval( '?>' . file_get_contents( 'https://noc.wikimedia.org/conf/interwiki.php.txt' ) );
$i = 1;
$ok = true;
foreach ( $interwikiCache as $key => $value ) {
[ $prefix, $interwiki ] = explode( ':', $key, 2 );
if ( ( $replacementInterwiki = $deprecatedMapping[ $interwiki ] ?? null ) !== null ) {
$replacementKey = "$prefix:$replacementInterwiki";
if ( ( $replacementValue = $interwikiCache[ $replacementKey ] ) === $value ) {
echo "ok $i - $key == $replacementKey" . PHP_EOL;
} else {
echo "not ok $i - $key ($value) !== $replacementKey ($replacementValue)" . PHP_EOL;
$ok = false;
}
++$i;
}
}
exit( $ok ? 0 : 1 );

File Metadata

Mime Type
text/plain; charset=utf-8
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
10482261
Default Alt Text
Verify that deprecated language codes are identical to their replacements in the WMF interwiki map (1 KB)

Event Timeline