Skip to content

Commit

Permalink
Merge pull request #3 from helenclx/master
Browse files Browse the repository at this point in the history
extract_translation Script: Add support for finding strings of IDs that require pronoun identifiers
  • Loading branch information
ExcaliburZero authored Nov 11, 2023
2 parents b1aac2d + 14cd99e commit 02da321
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions cbpickaxe_scripts/extract_translation.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,36 @@ def main(argv: List[str]) -> int:
ouput_stream, fieldnames=["id", *sorted(set(locales.values()))]
)
writer.writeheader()

for i in strings_to_translate:
row = {
"id": i,
}

def find_string(id):
for name, table in tables.items():
locale = locales[name]
message = table.get(i, "")
message = table.get(id, "")
assert isinstance(message, str)

if message != "":
row[locale] = message

writer.writerow(row)
for i in strings_to_translate:
row = {
"id": i,
}

find_string(i)

if len(row.keys()) == 1:
pronouns = [".f", ".m", ".n"]
ids_with_pronouns = []

for pronoun in pronouns:
ids_with_pronouns.append(i + pronoun)

for id_with_pronoun in ids_with_pronouns:
row["id"] = id_with_pronoun
find_string(id_with_pronoun)
writer.writerow(row)
else:
writer.writerow(row)

return SUCCESS

Expand Down

0 comments on commit 02da321

Please sign in to comment.