mirror of
https://gh.llkk.cc/https://github.com/WeblateOrg/language-data.git
synced 2025-10-04 15:12:29 +08:00
Remove CLDR native support
It never really worked well due to bugs in Babel to_gettext. Signed-off-by: Michal Čihař <michal@cihar.com>
This commit is contained in:
parent
007ddf01ea
commit
9dee0fa69f
1 changed files with 0 additions and 40 deletions
|
@ -1,40 +0,0 @@
|
|||
#! /usr/bin/env python3
|
||||
|
||||
# Attempt for native Python CLDR to gettext conversion
|
||||
# This is still incomplete and not used
|
||||
|
||||
from xml.etree import ElementTree
|
||||
from babel.plural import to_gettext
|
||||
|
||||
# Parse language names
|
||||
names = {}
|
||||
tree = ElementTree.parse("cldr-core/common/main/en.xml")
|
||||
for item in tree.iter("language"):
|
||||
names[item.get("type")] = item.text
|
||||
|
||||
# Parse language aliases
|
||||
tree = ElementTree.parse("cldr-core/common/supplemental/supplementalMetadata.xml")
|
||||
for item in tree.iter("languageAlias"):
|
||||
if item.get("reason") == "macrolanguage" and item.get("replacement") in names:
|
||||
names[item.get("type")] = names[item.get("replacement")]
|
||||
|
||||
# Parse plurals
|
||||
result = {}
|
||||
tree = ElementTree.parse("cldr-core/common/supplemental/plurals.xml")
|
||||
for item in tree.iter("pluralRules"):
|
||||
locales = item.get("locales").split()
|
||||
rules = [(x.get("count"), x.text.split("@")[0]) for x in item.iter("pluralRule")]
|
||||
formula = to_gettext(rules)
|
||||
nplurals = int(formula.split(";", 1)[0].split("=", 1)[1])
|
||||
equation = formula.split(";", 1)[1].split("=", 1)[1][1:-1]
|
||||
for locale in locales:
|
||||
result[locale] = (nplurals, equation)
|
||||
|
||||
with open("cldr.csv", "w") as handle:
|
||||
for code in sorted(result):
|
||||
if code not in names:
|
||||
print("MISSING {}".format(code))
|
||||
continue
|
||||
handle.write(
|
||||
"{};{};{};{}\n".format(code, names[code], result[code][0], result[code][1])
|
||||
)
|
Loading…
Add table
Add a link
Reference in a new issue