From ee8e81930b8b7920215e8a6ba98e22ddfa04c5e0 Mon Sep 17 00:00:00 2001 From: Shadi Naif Date: Mon, 14 Aug 2023 14:03:43 +0300 Subject: [PATCH] feat: stardandize XBlock template to support atlas Refs: FC-0012 OEP-58 --- .../{{cookiecutter.repo_name}}/Makefile | 20 ++++++++++++------- .../{ => conf}/locale/__init__.py | 0 .../{ => conf}/locale/config.yaml | 0 .../{ => conf}/locale/settings.py | 0 4 files changed, 13 insertions(+), 7 deletions(-) rename cookiecutter-xblock/{{cookiecutter.repo_name}}/{{cookiecutter.package_name}}/{ => conf}/locale/__init__.py (100%) rename cookiecutter-xblock/{{cookiecutter.repo_name}}/{{cookiecutter.package_name}}/{ => conf}/locale/config.yaml (100%) rename cookiecutter-xblock/{{cookiecutter.repo_name}}/{{cookiecutter.package_name}}/{ => conf}/locale/settings.py (100%) diff --git a/cookiecutter-xblock/{{cookiecutter.repo_name}}/Makefile b/cookiecutter-xblock/{{cookiecutter.repo_name}}/Makefile index c08043c9..78f508e0 100644 --- a/cookiecutter-xblock/{{cookiecutter.repo_name}}/Makefile +++ b/cookiecutter-xblock/{{cookiecutter.repo_name}}/Makefile @@ -7,10 +7,10 @@ REPO_NAME := {{cookiecutter.repo_name}} PACKAGE_NAME := {{cookiecutter.package_name}} -EXTRACT_DIR := $(PACKAGE_NAME)/locale/en/LC_MESSAGES -EXTRACTED_DJANGO := $(EXTRACT_DIR)/django-partial.po -EXTRACTED_DJANGOJS := $(EXTRACT_DIR)/djangojs-partial.po -EXTRACTED_TEXT := $(EXTRACT_DIR)/text.po +EXTRACT_DIR := $(PACKAGE_NAME)/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 JS_TARGET := public/js/translations TRANSLATIONS_DIR := $(PACKAGE_NAME)/translations @@ -59,8 +59,14 @@ dev.run: dev.clean dev.build ## Clean, build and run test image extract_translations: symlink_translations ## extract strings to be translated, outputting .po files cd $(PACKAGE_NAME) && i18n_tool extract - mv $(EXTRACTED_DJANGO) $(EXTRACTED_TEXT) - if [ -f "$(EXTRACTED_DJANGOJS)" ]; then cat $(EXTRACTED_DJANGOJS) >> $(EXTRACTED_TEXT); rm $(EXTRACTED_DJANGOJS); fi + mv $(EXTRACTED_DJANGO_PARTIAL) $(EXTRACTED_DJANGO) + # Use msgcat to concatenate djangojs if it exists + if test -f $(EXTRACTED_DJANGOJS_PARTIAL); then \ + msgcat $(EXTRACTED_DJANGO) $(EXTRACTED_DJANGOJS_PARTIAL) -o $(EXTRACTED_DJANGO) && \ + rm $(EXTRACTED_DJANGOJS_PARTIAL); \ + fi + sed -i'' -e 's/nplurals=INTEGER/nplurals=2/' $(EXTRACTED_DJANGO) + sed -i'' -e 's/plural=EXPRESSION/plural=\(n != 1\)/' $(EXTRACTED_DJANGO) compile_translations: symlink_translations ## compile translation files, outputting .mo files for each supported language cd $(PACKAGE_NAME) && i18n_tool generate @@ -83,7 +89,7 @@ push_translations: extract_translations ## push translations to transifex cd $(PACKAGE_NAME) && i18n_tool transifex push symlink_translations: - if [ ! -d "$(TRANSLATIONS_DIR)" ]; then ln -s locale/ $(TRANSLATIONS_DIR); fi + if [ ! -d "$(TRANSLATIONS_DIR)" ]; then ln -s conf/locale/ $(TRANSLATIONS_DIR); fi install_transifex_client: ## Install the Transifex client # Instaling client will skip CHANGELOG and LICENSE files from git changes diff --git a/cookiecutter-xblock/{{cookiecutter.repo_name}}/{{cookiecutter.package_name}}/locale/__init__.py b/cookiecutter-xblock/{{cookiecutter.repo_name}}/{{cookiecutter.package_name}}/conf/locale/__init__.py similarity index 100% rename from cookiecutter-xblock/{{cookiecutter.repo_name}}/{{cookiecutter.package_name}}/locale/__init__.py rename to cookiecutter-xblock/{{cookiecutter.repo_name}}/{{cookiecutter.package_name}}/conf/locale/__init__.py diff --git a/cookiecutter-xblock/{{cookiecutter.repo_name}}/{{cookiecutter.package_name}}/locale/config.yaml b/cookiecutter-xblock/{{cookiecutter.repo_name}}/{{cookiecutter.package_name}}/conf/locale/config.yaml similarity index 100% rename from cookiecutter-xblock/{{cookiecutter.repo_name}}/{{cookiecutter.package_name}}/locale/config.yaml rename to cookiecutter-xblock/{{cookiecutter.repo_name}}/{{cookiecutter.package_name}}/conf/locale/config.yaml diff --git a/cookiecutter-xblock/{{cookiecutter.repo_name}}/{{cookiecutter.package_name}}/locale/settings.py b/cookiecutter-xblock/{{cookiecutter.repo_name}}/{{cookiecutter.package_name}}/conf/locale/settings.py similarity index 100% rename from cookiecutter-xblock/{{cookiecutter.repo_name}}/{{cookiecutter.package_name}}/locale/settings.py rename to cookiecutter-xblock/{{cookiecutter.repo_name}}/{{cookiecutter.package_name}}/conf/locale/settings.py