Skip to content

Commit

Permalink
feat: add atlas support for cookiecutter-django-app (#392)
Browse files Browse the repository at this point in the history
Update cookiecutter-django-app to support atlas for all new apps

Refs: FC-0012 OEP-58
  • Loading branch information
shadinaif authored Oct 11, 2023
1 parent 1cc86c0 commit 2984ce8
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
19 changes: 14 additions & 5 deletions cookiecutter-django-app/{{cookiecutter.repo_name}}/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 2984ce8

Please sign in to comment.