From 6b35f7f287d112f932f5ade0f3138e55860c12fd Mon Sep 17 00:00:00 2001 From: Shadi Naif Date: Tue, 30 May 2023 23:11:34 +0300 Subject: [PATCH] feat: standardize make extract_translations (#105) Refs: FC-0012 OEP-58 --- Makefile | 18 ++++++++++++------ .../{translations => conf/locale}/__init__.py | 0 .../locale}/ar/LC_MESSAGES/text.mo | Bin .../locale}/ar/LC_MESSAGES/text.po | 0 .../{translations => conf/locale}/config.yaml | 0 .../locale/en/LC_MESSAGES/django.po} | 0 .../conf/locale/en/LC_MESSAGES/text.po | 1 + .../locale}/eo/LC_MESSAGES/text.mo | Bin .../locale}/eo/LC_MESSAGES/text.po | 0 .../locale}/es_419/LC_MESSAGES/text.po | 0 .../locale}/fr/LC_MESSAGES/text.po | 0 .../locale}/he/LC_MESSAGES/text.mo | Bin .../locale}/he/LC_MESSAGES/text.po | 0 .../locale}/hi/LC_MESSAGES/text.po | 0 .../locale}/ko_KR/LC_MESSAGES/text.mo | Bin .../locale}/ko_KR/LC_MESSAGES/text.po | 0 .../locale}/pl/LC_MESSAGES/text.mo | Bin .../locale}/pl/LC_MESSAGES/text.po | 0 .../locale}/pt_BR/LC_MESSAGES/text.po | 0 image_explorer/locale | 2 +- image_explorer/translations | 1 + 21 files changed, 15 insertions(+), 7 deletions(-) rename image_explorer/{translations => conf/locale}/__init__.py (100%) rename image_explorer/{translations => conf/locale}/ar/LC_MESSAGES/text.mo (100%) rename image_explorer/{translations => conf/locale}/ar/LC_MESSAGES/text.po (100%) rename image_explorer/{translations => conf/locale}/config.yaml (100%) rename image_explorer/{translations/en/LC_MESSAGES/text.po => conf/locale/en/LC_MESSAGES/django.po} (100%) create mode 120000 image_explorer/conf/locale/en/LC_MESSAGES/text.po rename image_explorer/{translations => conf/locale}/eo/LC_MESSAGES/text.mo (100%) rename image_explorer/{translations => conf/locale}/eo/LC_MESSAGES/text.po (100%) rename image_explorer/{translations => conf/locale}/es_419/LC_MESSAGES/text.po (100%) rename image_explorer/{translations => conf/locale}/fr/LC_MESSAGES/text.po (100%) rename image_explorer/{translations => conf/locale}/he/LC_MESSAGES/text.mo (100%) rename image_explorer/{translations => conf/locale}/he/LC_MESSAGES/text.po (100%) rename image_explorer/{translations => conf/locale}/hi/LC_MESSAGES/text.po (100%) rename image_explorer/{translations => conf/locale}/ko_KR/LC_MESSAGES/text.mo (100%) rename image_explorer/{translations => conf/locale}/ko_KR/LC_MESSAGES/text.po (100%) rename image_explorer/{translations => conf/locale}/pl/LC_MESSAGES/text.mo (100%) rename image_explorer/{translations => conf/locale}/pl/LC_MESSAGES/text.po (100%) rename image_explorer/{translations => conf/locale}/pt_BR/LC_MESSAGES/text.po (100%) create mode 120000 image_explorer/translations diff --git a/Makefile b/Makefile index f8d3178..86391f5 100644 --- a/Makefile +++ b/Makefile @@ -4,9 +4,10 @@ .DEFAULT_GOAL := help WORKING_DIR := image_explorer -EXTRACT_DIR := $(WORKING_DIR)/translations/en/LC_MESSAGES -EXTRACTED_DJANGO := $(EXTRACT_DIR)/django-partial.po -EXTRACTED_TEXT := $(EXTRACT_DIR)/text.po +EXTRACT_DIR := $(WORKING_DIR)/conf/locale/en/LC_MESSAGES +EXTRACTED_DJANGO_PARTIAL := $(EXTRACT_DIR)/django-partial.po +EXTRACTED_DJANGOJS_PARTIAL := $(EXTRACT_DIR)/djangojs-partial.po +EXTRACTED_DJANGO := $(EXTRACT_DIR)/django.po help: ## display this help message @echo "Please use \`make ' where is one of" @@ -25,9 +26,14 @@ clean: ## remove generated byte code, coverage reports, and build artifacts extract_translations: ## extract strings to be translated, outputting .po files cd $(WORKING_DIR) && i18n_tool extract - mv $(EXTRACTED_DJANGO) $(EXTRACTED_TEXT) - sed -i'' -e 's/nplurals=INTEGER/nplurals=2/' $(EXTRACTED_TEXT) - sed -i'' -e 's/plural=EXPRESSION/plural=\(n != 1\)/' $(EXTRACTED_TEXT) + mv $(EXTRACTED_DJANGO_PARTIAL) $(EXTRACTED_DJANGO) + # Safely concatenate djangojs if it exists + ( test -f $(EXTRACTED_DJANGOJS_PARTIAL) && \ + msgcat $(EXTRACTED_DJANGO) $(EXTRACTED_DJANGOJS_PARTIAL) -o $(EXTRACTED_DJANGO) \ + ) || ! test -f $(EXTRACTED_DJANGOJS_PARTIAL) + rm -rf $(EXTRACTED_DJANGOJS_PARTIAL) + sed -i'' -e 's/nplurals=INTEGER/nplurals=2/' $(EXTRACTED_DJANGO) + sed -i'' -e 's/plural=EXPRESSION/plural=\(n != 1\)/' $(EXTRACTED_DJANGO) compile_translations: ## compile translation files, outputting .mo files for each supported language cd $(WORKING_DIR) && i18n_tool generate diff --git a/image_explorer/translations/__init__.py b/image_explorer/conf/locale/__init__.py similarity index 100% rename from image_explorer/translations/__init__.py rename to image_explorer/conf/locale/__init__.py diff --git a/image_explorer/translations/ar/LC_MESSAGES/text.mo b/image_explorer/conf/locale/ar/LC_MESSAGES/text.mo similarity index 100% rename from image_explorer/translations/ar/LC_MESSAGES/text.mo rename to image_explorer/conf/locale/ar/LC_MESSAGES/text.mo diff --git a/image_explorer/translations/ar/LC_MESSAGES/text.po b/image_explorer/conf/locale/ar/LC_MESSAGES/text.po similarity index 100% rename from image_explorer/translations/ar/LC_MESSAGES/text.po rename to image_explorer/conf/locale/ar/LC_MESSAGES/text.po diff --git a/image_explorer/translations/config.yaml b/image_explorer/conf/locale/config.yaml similarity index 100% rename from image_explorer/translations/config.yaml rename to image_explorer/conf/locale/config.yaml diff --git a/image_explorer/translations/en/LC_MESSAGES/text.po b/image_explorer/conf/locale/en/LC_MESSAGES/django.po similarity index 100% rename from image_explorer/translations/en/LC_MESSAGES/text.po rename to image_explorer/conf/locale/en/LC_MESSAGES/django.po diff --git a/image_explorer/conf/locale/en/LC_MESSAGES/text.po b/image_explorer/conf/locale/en/LC_MESSAGES/text.po new file mode 120000 index 0000000..0082074 --- /dev/null +++ b/image_explorer/conf/locale/en/LC_MESSAGES/text.po @@ -0,0 +1 @@ +django.po \ No newline at end of file diff --git a/image_explorer/translations/eo/LC_MESSAGES/text.mo b/image_explorer/conf/locale/eo/LC_MESSAGES/text.mo similarity index 100% rename from image_explorer/translations/eo/LC_MESSAGES/text.mo rename to image_explorer/conf/locale/eo/LC_MESSAGES/text.mo diff --git a/image_explorer/translations/eo/LC_MESSAGES/text.po b/image_explorer/conf/locale/eo/LC_MESSAGES/text.po similarity index 100% rename from image_explorer/translations/eo/LC_MESSAGES/text.po rename to image_explorer/conf/locale/eo/LC_MESSAGES/text.po diff --git a/image_explorer/translations/es_419/LC_MESSAGES/text.po b/image_explorer/conf/locale/es_419/LC_MESSAGES/text.po similarity index 100% rename from image_explorer/translations/es_419/LC_MESSAGES/text.po rename to image_explorer/conf/locale/es_419/LC_MESSAGES/text.po diff --git a/image_explorer/translations/fr/LC_MESSAGES/text.po b/image_explorer/conf/locale/fr/LC_MESSAGES/text.po similarity index 100% rename from image_explorer/translations/fr/LC_MESSAGES/text.po rename to image_explorer/conf/locale/fr/LC_MESSAGES/text.po diff --git a/image_explorer/translations/he/LC_MESSAGES/text.mo b/image_explorer/conf/locale/he/LC_MESSAGES/text.mo similarity index 100% rename from image_explorer/translations/he/LC_MESSAGES/text.mo rename to image_explorer/conf/locale/he/LC_MESSAGES/text.mo diff --git a/image_explorer/translations/he/LC_MESSAGES/text.po b/image_explorer/conf/locale/he/LC_MESSAGES/text.po similarity index 100% rename from image_explorer/translations/he/LC_MESSAGES/text.po rename to image_explorer/conf/locale/he/LC_MESSAGES/text.po diff --git a/image_explorer/translations/hi/LC_MESSAGES/text.po b/image_explorer/conf/locale/hi/LC_MESSAGES/text.po similarity index 100% rename from image_explorer/translations/hi/LC_MESSAGES/text.po rename to image_explorer/conf/locale/hi/LC_MESSAGES/text.po diff --git a/image_explorer/translations/ko_KR/LC_MESSAGES/text.mo b/image_explorer/conf/locale/ko_KR/LC_MESSAGES/text.mo similarity index 100% rename from image_explorer/translations/ko_KR/LC_MESSAGES/text.mo rename to image_explorer/conf/locale/ko_KR/LC_MESSAGES/text.mo diff --git a/image_explorer/translations/ko_KR/LC_MESSAGES/text.po b/image_explorer/conf/locale/ko_KR/LC_MESSAGES/text.po similarity index 100% rename from image_explorer/translations/ko_KR/LC_MESSAGES/text.po rename to image_explorer/conf/locale/ko_KR/LC_MESSAGES/text.po diff --git a/image_explorer/translations/pl/LC_MESSAGES/text.mo b/image_explorer/conf/locale/pl/LC_MESSAGES/text.mo similarity index 100% rename from image_explorer/translations/pl/LC_MESSAGES/text.mo rename to image_explorer/conf/locale/pl/LC_MESSAGES/text.mo diff --git a/image_explorer/translations/pl/LC_MESSAGES/text.po b/image_explorer/conf/locale/pl/LC_MESSAGES/text.po similarity index 100% rename from image_explorer/translations/pl/LC_MESSAGES/text.po rename to image_explorer/conf/locale/pl/LC_MESSAGES/text.po diff --git a/image_explorer/translations/pt_BR/LC_MESSAGES/text.po b/image_explorer/conf/locale/pt_BR/LC_MESSAGES/text.po similarity index 100% rename from image_explorer/translations/pt_BR/LC_MESSAGES/text.po rename to image_explorer/conf/locale/pt_BR/LC_MESSAGES/text.po diff --git a/image_explorer/locale b/image_explorer/locale index 9915417..618b7e2 120000 --- a/image_explorer/locale +++ b/image_explorer/locale @@ -1 +1 @@ -translations/ \ No newline at end of file +conf/locale \ No newline at end of file diff --git a/image_explorer/translations b/image_explorer/translations new file mode 120000 index 0000000..618b7e2 --- /dev/null +++ b/image_explorer/translations @@ -0,0 +1 @@ +conf/locale \ No newline at end of file