cldr: Include decimal tags in export

This will be needed to implement support for recent Android extensions,
see https://github.com/WeblateOrg/weblate/issues/7520
This commit is contained in:
Michal Čihař 2022-07-19 11:22:32 +02:00
parent 79de2af279
commit 287fdaf634
2 changed files with 222 additions and 2 deletions

View file

@ -66,23 +66,25 @@ https://github.com/WeblateOrg/language-data
'''

result = {}
decimals = {}

with open(BASE) as handle:
data = json.load(handle)

for locale, rules in data["supplemental"]["plurals-type-cardinal"].items():
print(locale, rules)
result[locale] = [
name.replace("pluralRule-count-", "")
for name, rule in rules.items()
if "@integer" in rule
]
decimals[locale] = [name.replace("pluralRule-count-", "") for name in rules]


# Write plural tags
with open("weblate_language_data/plural_tags.py", "w") as output:
output.write(HEADER)
output.write(f"PLURAL_TAGS = {pprint.pformat(result)}")
output.write(f"PLURAL_TAGS = {pprint.pformat(result)}\n\n")
output.write(f"DECIMAL_PLURAL_TAGS = {pprint.pformat(decimals)}\n")

# Apply coding style
subprocess.run(

View file

@ -249,3 +249,221 @@ PLURAL_TAGS = {
"zh": ["other"],
"zu": ["one", "other"],
}

DECIMAL_PLURAL_TAGS = {
"af": ["one", "other"],
"ak": ["one", "other"],
"am": ["one", "other"],
"an": ["one", "other"],
"ar": ["zero", "one", "two", "few", "many", "other"],
"ars": ["zero", "one", "two", "few", "many", "other"],
"as": ["one", "other"],
"asa": ["one", "other"],
"ast": ["one", "other"],
"az": ["one", "other"],
"bal": ["one", "other"],
"be": ["one", "few", "many", "other"],
"bem": ["one", "other"],
"bez": ["one", "other"],
"bg": ["one", "other"],
"bho": ["one", "other"],
"bm": ["other"],
"bn": ["one", "other"],
"bo": ["other"],
"br": ["one", "two", "few", "many", "other"],
"brx": ["one", "other"],
"bs": ["one", "few", "other"],
"ca": ["one", "other"],
"ce": ["one", "other"],
"ceb": ["one", "other"],
"cgg": ["one", "other"],
"chr": ["one", "other"],
"ckb": ["one", "other"],
"cs": ["one", "few", "many", "other"],
"cy": ["zero", "one", "two", "few", "many", "other"],
"da": ["one", "other"],
"de": ["one", "other"],
"doi": ["one", "other"],
"dsb": ["one", "two", "few", "other"],
"dv": ["one", "other"],
"dz": ["other"],
"ee": ["one", "other"],
"el": ["one", "other"],
"en": ["one", "other"],
"eo": ["one", "other"],
"es": ["one", "many", "other"],
"et": ["one", "other"],
"eu": ["one", "other"],
"fa": ["one", "other"],
"ff": ["one", "other"],
"fi": ["one", "other"],
"fil": ["one", "other"],
"fo": ["one", "other"],
"fr": ["one", "many", "other"],
"fur": ["one", "other"],
"fy": ["one", "other"],
"ga": ["one", "two", "few", "many", "other"],
"gd": ["one", "two", "few", "other"],
"gl": ["one", "other"],
"gsw": ["one", "other"],
"gu": ["one", "other"],
"guw": ["one", "other"],
"gv": ["one", "two", "few", "many", "other"],
"ha": ["one", "other"],
"haw": ["one", "other"],
"he": ["one", "two", "many", "other"],
"hi": ["one", "other"],
"hnj": ["other"],
"hr": ["one", "few", "other"],
"hsb": ["one", "two", "few", "other"],
"hu": ["one", "other"],
"hy": ["one", "other"],
"ia": ["one", "other"],
"id": ["other"],
"ig": ["other"],
"ii": ["other"],
"io": ["one", "other"],
"is": ["one", "other"],
"it": ["one", "many", "other"],
"iu": ["one", "two", "other"],
"ja": ["other"],
"jbo": ["other"],
"jgo": ["one", "other"],
"jmc": ["one", "other"],
"jv": ["other"],
"jw": ["other"],
"ka": ["one", "other"],
"kab": ["one", "other"],
"kaj": ["one", "other"],
"kcg": ["one", "other"],
"kde": ["other"],
"kea": ["other"],
"kk": ["one", "other"],
"kkj": ["one", "other"],
"kl": ["one", "other"],
"km": ["other"],
"kn": ["one", "other"],
"ko": ["other"],
"ks": ["one", "other"],
"ksb": ["one", "other"],
"ksh": ["zero", "one", "other"],
"ku": ["one", "other"],
"kw": ["zero", "one", "two", "few", "many", "other"],
"ky": ["one", "other"],
"lag": ["zero", "one", "other"],
"lb": ["one", "other"],
"lg": ["one", "other"],
"lij": ["one", "other"],
"lkt": ["other"],
"ln": ["one", "other"],
"lo": ["other"],
"lt": ["one", "few", "many", "other"],
"lv": ["zero", "one", "other"],
"mas": ["one", "other"],
"mg": ["one", "other"],
"mgo": ["one", "other"],
"mk": ["one", "other"],
"ml": ["one", "other"],
"mn": ["one", "other"],
"mo": ["one", "few", "other"],
"mr": ["one", "other"],
"ms": ["other"],
"mt": ["one", "few", "many", "other"],
"my": ["other"],
"nah": ["one", "other"],
"naq": ["one", "two", "other"],
"nb": ["one", "other"],
"nd": ["one", "other"],
"ne": ["one", "other"],
"nl": ["one", "other"],
"nn": ["one", "other"],
"nnh": ["one", "other"],
"no": ["one", "other"],
"nqo": ["other"],
"nr": ["one", "other"],
"nso": ["one", "other"],
"ny": ["one", "other"],
"nyn": ["one", "other"],
"om": ["one", "other"],
"or": ["one", "other"],
"os": ["one", "other"],
"osa": ["other"],
"pa": ["one", "other"],
"pap": ["one", "other"],
"pcm": ["one", "other"],
"pl": ["one", "few", "many", "other"],
"prg": ["zero", "one", "other"],
"ps": ["one", "other"],
"pt": ["one", "many", "other"],
"pt-PT": ["one", "many", "other"],
"rm": ["one", "other"],
"ro": ["one", "few", "other"],
"rof": ["one", "other"],
"ru": ["one", "few", "many", "other"],
"rwk": ["one", "other"],
"sah": ["other"],
"saq": ["one", "other"],
"sat": ["one", "two", "other"],
"sc": ["one", "other"],
"scn": ["one", "other"],
"sd": ["one", "other"],
"sdh": ["one", "other"],
"se": ["one", "two", "other"],
"seh": ["one", "other"],
"ses": ["other"],
"sg": ["other"],
"sh": ["one", "few", "other"],
"shi": ["one", "few", "other"],
"si": ["one", "other"],
"sk": ["one", "few", "many", "other"],
"sl": ["one", "two", "few", "other"],
"sma": ["one", "two", "other"],
"smi": ["one", "two", "other"],
"smj": ["one", "two", "other"],
"smn": ["one", "two", "other"],
"sms": ["one", "two", "other"],
"sn": ["one", "other"],
"so": ["one", "other"],
"sq": ["one", "other"],
"sr": ["one", "few", "other"],
"ss": ["one", "other"],
"ssy": ["one", "other"],
"st": ["one", "other"],
"su": ["other"],
"sv": ["one", "other"],
"sw": ["one", "other"],
"syr": ["one", "other"],
"ta": ["one", "other"],
"te": ["one", "other"],
"teo": ["one", "other"],
"th": ["other"],
"ti": ["one", "other"],
"tig": ["one", "other"],
"tk": ["one", "other"],
"tl": ["one", "other"],
"tn": ["one", "other"],
"to": ["other"],
"tpi": ["other"],
"tr": ["one", "other"],
"ts": ["one", "other"],
"tzm": ["one", "other"],
"ug": ["one", "other"],
"uk": ["one", "few", "many", "other"],
"und": ["other"],
"ur": ["one", "other"],
"uz": ["one", "other"],
"ve": ["one", "other"],
"vi": ["other"],
"vo": ["one", "other"],
"vun": ["one", "other"],
"wa": ["one", "other"],
"wae": ["one", "other"],
"wo": ["other"],
"xh": ["one", "other"],
"xog": ["one", "other"],
"yi": ["one", "other"],
"yo": ["other"],
"yue": ["other"],
"zh": ["other"],
"zu": ["one", "other"],
}