Add base language codes as well

In some cases CLDR provides only a script variant we might not use.
This commit is contained in:
Niklas Laxström
2016-05-26 15:34:20 +02:00
parent 35ce36a611
commit 8e4a35bb66
3 changed files with 106 additions and 20 deletions

View File

@@ -3714,9 +3714,12 @@
"AF": [ "AF": [
"fa", "fa",
"ps", "ps",
"uz",
"tk",
"bgn", "bgn",
"ug-arab", "ug-arab",
"kk-arab" "kk-arab",
"kk-cyrl"
], ],
"AG": [ "AG": [
"en", "en",
@@ -3760,6 +3763,7 @@
"AU": [ "AU": [
"en", "en",
"zh-hant", "zh-hant",
"zh",
"it" "it"
], ],
"AW": [ "AW": [
@@ -3773,9 +3777,13 @@
"AZ": [ "AZ": [
"az-latn", "az-latn",
"az-cyrl", "az-cyrl",
"ku-latn" "tly",
"ku-latn",
"ttt",
"tkr"
], ],
"BA": [ "BA": [
"bs",
"en", "en",
"hr", "hr",
"sr-cyrl", "sr-cyrl",
@@ -3827,7 +3835,9 @@
"en" "en"
], ],
"BN": [ "BN": [
"ms",
"zh-hant", "zh-hant",
"zh",
"en" "en"
], ],
"BO": [ "BO": [
@@ -3880,9 +3890,11 @@
"de", "de",
"pdt", "pdt",
"cr", "cr",
"yi" "yi",
"iu"
], ],
"CC": [ "CC": [
"ms",
"en" "en"
], ],
"CD": [ "CD": [
@@ -3928,11 +3940,13 @@
"ff", "ff",
"ar", "ar",
"ksf", "ksf",
"ha-arab" "ha-arab",
"ha-latn"
], ],
"CN": [ "CN": [
"yue", "yue",
"zh-hans", "zh-hans",
"zh",
"wuu", "wuu",
"hsn", "hsn",
"hak", "hak",
@@ -3941,12 +3955,16 @@
"ii", "ii",
"ug-arab", "ug-arab",
"za", "za",
"mn",
"bo", "bo",
"ko", "ko",
"kk-arab", "kk-arab",
"kk-cyrl",
"ky",
"en", "en",
"ru", "ru",
"vi", "vi",
"uz",
"lzh" "lzh"
], ],
"CO": [ "CO": [
@@ -4137,9 +4155,11 @@
"cy", "cy",
"bn", "bn",
"zh-hant", "zh-hant",
"zh",
"el", "el",
"it", "it",
"ks-arab", "ks-arab",
"ks",
"gd", "gd",
"yi", "yi",
"ml", "ml",
@@ -4161,7 +4181,8 @@
], ],
"GF": [ "GF": [
"fr", "fr",
"zh-hant" "zh-hant",
"zh"
], ],
"GG": [ "GG": [
"en" "en"
@@ -4200,6 +4221,7 @@
"GR": [ "GR": [
"el", "el",
"en", "en",
"pnt",
"mk", "mk",
"tr", "tr",
"bg", "bg",
@@ -4221,6 +4243,7 @@
], ],
"HK": [ "HK": [
"zh-hant", "zh-hant",
"zh",
"yue", "yue",
"en", "en",
"zh-hans" "zh-hans"
@@ -4254,6 +4277,7 @@
"id", "id",
"jv", "jv",
"su", "su",
"ms",
"min", "min",
"bew", "bew",
"ban", "ban",
@@ -4262,6 +4286,7 @@
"ace", "ace",
"bbc", "bbc",
"zh-hant", "zh-hant",
"zh",
"sly", "sly",
"mwv" "mwv"
], ],
@@ -4307,7 +4332,9 @@
"ne", "ne",
"sat", "sat",
"ks-arab", "ks-arab",
"ks",
"gom-deva", "gom-deva",
"sd",
"tcy", "tcy",
"brx", "brx",
"mni", "mni",
@@ -4328,16 +4355,19 @@
"en", "en",
"ckb", "ckb",
"az-arab", "az-arab",
"az-latn",
"fa", "fa",
"lrc" "lrc"
], ],
"IR": [ "IR": [
"fa", "fa",
"az-arab", "az-arab",
"az-latn",
"mzn", "mzn",
"glk", "glk",
"ckb", "ckb",
"sdh", "sdh",
"tk",
"lrc", "lrc",
"ar", "ar",
"bqi", "bqi",
@@ -4348,7 +4378,8 @@
"ps", "ps",
"ka", "ka",
"gbz", "gbz",
"kk-arab" "kk-arab",
"kk-cyrl"
], ],
"IS": [ "IS": [
"is", "is",
@@ -4403,6 +4434,7 @@
"gu" "gu"
], ],
"KG": [ "KG": [
"ky",
"ru" "ru"
], ],
"KH": [ "KH": [
@@ -4435,7 +4467,8 @@
"kk-cyrl", "kk-cyrl",
"en", "en",
"de", "de",
"ug-cyrl" "ug-cyrl",
"ug-arab"
], ],
"LA": [ "LA": [
"lo" "lo"
@@ -4445,6 +4478,7 @@
"en", "en",
"hy", "hy",
"ku-arab", "ku-arab",
"ku-latn",
"fr" "fr"
], ],
"LC": [ "LC": [
@@ -4495,8 +4529,10 @@
"zgh", "zgh",
"fr", "fr",
"en", "en",
"tzm",
"shi-latn", "shi-latn",
"shi-tfng", "shi-tfng",
"rif",
"es" "es"
], ],
"MC": [ "MC": [
@@ -4511,8 +4547,8 @@
], ],
"ME": [ "ME": [
"sr-latn", "sr-latn",
"sq", "sr-cyrl",
"sr-cyrl" "sq"
], ],
"MF": [ "MF": [
"fr" "fr"
@@ -4532,6 +4568,7 @@
"tr" "tr"
], ],
"ML": [ "ML": [
"bm",
"fr", "fr",
"ses", "ses",
"ar" "ar"
@@ -4543,13 +4580,18 @@
"mnw" "mnw"
], ],
"MN": [ "MN": [
"mn",
"kk-arab", "kk-arab",
"kk-cyrl",
"zh-hans", "zh-hans",
"zh",
"ru", "ru",
"ug-cyrl" "ug-cyrl",
"ug-arab"
], ],
"MO": [ "MO": [
"zh-hant", "zh-hant",
"zh",
"pt", "pt",
"zh-hans", "zh-hans",
"en" "en"
@@ -4598,8 +4640,10 @@
"sei" "sei"
], ],
"MY": [ "MY": [
"ms",
"en", "en",
"zh-hant", "zh-hant",
"zh",
"ta", "ta",
"jv", "jv",
"dtp", "dtp",
@@ -4655,6 +4699,7 @@
"fy", "fy",
"id", "id",
"zea", "zea",
"rif",
"tr" "tr"
], ],
"NO": [ "NO": [
@@ -4692,7 +4737,8 @@
"PA": [ "PA": [
"es", "es",
"en", "en",
"zh-hant" "zh-hant",
"zh"
], ],
"PE": [ "PE": [
"es", "es",
@@ -4702,7 +4748,8 @@
"PF": [ "PF": [
"fr", "fr",
"ty", "ty",
"zh-hant" "zh-hant",
"zh"
], ],
"PG": [ "PG": [
"tpi", "tpi",
@@ -4720,19 +4767,24 @@
"pam", "pam",
"pag", "pag",
"zh-hant", "zh-hant",
"zh",
"cps", "cps",
"krj", "krj",
"bto" "bto"
], ],
"PK": [ "PK": [
"ur", "ur",
"pa-guru",
"en", "en",
"ps", "ps",
"sd",
"brh", "brh",
"fa", "fa",
"bgn", "bgn",
"tg",
"khw", "khw",
"ks-arab" "ks-arab",
"ks"
], ],
"PL": [ "PL": [
"pl", "pl",
@@ -4790,6 +4842,7 @@
"de", "de",
"tr", "tr",
"sr-latn", "sr-latn",
"sr-cyrl",
"bg", "bg",
"el", "el",
"pl" "pl"
@@ -4824,6 +4877,7 @@
"inh", "inh",
"tyv", "tyv",
"az-cyrl", "az-cyrl",
"az-latn",
"ady", "ady",
"krl", "krl",
"lbe", "lbe",
@@ -4831,7 +4885,9 @@
"mrj", "mrj",
"fi", "fi",
"sr-latn", "sr-latn",
"sr-cyrl",
"vep", "vep",
"mn",
"vot", "vot",
"cu" "cu"
], ],
@@ -4853,7 +4909,8 @@
"SD": [ "SD": [
"ar", "ar",
"en", "en",
"ha-arab" "ha-arab",
"ha-latn"
], ],
"SE": [ "SE": [
"sv", "sv",
@@ -4869,6 +4926,8 @@
"SG": [ "SG": [
"en", "en",
"zh-hans", "zh-hans",
"zh",
"ms",
"ta", "ta",
"ml", "ml",
"pa-guru" "pa-guru"
@@ -4916,7 +4975,8 @@
"SR": [ "SR": [
"nl", "nl",
"srn", "srn",
"zh-hant" "zh-hant",
"zh"
], ],
"SS": [ "SS": [
"ar", "ar",
@@ -4966,11 +5026,13 @@
"th", "th",
"en", "en",
"zh-hant", "zh-hant",
"zh",
"mnw", "mnw",
"shn" "shn"
], ],
"TJ": [ "TJ": [
"tg-cyrl", "tg-cyrl",
"tg",
"ru", "ru",
"fa", "fa",
"ar" "ar"
@@ -4983,7 +5045,9 @@
"tet" "tet"
], ],
"TM": [ "TM": [
"tk",
"ru", "ru",
"uz",
"ku-latn" "ku-latn"
], ],
"TN": [ "TN": [
@@ -5009,10 +5073,14 @@
"hy", "hy",
"ka", "ka",
"sr-latn", "sr-latn",
"sr-cyrl",
"lzz",
"sq", "sq",
"ab", "ab",
"el", "el",
"tru", "tru",
"uz",
"ky",
"kk-cyrl" "kk-cyrl"
], ],
"TT": [ "TT": [
@@ -5023,7 +5091,8 @@
"en" "en"
], ],
"TW": [ "TW": [
"zh-hant" "zh-hant",
"zh"
], ],
"TZ": [ "TZ": [
"sw", "sw",
@@ -5056,6 +5125,7 @@
"en", "en",
"es", "es",
"zh-hant", "zh-hant",
"zh",
"fr", "fr",
"de", "de",
"tl", "tl",
@@ -5079,6 +5149,7 @@
"es" "es"
], ],
"UZ": [ "UZ": [
"uz",
"ru", "ru",
"kaa", "kaa",
"tr" "tr"
@@ -5101,7 +5172,8 @@
], ],
"VN": [ "VN": [
"vi", "vi",
"zh-hant" "zh-hant",
"zh"
], ],
"VU": [ "VU": [
"bi", "bi",

View File

@@ -64,8 +64,17 @@ foreach ( $supplementalData->territoryInfo->territory as $territoryRecord ) {
$languageCodeAttr = $languageAttributes['type']; $languageCodeAttr = $languageAttributes['type'];
// Lower case is a convention for language codes in ULS. // Lower case is a convention for language codes in ULS.
// '_' is used in CLDR for compound codes and it's replaced with '-' here. // '_' is used in CLDR for compound codes and it's replaced with '-' here.
$parsedLangdb['territories'][$territoryCode][] =
strtr( strtolower( (string) $languageCodeAttr[0] ), '_', '-' ); $normalisedCode = strtr( strtolower( (string) $languageCodeAttr[0] ), '_', '-' );
$parsedLangdb['territories'][$territoryCode][] = $normalisedCode;
// In case of codes with variants, also add the base because ULS might consider
// them as separate languages, e.g. zh, zh-hant and zh-hans.
if ( strpos( $normalisedCode, '-' ) !== false ) {
$parts = explode( '-', $normalisedCode );
$parsedLangdb['territories'][$territoryCode][] = $parts[0];
}
} }
} }
@@ -91,6 +100,11 @@ foreach ( $parsedLangdb['territories'] as $territoryCode => $languages ) {
continue; continue;
} }
// Remove duplicates we might have created
$parsedLangdb['territories'][$territoryCode] =
array_unique( $parsedLangdb['territories'][$territoryCode] );
// We need to renumber or json conversion thinks these are objects // We need to renumber or json conversion thinks these are objects
$parsedLangdb['territories'][$territoryCode] = $parsedLangdb['territories'][$territoryCode] =
array_values( $parsedLangdb['territories'][$territoryCode] ); array_values( $parsedLangdb['territories'][$territoryCode] );

File diff suppressed because one or more lines are too long