From 256545e54834c07e528a3be8c214209210b6ff36 Mon Sep 17 00:00:00 2001 From: Nadja Heitmann Date: Thu, 9 Jan 2025 15:45:26 +0000 Subject: [PATCH] Update translation infrastructure --- .tx/config | 4 +++- lib/foreman_resource_quota/register.rb | 2 ++ locale/Makefile | 27 +++++++++++++++++++------- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/.tx/config b/.tx/config index d43729b..ece2fb7 100644 --- a/.tx/config +++ b/.tx/config @@ -1,8 +1,10 @@ [main] host = https://www.transifex.com -[foreman.foreman_resource_quota] +[o:foreman:p:foreman:r:foreman_resource_quota] file_filter = locale//foreman_resource_quota.edit.po source_file = locale/foreman_resource_quota.pot source_lang = en type = PO +minimum_perc = 50 + diff --git a/lib/foreman_resource_quota/register.rb b/lib/foreman_resource_quota/register.rb index 9e89589..05d872a 100644 --- a/lib/foreman_resource_quota/register.rb +++ b/lib/foreman_resource_quota/register.rb @@ -7,6 +7,8 @@ apipie_documented_controllers ["#{ForemanResourceQuota::Engine.root}" \ '/app/controllers/foreman_resource_quot/api/v2/*.rb'] + register_gettext + # Add permissions security_block :foreman_resource_quota do permission :view_resource_quotas, diff --git a/locale/Makefile b/locale/Makefile index 08014d1..5887bcc 100644 --- a/locale/Makefile +++ b/locale/Makefile @@ -6,14 +6,15 @@ # make tx-update - download and merge translations from Transifex # make clean - clean everything # -DOMAIN = foreman_resource_quota -VERSION = $(shell ruby -e 'require "rubygems";spec = Gem::Specification::load(Dir.glob("../*.gemspec")[0]);puts spec.version') +DOMAIN = $(shell ruby -rrubygems -e 'puts Gem::Specification::load(Dir.glob("../*.gemspec")[0]).name') +VERSION = $(shell ruby -rrubygems -e 'puts Gem::Specification::load(Dir.glob("../*.gemspec")[0]).version') POTFILE = $(DOMAIN).pot MOFILE = $(DOMAIN).mo POFILES = $(shell find . -name '$(DOMAIN).po') MOFILES = $(patsubst %.po,%.mo,$(POFILES)) POXFILES = $(patsubst %.po,%.pox,$(POFILES)) EDITFILES = $(patsubst %.po,%.edit.po,$(POFILES)) +JSFILES = $(shell find ../app/assets/javascripts/*/locale -name '$(DOMAIN).js') %.mo: %.po mkdir -p $(shell dirname $@)/LC_MESSAGES @@ -30,9 +31,16 @@ all-mo: $(MOFILES) cat $@ ! grep -q msgid $@ -%.edit.po: +%.edit.po: %.po.time_stamp touch $@ +# gettext will trash the .edit.po file if the time stamp doesn't exist or is older than the po file +%.po.time_stamp: %.po + touch --reference $< $@ + +# Prevent make from treating this as an intermediate file to be cleaned up +.PRECIOUS: %.po.time_stamp + check: $(POXFILES) # Unify duplicate translations @@ -42,19 +50,24 @@ uniq-po: done tx-pull: $(EDITFILES) - tx pull -f + # Initialize new languages + cd .. && tx pull -f --all --minimum-perc 50 + # Force update all existing languages + cd .. && tx pull -f --minimum-perc 0 for f in $(EDITFILES) ; do \ sed -i 's/^\("Project-Id-Version: \).*$$/\1$(DOMAIN) $(VERSION)\\n"/' $$f; \ done tx-update: tx-pull @echo - @echo Run rake plugin:gettext[$(DOMAIN)] from the Foreman installation, then make -C locale mo-files to finish + @echo Run rake plugin:gettext[$(DOMAIN)] from the Foreman installation + @echo then run rake plugin:po_to_json[$(DOMAIN)] from the Foreman installation + @echo then run make -C locale mo-files to finish @echo mo-files: $(MOFILES) - git add $(POFILES) $(POTFILE) ../locale/*/LC_MESSAGES + git add $(POFILES) $(POTFILE) $(JSFILES) ../locale/*/LC_MESSAGES git commit -m "i18n - pulling from tx" @echo @echo Changes commited! - @echo + echo