diff options
| author | Scott Shawcroft <scott@tannewt.org> | 2019-02-22 15:28:29 -0800 |
|---|---|---|
| committer | Scott Shawcroft <scott@tannewt.org> | 2019-02-22 15:28:29 -0800 |
| commit | 785edf719eb80d6af7b6a682fde57b5edc1e7a3b (patch) | |
| tree | e69d809ce8978f040dc0d1187f8f3374e44f5892 /tools/fixup_translations.py | |
| parent | 8cfc4ed9ca16c8b5faa3901385a8d9dbaaa03c19 (diff) | |
Update translations based on git history
Diffstat (limited to 'tools/fixup_translations.py')
| -rw-r--r-- | tools/fixup_translations.py | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/tools/fixup_translations.py b/tools/fixup_translations.py index c20ace55b..6db7f1cc5 100644 --- a/tools/fixup_translations.py +++ b/tools/fixup_translations.py @@ -33,20 +33,47 @@ for po_filename in po_filenames: continue print(commit.authored_date, commit) first_translations.metadata = current_file.metadata + first_translations.header = current_file.header for entry in first_translations: - if entry.msgid == "soft reboot\n": - continue newer_entry = current_file.find(entry.msgid) - if newer_entry and entry.msgstr != newer_entry.msgstr: + + if newer_entry and entry.msgid == "": + entry.merge(newer_entry) + print(entry) + elif newer_entry and entry.msgstr != newer_entry.msgstr: if newer_entry.msgstr != "" and (newer_entry.msgstr != entry.msgid or entry.msgid in NO_TRANSLATION_WHITELIST): entry.merge(newer_entry) entry.msgstr = newer_entry.msgstr + if "fuzzy" not in newer_entry.flags and "fuzzy" in entry.flags: + entry.flags.remove("fuzzy") elif entry.msgid not in fixed_ids: if commit not in bad_commits: bad_commits[commit] = set() bad_commits[commit].add(po_filename) fixed_ids.add(entry.msgid) - print(entry.msgid, "\"" + entry.msgstr + "\"", "\"" + newer_entry.msgstr + "\"") + #print(entry.msgid, "\"" + entry.msgstr + "\"", "\"" + newer_entry.msgstr + "\"",) + elif newer_entry and newer_entry.flags != entry.flags: + entry.flags = newer_entry.flags + elif newer_entry and newer_entry.obsolete != entry.obsolete: + entry.obsolete = newer_entry.obsolete + elif not newer_entry: + entry.obsolete = True + + # Add new entries to the modified pofile. + for entry in current_file: + old_entry = first_translations.find(entry.msgid, include_obsolete_entries=True) + if old_entry: + continue + first_translations.append(entry) + + # Remove obsolete translations. We can always use this script to revive them from the git history. + to_remove = [] + for entry in first_translations: + if entry.obsolete: + to_remove.append(entry) + + for remove in to_remove: + first_translations.remove(remove) first_translations.save(po_filename) |
