46 'be-x-old' =>
'be-tarask',
49 'zh-classical' =>
'lzh',
50 'zh-min-nan' =>
'nan',
88 'de-formal' =>
'de-x-formal',
90 'en-rtl' =>
'en-x-rtl',
91 'es-formal' =>
'es-x-formal',
92 'hu-formal' =>
'hu-x-formal',
93 'map-bms' =>
'jv-x-bms',
96 'nl-informal' =>
'nl-x-informal',
97 'roa-tara' =>
'nap-x-tara',
98 'simple' =>
'en-simple',
100 'sr-el' =>
'sr-Latn',
107 'zh-cn' =>
'zh-Hans-CN',
108 'zh-sg' =>
'zh-Hans-SG',
109 'zh-my' =>
'zh-Hans-MY',
110 'zh-tw' =>
'zh-Hant-TW',
111 'zh-hk' =>
'zh-Hant-HK',
112 'zh-mo' =>
'zh-Hant-MO',
145 foreach ( self::$deprecatedLanguageCodeMapping as $code => $ignore ) {
148 foreach ( self::$nonstandardLanguageCodeMapping as $code => $ignore ) {
165 return self::$deprecatedLanguageCodeMapping[$code] ?? $code;
178 public static function bcp47( $code ) {
180 if ( isset( self::$nonstandardLanguageCodeMapping[$code] ) ) {
181 $code = self::$nonstandardLanguageCodeMapping[$code];
183 $codeSegment = explode(
'-', $code );
185 foreach ( $codeSegment as $segNo => $seg ) {
187 if ( $segNo > 0 && strtolower( $codeSegment[( $segNo - 1 )] ) ==
'x' ) {
188 $codeBCP[$segNo] = strtolower( $seg );
190 } elseif ( ( strlen( $seg ) == 2 ) && ( $segNo > 0 ) ) {
191 $codeBCP[$segNo] = strtoupper( $seg );
193 } elseif ( ( strlen( $seg ) == 4 ) && ( $segNo > 0 ) ) {
194 $codeBCP[$segNo] = ucfirst( strtolower( $seg ) );
197 $codeBCP[$segNo] = strtolower( $seg );
200 $langCode = implode(
'-', $codeBCP );