From 2984ce895931ef7e628e3bf5516f056a5a923b04 Mon Sep 17 00:00:00 2001 From: Shadi Naif Date: Wed, 11 Oct 2023 17:26:09 +0300 Subject: [PATCH] feat: add atlas support for cookiecutter-django-app (#392) Update cookiecutter-django-app to support atlas for all new apps Refs: FC-0012 OEP-58 --- .../{{cookiecutter.repo_name}}/Makefile | 19 ++++++++++++++----- .../requirements/base.in | 2 ++ .../{{cookiecutter.app_name}}/base.html | 4 ++++ 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/cookiecutter-django-app/{{cookiecutter.repo_name}}/Makefile b/cookiecutter-django-app/{{cookiecutter.repo_name}}/Makefile index 8007fdb1..a4f6bd28 100644 --- a/cookiecutter-django-app/{{cookiecutter.repo_name}}/Makefile +++ b/cookiecutter-django-app/{{cookiecutter.repo_name}}/Makefile @@ -85,17 +85,26 @@ selfcheck: ## check that the Makefile is well-formed extract_translations: ## extract strings to be translated, outputting .mo files rm -rf docs/_build - cd {{cookiecutter.app_name}} && ../manage.py makemessages -l en -v1 -d django - cd {{cookiecutter.app_name}} && ../manage.py makemessages -l en -v1 -d djangojs + cd {{cookiecutter.app_name}} && i18n_tool extract --no-segment compile_translations: ## compile translation files, outputting .po files for each supported language - cd {{cookiecutter.app_name}} && ../manage.py compilemessages + cd {{cookiecutter.app_name}} && i18n_tool generate detect_changed_source_translations: cd {{cookiecutter.app_name}} && i18n_tool changed -pull_translations: ## pull translations from Transifex - tx pull -af -t --mode reviewed +ifeq ($(OPENEDX_ATLAS_PULL),) +pull_translations: ## Pull translations from Transifex + tx pull -t -a -f --mode reviewed --minimum-perc=1 +else +# Experimental: OEP-58 Pulls translations using atlas +pull_translations: + find {{cookiecutter.app_name}}/conf/locale -mindepth 1 -maxdepth 1 -type d -exec rm -r {} \; + atlas pull $(OPENEDX_ATLAS_ARGS) translations/{{cookiecutter.repo_name}}/{{cookiecutter.app_name}}/conf/locale:{{cookiecutter.app_name}}/conf/locale + python manage.py compilemessages + + @echo "Translations have been pulled via Atlas and compiled." +endif push_translations: ## push source translation files (.po) from Transifex tx push -s diff --git a/cookiecutter-django-app/{{cookiecutter.repo_name}}/requirements/base.in b/cookiecutter-django-app/{{cookiecutter.repo_name}}/requirements/base.in index 6f000f51..5eaa316e 100644 --- a/cookiecutter-django-app/{{cookiecutter.repo_name}}/requirements/base.in +++ b/cookiecutter-django-app/{{cookiecutter.repo_name}}/requirements/base.in @@ -5,3 +5,5 @@ Django # Web application framework {% if cookiecutter.models != "Comma-separated list of models" -%} django-model-utils # Provides TimeStampedModel abstract base class {%- endif %} + +openedx-atlas diff --git a/cookiecutter-django-app/{{cookiecutter.repo_name}}/{{cookiecutter.app_name}}/templates/{{cookiecutter.app_name}}/base.html b/cookiecutter-django-app/{{cookiecutter.repo_name}}/{{cookiecutter.app_name}}/templates/{{cookiecutter.app_name}}/base.html index ab4c3193..3e7f76f5 100644 --- a/cookiecutter-django-app/{{cookiecutter.repo_name}}/{{cookiecutter.app_name}}/templates/{{cookiecutter.app_name}}/base.html +++ b/cookiecutter-django-app/{{cookiecutter.repo_name}}/{{cookiecutter.app_name}}/templates/{{cookiecutter.app_name}}/base.html @@ -1,4 +1,8 @@ {% raw %} + +{% load i18n %} +{% trans "Dummy text to generate a translation (.po) source file. It is safe to delete this line. It is also safe to delete (load i18n) above if there are no other (trans) tags in the file" %} + {% comment %} As the developer of this package, don't place anything here if you can help it since this allows developers to have interoperability between your template