mirror of
https://github.com/dialect-app/po.git
synced 2025-06-19 12:46:24 +00:00
Update lang_update to support parameters
- Pass "-g" or "--google" to force use google as the source. - Pass a language code (basically the name in LINGUAS) to only update that particular language file.
This commit is contained in:
parent
1b9bd56883
commit
1519f1746a
1 changed files with 18 additions and 3 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
import argparse
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
@ -137,12 +138,18 @@ DIALECT_NAMES = {
|
||||||
EXCLUDE_LIST = []
|
EXCLUDE_LIST = []
|
||||||
|
|
||||||
|
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument("language", nargs="?", help="the language code for language to update")
|
||||||
|
parser.add_argument("-g", "--google", help="force use google for language names",
|
||||||
|
action="store_true")
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
if not os.path.isdir("cldr-json"):
|
if not os.path.isdir("cldr-json"):
|
||||||
print("Cloning Unicode CLDR repository...")
|
print("Cloning Unicode CLDR repository...")
|
||||||
subprocess.call(["git", "clone", "https://github.com/unicode-org/cldr-json"])
|
subprocess.call(["git", "clone", "https://github.com/unicode-org/cldr-json"])
|
||||||
|
|
||||||
linguas_file = open("../LINGUAS", "r")
|
|
||||||
for lang in linguas_file:
|
def process_language(lang):
|
||||||
lang = lang.strip()
|
lang = lang.strip()
|
||||||
if lang and lang not in EXCLUDE_LIST:
|
if lang and lang not in EXCLUDE_LIST:
|
||||||
cldr_present = True # Assume CLDR file is present.
|
cldr_present = True # Assume CLDR file is present.
|
||||||
|
@ -177,7 +184,7 @@ for lang in linguas_file:
|
||||||
print("Could not find possible substitutes.")
|
print("Could not find possible substitutes.")
|
||||||
cldr_present = False # Correct earlier assumption.
|
cldr_present = False # Correct earlier assumption.
|
||||||
|
|
||||||
if cldr_present:
|
if cldr_present or args.google:
|
||||||
cldr_langs = cldr_json["main"][cldr_lang]["localeDisplayNames"]["languages"]
|
cldr_langs = cldr_json["main"][cldr_lang]["localeDisplayNames"]["languages"]
|
||||||
for lang_code, lang_name in cldr_langs.items():
|
for lang_code, lang_name in cldr_langs.items():
|
||||||
if lang_code in DIALECT_NAMES:
|
if lang_code in DIALECT_NAMES:
|
||||||
|
@ -217,3 +224,11 @@ for lang in linguas_file:
|
||||||
lang_file.close()
|
lang_file.close()
|
||||||
|
|
||||||
print()
|
print()
|
||||||
|
|
||||||
|
|
||||||
|
if args.language:
|
||||||
|
process_language(args.language)
|
||||||
|
else:
|
||||||
|
linguas_file = open("../LINGUAS", "r")
|
||||||
|
for lang in linguas_file:
|
||||||
|
process_language(lang)
|
||||||
|
|
Loading…
Add table
Reference in a new issue