Skip to content

Commit

Permalink
Merge pull request #5791 from freedomofpress/reduce-lm-review
Browse files Browse the repository at this point in the history
Reduce localization manager review noise
  • Loading branch information
emkll authored Feb 18, 2021
2 parents 131f8f9 + cceb323 commit b56c6b0
Show file tree
Hide file tree
Showing 24 changed files with 4,220 additions and 20,693 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,26 @@ Type=Application
Terminal=false
StartupNotify=true
Categories=Network;
Name[nb_NO]=Journalistgrensesnitt for SecureDrop
Name[sk]=SecureDrop rozhranie novinára
Name[zh_Hans]=SecureDrop 记者界面
Name[nl]=SecureDrop - interface voor journalisten
Name[de_DE]=Journalistenschnittstelle für SecureDrop
Name[tr]=SecureDrop Gazeteci Arayüzü
Name[sv]=SecureDrop journalistgränssnitt
Name[ru]=Интерфейс для журналистов SecureDrop
Name[pt_BR]=Interface de Jornalista do SecureDrop
Name[zh_Hant]=SecureDrop 記者使用介面
Name[is]=Blaðamannaviðmót SecureDrop
Name[hi]=SecureDrop पत्रकार अंतराफलक
Icon={{ tails_config_securedrop_dotfiles }}/securedrop_icon.png
Exec=/usr/local/bin/tor-browser {{ item.0.onion_url }}
Name=SecureDrop Journalist Interface
Name[ar]=واجهة SecureDrop للصحفيين
Name[fr]=SecureDrop - Interface des journalistes
Name[ca]=Interfície de periodista del SecureDrop
Name[cs]=SecureDrop rozhraní novináře
Name[de_DE]=Journalistenschnittstelle für SecureDrop
Name[el]=Διεπαφή δημοσιογράφου του SecureDrop
Name[es_ES]=Interfaz de periodista de SecureDrop
Name[fr]=SecureDrop - Interface des journalistes
Name[hi]=SecureDrop पत्रकार अंतराफलक
Name[is]=Blaðamannaviðmót SecureDrop
Name[it]=Interfaccia Giornalista di SecureDrop
Name[nb_NO]=Journalistgrensesnitt for SecureDrop
Name[nl]=SecureDrop - interface voor journalisten
Name[pt_BR]=Interface de Jornalista do SecureDrop
Name[ro]=SecureDrop - interfața pentru jurnaliști
Name[el]=Διεπαφή δημοσιογράφου του SecureDrop
Name[ca]=Interfície de periodista del SecureDrop
Name[cs]=SecureDrop rozhraní novináře
Name=SecureDrop Journalist Interface
Icon={{ tails_config_securedrop_dotfiles }}/securedrop_icon.png
Exec=/usr/local/bin/tor-browser {{ item.0.onion_url }}
Name[ru]=Интерфейс для журналистов SecureDrop
Name[sk]=SecureDrop rozhranie novinára
Name[sv]=SecureDrop journalistgränssnitt
Name[tr]=SecureDrop Gazeteci Arayüzü
Name[zh_Hans]=SecureDrop 记者界面
Name[zh_Hant]=SecureDrop 記者使用介面
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,26 @@ Type=Application
Terminal=false
StartupNotify=true
Categories=Network;
Name[nb_NO]=Kildegrensesnitt for SecureDrop
Name[sk]=SecureDrop rozhranie zdroja
Name[zh_Hans]=SecureDrop 线人界面
Name[nl]=Securedrop - interface voor bronnen
Name[de_DE]=Quellenschnittstelle für SecureDrop
Name[tr]=SecureDrop Kaynak Arayüzü
Name[sv]=SecureDrop källgränssnitt
Name[ru]=Интерфейс для источников SecureDrop
Name[pt_BR]=Interface de Fontes do SecureDrop
Name[zh_Hant]=SecureDrop 線人使用介面
Name[is]=Heimildarmannaviðmót SecureDrop
Name[hi]=SecureDrop स्रोत अंतराफलक
Icon={{ tails_config_securedrop_dotfiles }}/securedrop_icon.png
Exec=/usr/local/bin/tor-browser {{ item.0.onion_url }}
Name=SecureDrop Source Interface
Name[ar]=واجهة SecureDrop للمصدر
Name[fr]=SecureDrop - Interface des sources
Name[ca]=Interfície de font del SecureDrop
Name[cs]=SecureDrop rozhraní zdroje
Name[de_DE]=Quellenschnittstelle für SecureDrop
Name[el]=Διεπαφή πηγής του SecureDrop
Name[es_ES]=Interfaz de fuente de SecureDrop
Name[fr]=SecureDrop - Interface des sources
Name[hi]=SecureDrop स्रोत अंतराफलक
Name[is]=Heimildarmannaviðmót SecureDrop
Name[it]=Interfaccia Fonte di SecureDrop
Name[nb_NO]=Kildegrensesnitt for SecureDrop
Name[nl]=Securedrop - interface voor bronnen
Name[pt_BR]=Interface de Fontes do SecureDrop
Name[ro]=SecureDrop - interfața pentru surse
Name[el]=Διεπαφή πηγής του SecureDrop
Name[ca]=Interfície de font del SecureDrop
Name[cs]=SecureDrop rozhraní zdroje
Name=SecureDrop Source Interface
Icon={{ tails_config_securedrop_dotfiles }}/securedrop_icon.png
Exec=/usr/local/bin/tor-browser {{ item.0.onion_url }}
Name[ru]=Интерфейс для источников SecureDrop
Name[sk]=SecureDrop rozhranie zdroja
Name[sv]=SecureDrop källgränssnitt
Name[tr]=SecureDrop Kaynak Arayüzü
Name[zh_Hans]=SecureDrop 线人界面
Name[zh_Hant]=SecureDrop 線人使用介面
51 changes: 40 additions & 11 deletions securedrop/i18n_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,25 @@ def translate_messages(self, args: argparse.Namespace) -> None:
'--version', args.version,
"--msgid-bugs-address=securedrop@freedom.press",
"--copyright-holder=Freedom of the Press Foundation",
"--add-comments=Translators:",
"--strip-comments",
"--add-location=never",
"--no-wrap",
*sources)

sed('-i', '-e', '/^"POT-Creation-Date/d', messages_file)

if (self.file_is_modified(messages_file) and
len(os.listdir(args.translations_dir)) > 1):
tglob = '{}/*/LC_MESSAGES/*.po'.format(args.translations_dir)
for translation in glob.iglob(tglob):
msgmerge('--previous', '--update', translation,
messages_file)
msgmerge(
'--previous',
'--update',
'--no-wrap',
translation,
messages_file
)
log.warning("messages translations updated in {}".format(
messages_file))
else:
Expand Down Expand Up @@ -141,15 +151,34 @@ def translate_desktop(self, args: argparse.Namespace) -> None:
pos = [f for f in os.listdir(args.translations_dir) if f.endswith('.po')]
linguas = [l[:-3] for l in pos]
content = "\n".join(linguas) + "\n"
open(join(args.translations_dir, 'LINGUAS'), 'w').write(content)

for source in args.sources.split(','):
target = source.rstrip('.in')
msgfmt('--desktop',
'--template', source,
'-o', target,
'-d', '.',
_cwd=args.translations_dir)
linguas_file = join(args.translations_dir, 'LINGUAS')
try:
open(linguas_file, 'w').write(content)

for source in args.sources.split(','):
target = source.rstrip('.in')
msgfmt('--desktop',
'--template', source,
'-o', target,
'-d', '.',
_cwd=args.translations_dir)
self.sort_desktop_template(join(args.translations_dir, target))
finally:
if os.path.exists(linguas_file):
os.unlink(linguas_file)

def sort_desktop_template(self, template: str) -> None:
"""
Sorts the lines containing the icon names.
"""
lines = open(template).readlines()
names = sorted(l for l in lines if l.startswith("Name"))
others = (l for l in lines if not l.startswith("Name"))
with open(template, "w") as new_template:
for line in others:
new_template.write(line)
for line in names:
new_template.write(line)

def set_translate_parser(self,
parser: argparse.ArgumentParser,
Expand Down
Loading

0 comments on commit b56c6b0

Please sign in to comment.