Bug 1407674 - Shrink extlangMappings by removing redundant "preferred" fields. r=Waldo

This commit is contained in:
André Bargull 2017-10-12 05:30:19 -07:00
Родитель 46b0925912
Коммит f5a7cfc81b
3 изменённых файлов: 256 добавлений и 242 удалений

Просмотреть файл

@ -427,8 +427,10 @@ function CanonicalizeLanguageTag(locale) {
// "zh-nan" -> "nan"
// Note that the script generating extlangMappings makes sure that
// no extlang mapping will replace a normal language code.
subtag = extlangMappings[subtag].preferred;
if (i === 1 && extlangMappings[subtag].prefix === subtags[0]) {
// The preferred value for all current deprecated extlang subtags
// is equal to the extlang subtag, so we only need remove the
// redundant prefix to get the preferred value.
if (i === 1 && extlangMappings[subtag] === subtags[0]) {
callFunction(std_Array_shift, subtags);
i--;
}

Просмотреть файл

@ -1,7 +1,7 @@
// Generated by make_intl_data.py. DO NOT EDIT.
// Mappings from complete tags to preferred values.
// Derived from IANA Language Subtag Registry, file date 2017-03-03.
// Derived from IANA Language Subtag Registry, file date 2017-08-15.
// https://www.iana.org/assignments/language-subtag-registry
var langTagMappings = {
"art-lojban": "jbo",
@ -59,7 +59,7 @@ var langTagMappings = {
};
// Mappings from non-extlang subtags to preferred values.
// Derived from IANA Language Subtag Registry, file date 2017-03-03.
// Derived from IANA Language Subtag Registry, file date 2017-08-15.
// https://www.iana.org/assignments/language-subtag-registry
var langSubtagMappings = {
"BU": "MM",
@ -148,239 +148,242 @@ var langSubtagMappings = {
};
// Mappings from extlang subtags to preferred values.
// Derived from IANA Language Subtag Registry, file date 2017-03-03.
// All current deprecated extlang subtags have the form `<prefix>-<extlang>`
// and their preferred value is exactly equal to `<extlang>`. So each key in
// extlangMappings acts both as the extlang subtag and its preferred value.
// Derived from IANA Language Subtag Registry, file date 2017-08-15.
// https://www.iana.org/assignments/language-subtag-registry
var extlangMappings = {
"aao": {preferred: "aao", prefix: "ar"},
"abh": {preferred: "abh", prefix: "ar"},
"abv": {preferred: "abv", prefix: "ar"},
"acm": {preferred: "acm", prefix: "ar"},
"acq": {preferred: "acq", prefix: "ar"},
"acw": {preferred: "acw", prefix: "ar"},
"acx": {preferred: "acx", prefix: "ar"},
"acy": {preferred: "acy", prefix: "ar"},
"adf": {preferred: "adf", prefix: "ar"},
"ads": {preferred: "ads", prefix: "sgn"},
"aeb": {preferred: "aeb", prefix: "ar"},
"aec": {preferred: "aec", prefix: "ar"},
"aed": {preferred: "aed", prefix: "sgn"},
"aen": {preferred: "aen", prefix: "sgn"},
"afb": {preferred: "afb", prefix: "ar"},
"afg": {preferred: "afg", prefix: "sgn"},
"ajp": {preferred: "ajp", prefix: "ar"},
"apc": {preferred: "apc", prefix: "ar"},
"apd": {preferred: "apd", prefix: "ar"},
"arb": {preferred: "arb", prefix: "ar"},
"arq": {preferred: "arq", prefix: "ar"},
"ars": {preferred: "ars", prefix: "ar"},
"ary": {preferred: "ary", prefix: "ar"},
"arz": {preferred: "arz", prefix: "ar"},
"ase": {preferred: "ase", prefix: "sgn"},
"asf": {preferred: "asf", prefix: "sgn"},
"asp": {preferred: "asp", prefix: "sgn"},
"asq": {preferred: "asq", prefix: "sgn"},
"asw": {preferred: "asw", prefix: "sgn"},
"auz": {preferred: "auz", prefix: "ar"},
"avl": {preferred: "avl", prefix: "ar"},
"ayh": {preferred: "ayh", prefix: "ar"},
"ayl": {preferred: "ayl", prefix: "ar"},
"ayn": {preferred: "ayn", prefix: "ar"},
"ayp": {preferred: "ayp", prefix: "ar"},
"bbz": {preferred: "bbz", prefix: "ar"},
"bfi": {preferred: "bfi", prefix: "sgn"},
"bfk": {preferred: "bfk", prefix: "sgn"},
"bjn": {preferred: "bjn", prefix: "ms"},
"bog": {preferred: "bog", prefix: "sgn"},
"bqn": {preferred: "bqn", prefix: "sgn"},
"bqy": {preferred: "bqy", prefix: "sgn"},
"btj": {preferred: "btj", prefix: "ms"},
"bve": {preferred: "bve", prefix: "ms"},
"bvl": {preferred: "bvl", prefix: "sgn"},
"bvu": {preferred: "bvu", prefix: "ms"},
"bzs": {preferred: "bzs", prefix: "sgn"},
"cdo": {preferred: "cdo", prefix: "zh"},
"cds": {preferred: "cds", prefix: "sgn"},
"cjy": {preferred: "cjy", prefix: "zh"},
"cmn": {preferred: "cmn", prefix: "zh"},
"coa": {preferred: "coa", prefix: "ms"},
"cpx": {preferred: "cpx", prefix: "zh"},
"csc": {preferred: "csc", prefix: "sgn"},
"csd": {preferred: "csd", prefix: "sgn"},
"cse": {preferred: "cse", prefix: "sgn"},
"csf": {preferred: "csf", prefix: "sgn"},
"csg": {preferred: "csg", prefix: "sgn"},
"csl": {preferred: "csl", prefix: "sgn"},
"csn": {preferred: "csn", prefix: "sgn"},
"csq": {preferred: "csq", prefix: "sgn"},
"csr": {preferred: "csr", prefix: "sgn"},
"czh": {preferred: "czh", prefix: "zh"},
"czo": {preferred: "czo", prefix: "zh"},
"doq": {preferred: "doq", prefix: "sgn"},
"dse": {preferred: "dse", prefix: "sgn"},
"dsl": {preferred: "dsl", prefix: "sgn"},
"dup": {preferred: "dup", prefix: "ms"},
"ecs": {preferred: "ecs", prefix: "sgn"},
"esl": {preferred: "esl", prefix: "sgn"},
"esn": {preferred: "esn", prefix: "sgn"},
"eso": {preferred: "eso", prefix: "sgn"},
"eth": {preferred: "eth", prefix: "sgn"},
"fcs": {preferred: "fcs", prefix: "sgn"},
"fse": {preferred: "fse", prefix: "sgn"},
"fsl": {preferred: "fsl", prefix: "sgn"},
"fss": {preferred: "fss", prefix: "sgn"},
"gan": {preferred: "gan", prefix: "zh"},
"gds": {preferred: "gds", prefix: "sgn"},
"gom": {preferred: "gom", prefix: "kok"},
"gse": {preferred: "gse", prefix: "sgn"},
"gsg": {preferred: "gsg", prefix: "sgn"},
"gsm": {preferred: "gsm", prefix: "sgn"},
"gss": {preferred: "gss", prefix: "sgn"},
"gus": {preferred: "gus", prefix: "sgn"},
"hab": {preferred: "hab", prefix: "sgn"},
"haf": {preferred: "haf", prefix: "sgn"},
"hak": {preferred: "hak", prefix: "zh"},
"hds": {preferred: "hds", prefix: "sgn"},
"hji": {preferred: "hji", prefix: "ms"},
"hks": {preferred: "hks", prefix: "sgn"},
"hos": {preferred: "hos", prefix: "sgn"},
"hps": {preferred: "hps", prefix: "sgn"},
"hsh": {preferred: "hsh", prefix: "sgn"},
"hsl": {preferred: "hsl", prefix: "sgn"},
"hsn": {preferred: "hsn", prefix: "zh"},
"icl": {preferred: "icl", prefix: "sgn"},
"iks": {preferred: "iks", prefix: "sgn"},
"ils": {preferred: "ils", prefix: "sgn"},
"inl": {preferred: "inl", prefix: "sgn"},
"ins": {preferred: "ins", prefix: "sgn"},
"ise": {preferred: "ise", prefix: "sgn"},
"isg": {preferred: "isg", prefix: "sgn"},
"isr": {preferred: "isr", prefix: "sgn"},
"jak": {preferred: "jak", prefix: "ms"},
"jax": {preferred: "jax", prefix: "ms"},
"jcs": {preferred: "jcs", prefix: "sgn"},
"jhs": {preferred: "jhs", prefix: "sgn"},
"jls": {preferred: "jls", prefix: "sgn"},
"jos": {preferred: "jos", prefix: "sgn"},
"jsl": {preferred: "jsl", prefix: "sgn"},
"jus": {preferred: "jus", prefix: "sgn"},
"kgi": {preferred: "kgi", prefix: "sgn"},
"knn": {preferred: "knn", prefix: "kok"},
"kvb": {preferred: "kvb", prefix: "ms"},
"kvk": {preferred: "kvk", prefix: "sgn"},
"kvr": {preferred: "kvr", prefix: "ms"},
"kxd": {preferred: "kxd", prefix: "ms"},
"lbs": {preferred: "lbs", prefix: "sgn"},
"lce": {preferred: "lce", prefix: "ms"},
"lcf": {preferred: "lcf", prefix: "ms"},
"liw": {preferred: "liw", prefix: "ms"},
"lls": {preferred: "lls", prefix: "sgn"},
"lsg": {preferred: "lsg", prefix: "sgn"},
"lsl": {preferred: "lsl", prefix: "sgn"},
"lso": {preferred: "lso", prefix: "sgn"},
"lsp": {preferred: "lsp", prefix: "sgn"},
"lst": {preferred: "lst", prefix: "sgn"},
"lsy": {preferred: "lsy", prefix: "sgn"},
"ltg": {preferred: "ltg", prefix: "lv"},
"lvs": {preferred: "lvs", prefix: "lv"},
"lzh": {preferred: "lzh", prefix: "zh"},
"max": {preferred: "max", prefix: "ms"},
"mdl": {preferred: "mdl", prefix: "sgn"},
"meo": {preferred: "meo", prefix: "ms"},
"mfa": {preferred: "mfa", prefix: "ms"},
"mfb": {preferred: "mfb", prefix: "ms"},
"mfs": {preferred: "mfs", prefix: "sgn"},
"min": {preferred: "min", prefix: "ms"},
"mnp": {preferred: "mnp", prefix: "zh"},
"mqg": {preferred: "mqg", prefix: "ms"},
"mre": {preferred: "mre", prefix: "sgn"},
"msd": {preferred: "msd", prefix: "sgn"},
"msi": {preferred: "msi", prefix: "ms"},
"msr": {preferred: "msr", prefix: "sgn"},
"mui": {preferred: "mui", prefix: "ms"},
"mzc": {preferred: "mzc", prefix: "sgn"},
"mzg": {preferred: "mzg", prefix: "sgn"},
"mzy": {preferred: "mzy", prefix: "sgn"},
"nan": {preferred: "nan", prefix: "zh"},
"nbs": {preferred: "nbs", prefix: "sgn"},
"ncs": {preferred: "ncs", prefix: "sgn"},
"nsi": {preferred: "nsi", prefix: "sgn"},
"nsl": {preferred: "nsl", prefix: "sgn"},
"nsp": {preferred: "nsp", prefix: "sgn"},
"nsr": {preferred: "nsr", prefix: "sgn"},
"nzs": {preferred: "nzs", prefix: "sgn"},
"okl": {preferred: "okl", prefix: "sgn"},
"orn": {preferred: "orn", prefix: "ms"},
"ors": {preferred: "ors", prefix: "ms"},
"pel": {preferred: "pel", prefix: "ms"},
"pga": {preferred: "pga", prefix: "ar"},
"pgz": {preferred: "pgz", prefix: "sgn"},
"pks": {preferred: "pks", prefix: "sgn"},
"prl": {preferred: "prl", prefix: "sgn"},
"prz": {preferred: "prz", prefix: "sgn"},
"psc": {preferred: "psc", prefix: "sgn"},
"psd": {preferred: "psd", prefix: "sgn"},
"pse": {preferred: "pse", prefix: "ms"},
"psg": {preferred: "psg", prefix: "sgn"},
"psl": {preferred: "psl", prefix: "sgn"},
"pso": {preferred: "pso", prefix: "sgn"},
"psp": {preferred: "psp", prefix: "sgn"},
"psr": {preferred: "psr", prefix: "sgn"},
"pys": {preferred: "pys", prefix: "sgn"},
"rms": {preferred: "rms", prefix: "sgn"},
"rsl": {preferred: "rsl", prefix: "sgn"},
"rsm": {preferred: "rsm", prefix: "sgn"},
"sdl": {preferred: "sdl", prefix: "sgn"},
"sfb": {preferred: "sfb", prefix: "sgn"},
"sfs": {preferred: "sfs", prefix: "sgn"},
"sgg": {preferred: "sgg", prefix: "sgn"},
"sgx": {preferred: "sgx", prefix: "sgn"},
"shu": {preferred: "shu", prefix: "ar"},
"slf": {preferred: "slf", prefix: "sgn"},
"sls": {preferred: "sls", prefix: "sgn"},
"sqk": {preferred: "sqk", prefix: "sgn"},
"sqs": {preferred: "sqs", prefix: "sgn"},
"ssh": {preferred: "ssh", prefix: "ar"},
"ssp": {preferred: "ssp", prefix: "sgn"},
"ssr": {preferred: "ssr", prefix: "sgn"},
"svk": {preferred: "svk", prefix: "sgn"},
"swc": {preferred: "swc", prefix: "sw"},
"swh": {preferred: "swh", prefix: "sw"},
"swl": {preferred: "swl", prefix: "sgn"},
"syy": {preferred: "syy", prefix: "sgn"},
"szs": {preferred: "szs", prefix: "sgn"},
"tmw": {preferred: "tmw", prefix: "ms"},
"tse": {preferred: "tse", prefix: "sgn"},
"tsm": {preferred: "tsm", prefix: "sgn"},
"tsq": {preferred: "tsq", prefix: "sgn"},
"tss": {preferred: "tss", prefix: "sgn"},
"tsy": {preferred: "tsy", prefix: "sgn"},
"tza": {preferred: "tza", prefix: "sgn"},
"ugn": {preferred: "ugn", prefix: "sgn"},
"ugy": {preferred: "ugy", prefix: "sgn"},
"ukl": {preferred: "ukl", prefix: "sgn"},
"uks": {preferred: "uks", prefix: "sgn"},
"urk": {preferred: "urk", prefix: "ms"},
"uzn": {preferred: "uzn", prefix: "uz"},
"uzs": {preferred: "uzs", prefix: "uz"},
"vgt": {preferred: "vgt", prefix: "sgn"},
"vkk": {preferred: "vkk", prefix: "ms"},
"vkt": {preferred: "vkt", prefix: "ms"},
"vsi": {preferred: "vsi", prefix: "sgn"},
"vsl": {preferred: "vsl", prefix: "sgn"},
"vsv": {preferred: "vsv", prefix: "sgn"},
"wbs": {preferred: "wbs", prefix: "sgn"},
"wuu": {preferred: "wuu", prefix: "zh"},
"xki": {preferred: "xki", prefix: "sgn"},
"xml": {preferred: "xml", prefix: "sgn"},
"xmm": {preferred: "xmm", prefix: "ms"},
"xms": {preferred: "xms", prefix: "sgn"},
"ygs": {preferred: "ygs", prefix: "sgn"},
"yhs": {preferred: "yhs", prefix: "sgn"},
"ysl": {preferred: "ysl", prefix: "sgn"},
"yue": {preferred: "yue", prefix: "zh"},
"zib": {preferred: "zib", prefix: "sgn"},
"zlm": {preferred: "zlm", prefix: "ms"},
"zmi": {preferred: "zmi", prefix: "ms"},
"zsl": {preferred: "zsl", prefix: "sgn"},
"zsm": {preferred: "zsm", prefix: "ms"},
"aao": "ar",
"abh": "ar",
"abv": "ar",
"acm": "ar",
"acq": "ar",
"acw": "ar",
"acx": "ar",
"acy": "ar",
"adf": "ar",
"ads": "sgn",
"aeb": "ar",
"aec": "ar",
"aed": "sgn",
"aen": "sgn",
"afb": "ar",
"afg": "sgn",
"ajp": "ar",
"apc": "ar",
"apd": "ar",
"arb": "ar",
"arq": "ar",
"ars": "ar",
"ary": "ar",
"arz": "ar",
"ase": "sgn",
"asf": "sgn",
"asp": "sgn",
"asq": "sgn",
"asw": "sgn",
"auz": "ar",
"avl": "ar",
"ayh": "ar",
"ayl": "ar",
"ayn": "ar",
"ayp": "ar",
"bbz": "ar",
"bfi": "sgn",
"bfk": "sgn",
"bjn": "ms",
"bog": "sgn",
"bqn": "sgn",
"bqy": "sgn",
"btj": "ms",
"bve": "ms",
"bvl": "sgn",
"bvu": "ms",
"bzs": "sgn",
"cdo": "zh",
"cds": "sgn",
"cjy": "zh",
"cmn": "zh",
"coa": "ms",
"cpx": "zh",
"csc": "sgn",
"csd": "sgn",
"cse": "sgn",
"csf": "sgn",
"csg": "sgn",
"csl": "sgn",
"csn": "sgn",
"csq": "sgn",
"csr": "sgn",
"czh": "zh",
"czo": "zh",
"doq": "sgn",
"dse": "sgn",
"dsl": "sgn",
"dup": "ms",
"ecs": "sgn",
"esl": "sgn",
"esn": "sgn",
"eso": "sgn",
"eth": "sgn",
"fcs": "sgn",
"fse": "sgn",
"fsl": "sgn",
"fss": "sgn",
"gan": "zh",
"gds": "sgn",
"gom": "kok",
"gse": "sgn",
"gsg": "sgn",
"gsm": "sgn",
"gss": "sgn",
"gus": "sgn",
"hab": "sgn",
"haf": "sgn",
"hak": "zh",
"hds": "sgn",
"hji": "ms",
"hks": "sgn",
"hos": "sgn",
"hps": "sgn",
"hsh": "sgn",
"hsl": "sgn",
"hsn": "zh",
"icl": "sgn",
"iks": "sgn",
"ils": "sgn",
"inl": "sgn",
"ins": "sgn",
"ise": "sgn",
"isg": "sgn",
"isr": "sgn",
"jak": "ms",
"jax": "ms",
"jcs": "sgn",
"jhs": "sgn",
"jls": "sgn",
"jos": "sgn",
"jsl": "sgn",
"jus": "sgn",
"kgi": "sgn",
"knn": "kok",
"kvb": "ms",
"kvk": "sgn",
"kvr": "ms",
"kxd": "ms",
"lbs": "sgn",
"lce": "ms",
"lcf": "ms",
"liw": "ms",
"lls": "sgn",
"lsg": "sgn",
"lsl": "sgn",
"lso": "sgn",
"lsp": "sgn",
"lst": "sgn",
"lsy": "sgn",
"ltg": "lv",
"lvs": "lv",
"lzh": "zh",
"max": "ms",
"mdl": "sgn",
"meo": "ms",
"mfa": "ms",
"mfb": "ms",
"mfs": "sgn",
"min": "ms",
"mnp": "zh",
"mqg": "ms",
"mre": "sgn",
"msd": "sgn",
"msi": "ms",
"msr": "sgn",
"mui": "ms",
"mzc": "sgn",
"mzg": "sgn",
"mzy": "sgn",
"nan": "zh",
"nbs": "sgn",
"ncs": "sgn",
"nsi": "sgn",
"nsl": "sgn",
"nsp": "sgn",
"nsr": "sgn",
"nzs": "sgn",
"okl": "sgn",
"orn": "ms",
"ors": "ms",
"pel": "ms",
"pga": "ar",
"pgz": "sgn",
"pks": "sgn",
"prl": "sgn",
"prz": "sgn",
"psc": "sgn",
"psd": "sgn",
"pse": "ms",
"psg": "sgn",
"psl": "sgn",
"pso": "sgn",
"psp": "sgn",
"psr": "sgn",
"pys": "sgn",
"rms": "sgn",
"rsl": "sgn",
"rsm": "sgn",
"sdl": "sgn",
"sfb": "sgn",
"sfs": "sgn",
"sgg": "sgn",
"sgx": "sgn",
"shu": "ar",
"slf": "sgn",
"sls": "sgn",
"sqk": "sgn",
"sqs": "sgn",
"ssh": "ar",
"ssp": "sgn",
"ssr": "sgn",
"svk": "sgn",
"swc": "sw",
"swh": "sw",
"swl": "sgn",
"syy": "sgn",
"szs": "sgn",
"tmw": "ms",
"tse": "sgn",
"tsm": "sgn",
"tsq": "sgn",
"tss": "sgn",
"tsy": "sgn",
"tza": "sgn",
"ugn": "sgn",
"ugy": "sgn",
"ukl": "sgn",
"uks": "sgn",
"urk": "ms",
"uzn": "uz",
"uzs": "uz",
"vgt": "sgn",
"vkk": "ms",
"vkt": "ms",
"vsi": "sgn",
"vsl": "sgn",
"vsv": "sgn",
"wbs": "sgn",
"wuu": "zh",
"xki": "sgn",
"xml": "sgn",
"xmm": "ms",
"xms": "sgn",
"ygs": "sgn",
"yhs": "sgn",
"ysl": "sgn",
"yue": "zh",
"zib": "sgn",
"zlm": "ms",
"zmi": "ms",
"zsl": "sgn",
"zsm": "ms",
};

Просмотреть файл

@ -173,7 +173,10 @@ def writeMappingsVar(intlData, dict, name, description, fileDate, url):
variable name and a comment with description, fileDate, and URL.
"""
intlData.write("\n")
intlData.write("// {0}.\n".format(description))
if type(description) is not list:
description = [description]
for desc in description:
intlData.write("// {0}\n".format(desc))
intlData.write("// Derived from IANA Language Subtag Registry, file date {0}.\n".format(fileDate))
intlData.write("// {0}\n".format(url))
intlData.write("var {0} = {{\n".format(name))
@ -184,7 +187,9 @@ def writeMappingsVar(intlData, dict, name, description, fileDate, url):
else:
preferred = dict[key]["preferred"]
prefix = dict[key]["prefix"]
value = '{{preferred: "{0}", prefix: "{1}"}}'.format(preferred, prefix)
if key != preferred:
raise Exception("Expected '{0}' matches preferred locale '{1}'".format(key, preferred))
value = '"{0}"'.format(prefix)
intlData.write(' "{0}": {1},\n'.format(key, value))
intlData.write("};\n")
@ -192,11 +197,15 @@ def writeMappingsVar(intlData, dict, name, description, fileDate, url):
def writeLanguageTagData(intlData, fileDate, url, langTagMappings, langSubtagMappings, extlangMappings):
""" Writes the language tag data to the Intl data file. """
writeMappingsVar(intlData, langTagMappings, "langTagMappings",
"Mappings from complete tags to preferred values", fileDate, url)
"Mappings from complete tags to preferred values.", fileDate, url)
writeMappingsVar(intlData, langSubtagMappings, "langSubtagMappings",
"Mappings from non-extlang subtags to preferred values", fileDate, url)
"Mappings from non-extlang subtags to preferred values.", fileDate, url)
writeMappingsVar(intlData, extlangMappings, "extlangMappings",
"Mappings from extlang subtags to preferred values", fileDate, url)
["Mappings from extlang subtags to preferred values.",
"All current deprecated extlang subtags have the form `<prefix>-<extlang>`",
"and their preferred value is exactly equal to `<extlang>`. So each key in",
"extlangMappings acts both as the extlang subtag and its preferred value."],
fileDate, url)
def updateLangTags(args):
""" Update the IntlData.js file. """