Skip to content

Commit

Permalink
Update all translations to remove particles and fix capitalization
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewtavis committed Nov 10, 2024
1 parent cafea75 commit 07af00f
Show file tree
Hide file tree
Showing 9 changed files with 2,673,330 additions and 2,673,323 deletions.
40 changes: 37 additions & 3 deletions fix_translations.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

sub_folders = [f.path for f in os.scandir("scribe_data_json_export") if f.is_dir()]
sub_translation_files = [f"{f}/translations.json" for f in sub_folders]

german_noun_file = "scribe_data_json_export/German/nouns.json"

with Path(german_noun_file).open("r", encoding="utf-8") as file:
Expand All @@ -24,6 +25,18 @@
if "nominativePlural" in n.keys():
german_nouns.append(n["nominativePlural"])

german_proper_noun_file = "scribe_data_json_export/German/proper_nouns.json"

with Path(german_proper_noun_file).open("r", encoding="utf-8") as file:
german_proper_nouns_dict = json.load(file)

german_proper_nouns = []
for n in german_proper_nouns_dict:
german_proper_nouns.append(n["nominativeSingular"])

if "nominativePlural" in n.keys():
german_proper_nouns.append(n["nominativePlural"])

german_nouns = list(set(german_nouns))

for t in sub_translation_files:
Expand All @@ -38,20 +51,41 @@
unit="translations",
):
new_translations = {}
if k[0].islower():
if t.split("/")[1] == "German":
for sub_key in translations_dict[k].keys():
if k in german_nouns and k in german_proper_nouns:
new_translations[sub_key] = translations_dict[k][sub_key]

else:
new_translations[sub_key] = translations_dict[k][sub_key].lower()

elif k[0].islower():
for sub_key in translations_dict[k].keys():
if (
sub_key == "de"
and translations_dict[k][sub_key] not in german_nouns
):
new_translations[sub_key] = translations_dict[k][sub_key].lower()

else:
elif sub_key == "de":
new_translations[sub_key] = translations_dict[k][sub_key]

else:
new_translations[sub_key] = translations_dict[k][sub_key].lower()

else:
for sub_key in translations_dict[k].keys():
new_translations[sub_key] = translations_dict[k][sub_key]
if sub_key == "de" and translations_dict[k][sub_key] in german_nouns:
if translations_dict[k][sub_key] in german_proper_nouns:
new_translations[sub_key] = translations_dict[k][sub_key]

else:
new_translations[sub_key] = translations_dict[k][
sub_key
].lower()

else:
new_translations[sub_key] = translations_dict[k][sub_key]

new_translations_dict[k] = new_translations

Expand Down
Loading

0 comments on commit 07af00f

Please sign in to comment.