Check translations keys in CI (#279)

This commit is contained in:
Thomas Miceli 2024-05-11 21:02:57 +02:00 committed by GitHub
parent f705e879a1
commit 97636b23f5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 47 additions and 10 deletions

View file

@ -41,9 +41,12 @@ jobs:
with: with:
go-version: "1.22" go-version: "1.22"
- name: Check - name: Check Go modules
run: make go_mod check_changes run: make go_mod check_changes
- name: Check translations
run: make check-tr
test: test:
strategy: strategy:
fail-fast: false fail-fast: false

View file

@ -1,4 +1,4 @@
.PHONY: all all_crosscompile install build_frontend build_backend build build_crosscompile build_docker build_dev_docker run_dev_docker watch_frontend watch_backend watch clean clean_docker check_changes go_mod fmt test .PHONY: all all_crosscompile install build_frontend build_backend build build_crosscompile build_docker build_dev_docker run_dev_docker watch_frontend watch_backend watch clean clean_docker check_changes go_mod fmt test check-tr
# Specify the name of your Go binary output # Specify the name of your Go binary output
BINARY_NAME := opengist BINARY_NAME := opengist
@ -73,3 +73,6 @@ fmt:
test: test:
@go test ./... -p 1 @go test ./... -p 1
check-tr:
@bash ./scripts/check-translations.sh

View file

@ -132,9 +132,6 @@ auth.username: 'Benutzername'
auth.password: 'Passwort' auth.password: 'Passwort'
auth.register-instead: 'Stattdessen registrieren' auth.register-instead: 'Stattdessen registrieren'
auth.login-instead: 'Stattdessen anmelden' auth.login-instead: 'Stattdessen anmelden'
auth.github-oauth: 'Mit GitHub-Account fortfahren'
auth.gitlab-oauth: 'Mit GitLab-Account fortfahren'
auth.gitea-oauth: 'Mit Gitea-Account fortfahren'
error: 'Fehler' error: 'Fehler'

View file

@ -157,7 +157,6 @@ admin.delete: Eliminar
admin.created_at: Creado admin.created_at: Creado
admin.config-link: Esta configuración puede ser %s por un archivo de configuración YAML y/o variables de entorno. admin.config-link: Esta configuración puede ser %s por un archivo de configuración YAML y/o variables de entorno.
admin.config-link-overridden: sobrescrito
admin.disable-signup: Deshabilitar registro admin.disable-signup: Deshabilitar registro
admin.disable-signup_help: Prohibir la creación de nuevas cuentas. admin.disable-signup_help: Prohibir la creación de nuevas cuentas.
admin.require-login: Requerir inicio de sesión admin.require-login: Requerir inicio de sesión

View file

@ -187,7 +187,6 @@ settings.create-password-help: Créer un mot de passe pour se connecter à Openg
settings.change-password: Changer le mot de passe settings.change-password: Changer le mot de passe
settings.change-password-help: Changer le mot de passe pour se connecter à Opengist via HTTP settings.change-password-help: Changer le mot de passe pour se connecter à Opengist via HTTP
settings.password-label-title: Mot de passe settings.password-label-title: Mot de passe
auth.gitlab-oauth: Continuer avec un compte GitLab
admin.actions.sync-previews: Synchroniser l'aperçu des gists admin.actions.sync-previews: Synchroniser l'aperçu des gists
admin.actions.reset-hooks: Réinitialiser les hooks de Git pour tous les dépôts admin.actions.reset-hooks: Réinitialiser les hooks de Git pour tous les dépôts
gist.new.url: URL gist.new.url: URL

View file

@ -17,8 +17,6 @@ gist.header.clone-http: Clonar via %s
gist.header.clone-http-help: Clonar com Git usando autenticação básica HTTP. gist.header.clone-http-help: Clonar com Git usando autenticação básica HTTP.
gist.header.clone-ssh: Clonar via SSH gist.header.clone-ssh: Clonar via SSH
gist.header.clone-ssh-help: Clonar com Git usando uma chave SSH. gist.header.clone-ssh-help: Clonar com Git usando uma chave SSH.
gist.header.share: Compartilhar
gist.header.share-help: Copiar link para compartilhar este gist.
gist.header.download-zip: Baixar ZIP gist.header.download-zip: Baixar ZIP
gist.raw: Bruto gist.raw: Bruto
@ -157,7 +155,6 @@ admin.delete: Excluir
admin.created_at: Criado admin.created_at: Criado
admin.config-link: Esta configuração pode ser %s por um arquivo de configuração YAML e/ou variáveis de ambiente. admin.config-link: Esta configuração pode ser %s por um arquivo de configuração YAML e/ou variáveis de ambiente.
admin.config-link-overridden: sobrescrito
admin.disable-signup: Desabilitar registro admin.disable-signup: Desabilitar registro
admin.disable-signup_help: Proibir a criação de novas contas. admin.disable-signup_help: Proibir a criação de novas contas.
admin.require-login: Exigir login admin.require-login: Exigir login

39
scripts/check-translations.sh Executable file
View file

@ -0,0 +1,39 @@
#!/bin/bash
differences_found=0
# Extract keys from the reference file and sort them
sort <(awk -F':' '{print $1}' internal/i18n/locales/en-US.yml) > sorted_reference_keys.txt
sed -i '/^\s*$/d' sorted_reference_keys.txt
for new_file in internal/i18n/locales/*.yml; do
filename=$(basename $new_file)
echo ""
echo "Checking $filename..."
# Extract keys from the current file and sort them
sort <(awk -F':' '{print $1}' $new_file) > sorted_new_keys.txt
sed -i '/^\s*$/d' sorted_new_keys.txt
comm -3 sorted_reference_keys.txt sorted_new_keys.txt > differences.txt
if [ -s differences.txt ]; then
echo "Error in $filename: The YAML file has differences in keys."
while IFS= read -r line; do
if [[ $line == $'\t'* ]]; then
echo "+ Additional key in $filename: $(echo $line | awk '{$1=$1; print}')"
else
echo "- Missing key in $filename: $(echo $line | awk '{$1=$1; print}')"
fi
done < differences.txt
differences_found=1
else
echo "All keys in $filename match perfectly."
fi
rm sorted_new_keys.txt
done
rm sorted_reference_keys.txt differences.txt
exit $differences_found