From 35463646e4c4fd84fc729ea63e6ab3f667861df2 Mon Sep 17 00:00:00 2001 From: JanAckermann Date: Wed, 24 Mar 2021 09:56:10 +0100 Subject: [PATCH] added l10n --- .gitignore | 3 +++ .make/l10n.mk | 49 ++++++++++++++++++++++++++++++++++++++++ Makefile | 27 ++++++++++++++++++++++ accounts/Makefile | 3 +++ accounts/l10n/.tx/config | 9 ++++++++ settings/Makefile | 4 +++- settings/l10n/.tx/config | 9 ++++++++ 7 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 .make/l10n.mk create mode 100644 accounts/l10n/.tx/config create mode 100644 settings/l10n/.tx/config diff --git a/.gitignore b/.gitignore index 21bda20ff0..16a4eaabbf 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,6 @@ vendor-bin/**/composer.lock # drone CI is in .drone.star, do not let someone accidentally commit a local .drone.yml .drone.yml + +**/l10n/locale +**/l10n/template.pot diff --git a/.make/l10n.mk b/.make/l10n.mk new file mode 100644 index 0000000000..e13255ba1f --- /dev/null +++ b/.make/l10n.mk @@ -0,0 +1,49 @@ +# On OSX the PATH variable isn't exported unless "SHELL" is also set, see: http://stackoverflow.com/a/25506676 +SHELL = /bin/bash +NODE_BINDIR = ./node_modules/.bin +export PATH := $(NODE_BINDIR):$(PATH) + +INPUT_FILES = ./ui + +# Where to write the files generated by this makefile. +OUTPUT_DIR = ./l10n + +# Template file +TEMPLATE_FILE = ./l10n/template.pot + +# Name of the generated .po files for each available locale. +LOCALE_FILES = $(shell find l10n/locale -name '*.po') + +.PHONY: l10n-push +l10n-push: + cd $(OUTPUT_DIR) && tx -d push -s --skip --no-interactive + +.PHONY: l10n-pull +l10n-pull: + cd $(OUTPUT_DIR) && tx -d pull -a --skip --minimum-perc=75 + +.PHONY: l10n-clean +l10n-clean: + rm -rf $(OUTPUT_DIR)/locale + rm -rf $(OUTPUT_DIR)/translations.json + rm -f $(TEMPLATE_FILE) + +.PHONY: l10n-read +l10n-read: node_modules $(TEMPLATE_FILE) + +.PHONY: l10n-write +l10n-write: node_modules $(OUTPUT_DIR)/translations.json + +# Create a main .pot template, then generate .po files for each available language. +# Thanks to Systematic: https://github.com/Polyconseil/systematic/blob/866d5a/mk/main.mk#L167-L183 +$(TEMPLATE_FILE): +# Extract gettext strings from each template file and create a POT dictionary template. +# Generate .po files for each available language. + export GETTEXT_SOURCES=`find $(INPUT_FILES) -name '*.vue' -o -name '*.js'`; \ + node ./node_modules/easygettext/src/extract-cli.js --attribute v-translate --output $(OUTPUT_DIR)/template.pot $$GETTEXT_SOURCES; + +# Generate translations.json file from .pot template. +$(OUTPUT_DIR)/translations.json: + gettext-compile --output $(OUTPUT_DIR)/translations.json $(LOCALE_FILES); + + diff --git a/Makefile b/Makefile index a8ce333097..1a2ff81557 100644 --- a/Makefile +++ b/Makefile @@ -12,6 +12,8 @@ WHITE := $(shell tput -Txterm setaf 7) RESET := $(shell tput -Txterm sgr0) +L10N_MODULES := $(shell find . -path '*.tx*' -name 'config' | sed 's|/[^/]*$$||' | sed 's|/[^/]*$$||' | sed 's|/[^/]*$$||') + # if you add a module here please also add it to the .drone.star file OCIS_MODULES = \ accounts \ @@ -153,3 +155,28 @@ ifndef CHANGELOG_VERSION $(error CHANGELOG_VERSION is undefined) endif $(CALENS) --version $(CHANGELOG_VERSION) -o ocis/dist/CHANGELOG.md + + +.PHONY: l10n-pull +l10n-pull: + @for extension in $(L10N_MODULES); do \ + make -C $$extension l10n-pull; \ + done + +.PHONY: l10n-clean +l10n-clean: + @for extension in $(L10N_MODULES); do \ + make -C $$extension l10n-clean; \ + done + +.PHONY: l10n-read +l10n-read: + @for extension in $(L10N_MODULES); do \ + make -C $$extension l10n-read; \ + done + +.PHONY: l10n-write +l10n-write: + @for extension in $(L10N_MODULES); do \ + make -C $$extension l10n-write; \ + done diff --git a/accounts/Makefile b/accounts/Makefile index 6683905536..c02d1e0f8f 100644 --- a/accounts/Makefile +++ b/accounts/Makefile @@ -20,6 +20,9 @@ include ../.make/release.mk ############ docs generate ############ include ../.make/docs.mk +############ l10n ############ +include ../.make/l10n.mk + .PHONY: docs-generate docs-generate: config-docs-generate \ grpc-docs-generate diff --git a/accounts/l10n/.tx/config b/accounts/l10n/.tx/config new file mode 100644 index 0000000000..c401c8aef6 --- /dev/null +++ b/accounts/l10n/.tx/config @@ -0,0 +1,9 @@ +[main] +host = https://www.transifex.com + +[owncloud.ocis-accounts] +file_filter = locale//LC_MESSAGES/app.po +minimum_perc = 0 +source_file = template.pot +source_lang = en +type = PO diff --git a/settings/Makefile b/settings/Makefile index 838658496a..e1b559f5ee 100644 --- a/settings/Makefile +++ b/settings/Makefile @@ -15,13 +15,15 @@ endif include ../.make/go.mk - ############ release ############ include ../.make/release.mk ############ docs generate ############ include ../.make/docs.mk +############ l10n ############ +include ../.make/l10n.mk + .PHONY: docs-generate docs-generate: config-docs-generate \ grpc-docs-generate diff --git a/settings/l10n/.tx/config b/settings/l10n/.tx/config new file mode 100644 index 0000000000..6f2de28cef --- /dev/null +++ b/settings/l10n/.tx/config @@ -0,0 +1,9 @@ +[main] +host = https://www.transifex.com + +[owncloud.ocis-settings] +file_filter = locale//LC_MESSAGES/app.po +minimum_perc = 0 +source_file = template.pot +source_lang = en +type = PO