Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

provides tooling for interactive localization updates #1348

Merged
merged 9 commits into from
Dec 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ common-steps:
command: |
set -e
source .venv/bin/activate
make check-black check-isort lint bandit
make check-black check-isort lint bandit check-strings

- &check_python_dependencies_for_vulns
run:
Expand Down
4 changes: 4 additions & 0 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
TOP=`git rev-parse --show-toplevel`

make -C "$TOP" check-strings
36 changes: 0 additions & 36 deletions .github/workflows/l10n.yml

This file was deleted.

3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ coverage.xml
.pytest_cache/

# Translations
*.mo
*.po-e
*.pot-e

# Django stuff:
*.log
Expand Down
60 changes: 16 additions & 44 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
all: help

.PHONY: venv-debian
venv-debian: ## Provision a Python 3 virtualenv for development on a prod-like system that has installed dependencies specified in https://github.com/freedomofpress/securedrop-debian-packaging/blob/main/securedrop-client/debian/control
venv-debian: hooks ## Provision a Python 3 virtualenv for development on a prod-like system that has installed dependencies specified in https://github.com/freedomofpress/securedrop-debian-packaging/blob/main/securedrop-client/debian/control
python3 -m venv .venv-debian --system-site-packages
.venv-debian/bin/pip install --upgrade pip wheel
.venv-debian/bin/pip install --require-hashes -r "requirements/dev-requirements-debian.txt"
Expand All @@ -12,21 +12,27 @@ venv-debian: ## Provision a Python 3 virtualenv for development on a prod-like s
@echo "Then run: source .venv-debian/bin/activate"

.PHONY: venv
venv: ## Provision a Python 3 virtualenv for development on Linux
venv: hooks ## Provision a Python 3 virtualenv for development on Linux
python3 -m venv .venv
.venv/bin/pip install --upgrade pip wheel
.venv/bin/pip install --require-hashes -r "requirements/dev-requirements.txt"
@echo "#################"
@echo "Make sure to run: source .venv/bin/activate"

.PHONY: venv-mac
venv-mac: ## Provision a Python 3 virtualenv for development on macOS
venv-mac: hooks ## Provision a Python 3 virtualenv for development on macOS
python3 -m venv .venv
.venv/bin/pip install --upgrade pip wheel
.venv/bin/pip install --require-hashes -r "requirements/dev-mac-requirements.txt"
@echo "#################"
@echo "Make sure to run: source .venv/bin/activate"

HOOKS_DIR=.githooks

.PHONY: hooks
hooks: ## Configure Git to use the hooks provided by this repository.
git config core.hooksPath "$(HOOKS_DIR)"

SEMGREP_FLAGS := --exclude "tests/" --error --strict --verbose

.PHONY: semgrep
Expand Down Expand Up @@ -187,26 +193,20 @@ version:
##############

LOCALE_DIR=securedrop_client/locale
LOCALES=$(shell find ${LOCALE_DIR} -name "*.po")
POT=${LOCALE_DIR}/messages.pot
SUPPORTED_LOCALES_LIST=l10n.txt
VERSION=$(shell python -c "import securedrop_client; print(securedrop_client.__version__)")
WEBLATE_API=https://weblate.securedrop.org/api/
WEBLATE_COMPONENT=securedrop-client

# Update POTs from translated strings in source code and merge into
# per-locale POs.
.PHONY: update-translation-catalogs
update-translation-catalogs:
@make --always-make ${POT}
@git add --verbose ${POT}
@for catalog in $$(find ${LOCALE_DIR} -name "*.po"); do make $${catalog}; git add --verbose $${catalog}; done
-git commit --message "l10n: update translation catalogs"
.PHONY: check-strings
check-strings: ## Check that the translation catalog is up to date with source code
@make extract-strings
@git diff --quiet ${LOCALE_DIR} || { echo "Translation catalog is out of date. Please run \"make extract-strings\" and commit the changes."; exit 1; }

# Compile loadable/packageable MOs.
.PHONY: compile-translation-catalogs
compile-translation-catalogs: ${LOCALE_DIR}/*/LC_MESSAGES/messages.mo
@for locale in $^; do make $${locale}; done
.PHONY: extract-strings
extract-strings: ## Extract translatable strings from source code
@make --always-make ${POT}

# Derive POT from sources.
$(POT): securedrop_client
Expand All @@ -226,34 +226,6 @@ $(POT): securedrop_client
$^
@sed -i -e '/^"POT-Creation-Date/d' ${POT}

# Merge current POT with a locale's PO.
#
# NB. freedomofpress/securedrop/securedrop/i18n_tool.py updates via
# msgmerge even though pybabel.update() is available. Here we use
# "pybabel update" for consistency with "pybabel extract".
${LOCALE_DIR}/%/LC_MESSAGES/messages.po: ${POT}
ifeq ($(strip $(LOCALES)),)
@echo "no translation catalogs to update"
else
@pybabel update \
--locale $$(echo $@ | grep -Eio "[a-zA-Z_]+/LC_MESSAGES/messages.po" | sed 's/\/LC_MESSAGES\/messages.po//') \
--input-file ${POT} \
--output-file $@ \
--no-wrap \
--previous
@sed -i -e '/^"POT-Creation-Date/d' $@
endif

# Compile a locale's PO to MO for (a) development runtime or (b) packaging.
${LOCALE_DIR}/%/LC_MESSAGES/messages.mo: ${LOCALE_DIR}/%/LC_MESSAGES/messages.po
ifeq ($(strip $(LOCALES)),)
@echo "no translation catalogs to compile"
else
@pybabel compile \
--directory ${LOCALE_DIR} \
--statistics
endif

# List languages 100% translated in Weblate.
.PHONY: supported-languages
supported-languages:
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ make venv
source .venv/bin/activate
```

* `make venv` will also run `make hooks`, which will configure Git to use the hooks found in `.githooks/` to check certain code-quality standards on new commits in this repository. These checks are also enforced in CI.

4. Run SecureDrop Client

```
Expand Down Expand Up @@ -104,6 +106,8 @@ make venv
source .venv/bin/activate
```

* `make venv` will also run `make hooks`, which will configure Git to use the hooks found in `.githooks/` to check certain code-quality standards on new commits in this repository. These checks are also enforced in CI.

4. Run SecureDrop Client

```
Expand Down Expand Up @@ -151,6 +155,8 @@ It is possible to run the development environment in macOS on non-Apple Silicon
make venv-mac
source .venv/bin/activate
```
* `make venv-mac` will also run `make hooks`, which will configure Git to use the hooks found in `.githooks/` to check certain code-quality standards on new commits in this repository. These checks are also enforced in CI.

7. Run SecureDrop Client
```
./run.sh
Expand Down
Binary file not shown.
116 changes: 55 additions & 61 deletions securedrop_client/locale/ca/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Translations template for SecureDrop Client.
# Catalan translations for SecureDrop Client.
# Copyright (C) 2021 Freedom of the Press Foundation
# This file is distributed under the same license as the SecureDrop Client project.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2021.
Expand All @@ -9,14 +9,12 @@ msgstr ""
"Report-Msgid-Bugs-To: securedrop@freedom.press\n"
"PO-Revision-Date: 2021-10-18 15:42+0000\n"
"Last-Translator: Benet (BennyBeat) R. i Camps <bennybeat@gmail.com>\n"
"Language-Team: Catalan <https://weblate.securedrop.org/projects/securedrop/"
"securedrop-client/ca/>\n"
"Language: ca\n"
"Language-Team: Catalan <https://weblate.securedrop.org/projects/securedrop/securedrop-client/ca/>\n"
"Plural-Forms: nplurals=2; plural=n != 1\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.6\n"
"Generated-By: Babel 2.9.1\n"

msgid "{application_name} is already running"
Expand Down Expand Up @@ -55,9 +53,7 @@ msgid "Retrieving new messages"
msgstr "S'estan obtenint els missatges nous"

msgid "File does not exist in the data directory. Please try re-downloading."
msgstr ""
"Els fitxers no existeixen en el directori de dades. Proveu de baixar-los de "
"nou."
msgstr "Els fitxers no existeixen en el directori de dades. Proveu de baixar-los de nou."

msgid "The file download failed. Please try again."
msgstr "Ha fallat la baixada del fitxer. Proveu-ho de nou."
Expand All @@ -68,9 +64,54 @@ msgstr "Ha fallat la supressió de la conversa al servidor"
msgid "Failed to delete source at server"
msgstr "Ha fallat la supressió de la font al servidor"

msgid "Username"
msgstr "Nom d’usuari"

msgid "Passphrase"
msgstr ""

msgid "Two-Factor Code"
msgstr "Codi d'autenticació de factor doble"

msgid "SecureDrop Client v{}"
msgstr "Client del SecureDrop v{}"

msgid "SIGN IN"
msgstr "INICIA LA SESSIÓ"

msgid ""
"That username won't work.\n"
"It should be at least 3 characters long."
msgstr ""
"No es pot utilitzar aquest nom d'usuari.\n"
"Indiqueu un nom d'usuari d'almenys 3 caràcters."

msgid ""
"That passphrase won't work.\n"
"It should be between 14 and 128 characters long."
msgstr ""
"No es pot utilitzar aquesta contrasenya.\n"
"Indiqueu una contrasenya de 14 a 128 caràcters."

msgid ""
"That two-factor code won't work.\n"
"It should only contain numerals."
msgstr ""
"No es pot utilitzar aquest codi.\n"
"El codi ha de ser només numèric."

msgid "SIGNING IN"
msgstr ""

msgid "Please enter a username, passphrase and two-factor code."
msgstr "Inseriu un nom d'usuari, contrasenya i codi de factor doble."

msgid "SecureDrop Client {}"
msgstr "Client del SecureDrop {}"

msgid "Quit"
msgstr ""

msgid "Last Refresh: {}"
msgstr "Última actualització: {}"

Expand All @@ -83,21 +124,14 @@ msgstr "{}"
msgid "SIGN OUT"
msgstr "TANCA LA SESSIÓ"

msgid "SIGN IN"
msgstr "INICIA LA SESSIÓ"

msgid "Nothing to see just yet!"
msgstr "Encara no hi ha res per mostrar"

msgid "Source submissions will be listed to the left, once downloaded and decrypted."
msgstr ""
"Els enviaments de les fonts es llistaran a l'esquerra, una vegada es baixen "
"i es desxifren."
msgstr "Els enviaments de les fonts es llistaran a l'esquerra, una vegada es baixen i es desxifren."

msgid "This is where you will read messages, reply to sources, and work with files."
msgstr ""
"Aquí és on llegireu els missatges, respostes a les fonts, i on treballareu "
"amb els fitxers."
msgstr "Aquí és on llegireu els missatges, respostes a les fonts, i on treballareu amb els fitxers."

msgid "Select a source from the list, to:"
msgstr "Seleccioneu una font de la llista, per a:"
Expand All @@ -123,45 +157,6 @@ msgstr "— S'han eliminat tots els fitxers i missatges d'aquesta font —"
msgid "USE OFFLINE"
msgstr "USA-HO FORA DE LÍNIA"

msgid "Username"
msgstr "Nom d’usuari"

msgid "Passphrase"
msgstr ""

msgid "Two-Factor Code"
msgstr "Codi d'autenticació de factor doble"

msgid "SecureDrop Client v{}"
msgstr "Client del SecureDrop v{}"

msgid ""
"That username won't work.\n"
"It should be at least 3 characters long."
msgstr ""
"No es pot utilitzar aquest nom d'usuari.\n"
"Indiqueu un nom d'usuari d'almenys 3 caràcters."

msgid ""
"That passphrase won't work.\n"
"It should be between 14 and 128 characters long."
msgstr ""
"No es pot utilitzar aquesta contrasenya.\n"
"Indiqueu una contrasenya de 14 a 128 caràcters."

msgid ""
"That two-factor code won't work.\n"
"It should only contain numerals."
msgstr ""
"No es pot utilitzar aquest codi.\n"
"El codi ha de ser només numèric."

msgid "SIGNING IN"
msgstr ""

msgid "Please enter a username, passphrase and two-factor code."
msgstr "Inseriu un nom d'usuari, contrasenya i codi de factor doble."

msgid "Failed to send"
msgstr "Ha fallat en enviar"

Expand Down Expand Up @@ -190,9 +185,7 @@ msgid "CONTINUE"
msgstr "CONTINUA"

msgid "Preparing to print:<br /><span style=\"font-weight:normal\">{}</span>"
msgstr ""
"S'està preparant per imprimir:<br /><span style=\"font-weight:normal\""
">{}</span>"
msgstr "S'està preparant per imprimir:<br /><span style=\"font-weight:normal\">{}</span>"

msgid "Ready to print:<br /><span style=\"font-weight:normal\">{}</span>"
msgstr ""
Expand Down Expand Up @@ -322,11 +315,12 @@ msgstr ""
msgid " to compose or send a reply"
msgstr ""

msgid "DELETE"
msgstr "SUPRIMEIX"

msgid "Entire source account"
msgstr ""

msgid "Files and messages"
msgstr ""

msgid "DELETE"
msgstr "SUPRIMEIX"
Binary file not shown.
Loading