mirror of
https://gh.llkk.cc/https://github.com/WeblateOrg/language-data.git
synced 2025-10-04 15:12:29 +08:00
31 lines
837 B
Python
Executable file
31 lines
837 B
Python
Executable file
#! /usr/bin/env python3
|
|
|
|
# Export Gettext builtin plurals
|
|
|
|
import re
|
|
|
|
MATCH = re.compile(r"\s*([^,]+),\s*([^,#]+)( \[#f[0-9]*\]_)?,\s*(nplurals.*)\s*")
|
|
|
|
with open("modules/l10n-guide/docs/l10n/pluralforms.rst") as handle:
|
|
content = handle.read()
|
|
|
|
output = []
|
|
state = 0
|
|
for line in content.splitlines():
|
|
if "csv-table" in line:
|
|
state = 1
|
|
continue
|
|
if state == 1:
|
|
matches = MATCH.match(line)
|
|
if matches:
|
|
output.append(
|
|
"{};{};{};{}\n".format(
|
|
matches[1],
|
|
matches[2],
|
|
int(matches[4].split(";", 1)[0].split("=")[1]),
|
|
matches[4].split(";", 1)[1].split("=", 1)[1].rstrip(";"),
|
|
)
|
|
)
|
|
|
|
with open("l10n-guide.csv", "w") as handle:
|
|
handle.writelines(sorted(output))
|