Skip to content

Commit

Permalink
Fix handling of strings with context in scripts/convert_l10n.py
Browse files Browse the repository at this point in the history
  • Loading branch information
heinrich5991 committed Dec 21, 2019
1 parent cbb5776 commit a461407
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions scripts/convert_l10n.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
JSON_KEY_TRANSL="translated strings"
JSON_KEY_UNTRANSL="needs translation"
JSON_KEY_OLDTRANSL="old translations"
JSON_KEY_CTXT="context"
JSON_KEY_OR="or"
JSON_KEY_TR="tr"

Expand Down Expand Up @@ -75,8 +76,10 @@ def write_languagefile(outputfilename, l10n_src, old_l10n_data):
JSON_KEY_UNTRANSL,
JSON_KEY_TRANSL,
):
if type_ not in old_l10n_data:
continue
translations.update({
t[JSON_KEY_OR]: t[JSON_KEY_TR]
(t[JSON_KEY_OR], t.get(JSON_KEY_CTXT)): t[JSON_KEY_TR]
for t in old_l10n_data[type_]
if t[JSON_KEY_TR]
})
Expand All @@ -86,10 +89,11 @@ def write_languagefile(outputfilename, l10n_src, old_l10n_data):
old_items = set(translations) - set(l10n_src)
new_items = set(l10n_src) - set(translations)

for msg in all_items:
for msg, ctxt in all_items:
po.append(polib.POEntry(
msgid=msg,
msgstr=translations.get(msg, ""),
msgctxt=ctxt,
msgstr=translations.get((msg, ctxt), ""),
obsolete=(msg in old_items),
occurrences=l10n_src[msg],
))
Expand Down

0 comments on commit a461407

Please sign in to comment.