diff --git a/cookiecutter-django-app/{{cookiecutter.repo_name}}/Makefile b/cookiecutter-django-app/{{cookiecutter.repo_name}}/Makefile index a4f6bd28..cc3b53dd 100644 --- a/cookiecutter-django-app/{{cookiecutter.repo_name}}/Makefile +++ b/cookiecutter-django-app/{{cookiecutter.repo_name}}/Makefile @@ -1,5 +1,5 @@ .PHONY: clean clean_tox compile_translations coverage diff_cover docs dummy_translations \ - extract_translations fake_translations help pii_check pull_translations push_translations \ + extract_translations fake_translations help pii_check pull_translations \ quality requirements selfcheck test test-all upgrade validate install_transifex_client .DEFAULT_GOAL := help @@ -106,9 +106,6 @@ pull_translations: @echo "Translations have been pulled via Atlas and compiled." endif -push_translations: ## push source translation files (.po) from Transifex - tx push -s - dummy_translations: ## generate dummy translation (.po) files cd {{cookiecutter.app_name}} && i18n_tool dummy diff --git a/cookiecutter-django-app/{{cookiecutter.repo_name}}/docs/internationalization.rst b/cookiecutter-django-app/{{cookiecutter.repo_name}}/docs/internationalization.rst index 9b25877c..bb98088b 100644 --- a/cookiecutter-django-app/{{cookiecutter.repo_name}}/docs/internationalization.rst +++ b/cookiecutter-django-app/{{cookiecutter.repo_name}}/docs/internationalization.rst @@ -34,8 +34,6 @@ The `make` targets listed below can be used to push or pull translations. - Description * - pull_translations - Pull translations from Transifex - * - push_translations - - Push source translation files to Transifex Fake Translations ***************** diff --git a/cookiecutter-django-ida/{{cookiecutter.repo_name}}/Makefile b/cookiecutter-django-ida/{{cookiecutter.repo_name}}/Makefile index c7edc4b9..fed2fba0 100644 --- a/cookiecutter-django-ida/{{cookiecutter.repo_name}}/Makefile +++ b/cookiecutter-django-ida/{{cookiecutter.repo_name}}/Makefile @@ -5,7 +5,7 @@ test coverage isort_check isort style lint quality pii_check validate \ migrate html_coverage upgrade extract_translation dummy_translations \ compile_translations fake_translations pull_translations \ - push_translations start-devstack open-devstack pkg-devstack \ + start-devstack open-devstack pkg-devstack \ detect_changed_source_translations validate_translations check_keywords \ install_transifex_client @@ -142,9 +142,6 @@ pull_translations: @echo "Translations have been pulled via Atlas and compiled." endif -push_translations: ## push source translation files (.po) from Transifex - tx push -s - start-devstack: ## run a local development copy of the server docker-compose --x-networking up diff --git a/cookiecutter-django-ida/{{cookiecutter.repo_name}}/db_keyword_overrides.yml b/cookiecutter-django-ida/{{cookiecutter.repo_name}}/db_keyword_overrides.yml index 62a4d610..24d9846d 100644 --- a/cookiecutter-django-ida/{{cookiecutter.repo_name}}/db_keyword_overrides.yml +++ b/cookiecutter-django-ida/{{cookiecutter.repo_name}}/db_keyword_overrides.yml @@ -1,6 +1,6 @@ # This file is used by the 'check_reserved_keywords' management command to allow specific field names to be overridden # when checking for conflicts with lists of restricted keywords used in various database/data warehouse tools. -# For more information, see: +# For more information, see: # https://openedx.atlassian.net/wiki/spaces/DE/pages/1411809288/Reserved+Keyword+Linter # and # https://github.com/openedx/edx-django-release-util/release_util/management/commands/check_reserved_keywords.py diff --git a/cookiecutter-django-ida/{{cookiecutter.repo_name}}/docs/internationalization.rst b/cookiecutter-django-ida/{{cookiecutter.repo_name}}/docs/internationalization.rst index 9b25877c..bb98088b 100644 --- a/cookiecutter-django-ida/{{cookiecutter.repo_name}}/docs/internationalization.rst +++ b/cookiecutter-django-ida/{{cookiecutter.repo_name}}/docs/internationalization.rst @@ -34,8 +34,6 @@ The `make` targets listed below can be used to push or pull translations. - Description * - pull_translations - Pull translations from Transifex - * - push_translations - - Push source translation files to Transifex Fake Translations ***************** diff --git a/cookiecutter-xblock/{{cookiecutter.repo_name}}/Makefile b/cookiecutter-xblock/{{cookiecutter.repo_name}}/Makefile index 20802d1d..bc62c5e5 100644 --- a/cookiecutter-xblock/{{cookiecutter.repo_name}}/Makefile +++ b/cookiecutter-xblock/{{cookiecutter.repo_name}}/Makefile @@ -3,7 +3,7 @@ .PHONY: dev.clean dev.build dev.run upgrade help requirements .PHONY: extract_translations compile_translations .PHONY: detect_changed_source_translations dummy_translations build_dummy_translations -.PHONY: validate_translations pull_translations push_translations install_transifex_clients +.PHONY: validate_translations pull_translations install_transifex_clients REPO_NAME := {{cookiecutter.repo_name}} PACKAGE_NAME := {{cookiecutter.package_name}} @@ -86,9 +86,6 @@ validate_translations: build_dummy_translations detect_changed_source_translatio pull_translations: ## pull translations from transifex cd $(PACKAGE_NAME) && i18n_tool transifex pull -push_translations: extract_translations ## push translations to transifex - cd $(PACKAGE_NAME) && i18n_tool transifex push - install_transifex_client: ## Install the Transifex client # Instaling client will skip CHANGELOG and LICENSE files from git changes # so remind the user to commit the change first before installing client. diff --git a/cookiecutter-xblock/{{cookiecutter.repo_name}}/README.rst b/cookiecutter-xblock/{{cookiecutter.repo_name}}/README.rst index 9c91e7cf..b452e774 100644 --- a/cookiecutter-xblock/{{cookiecutter.repo_name}}/README.rst +++ b/cookiecutter-xblock/{{cookiecutter.repo_name}}/README.rst @@ -1,26 +1,30 @@ {{cookiecutter.project_desc}} -############################# +{%- set heading_underline_length = (cookiecutter.project_desc | length) %} +{{ '#' * heading_underline_length }} Testing with Docker -******************** +******************* -This XBlock comes with a Docker test environment ready to build, based on the xblock-sdk workbench. To build and run it:: +This XBlock comes with a Docker test environment ready to build, based on the xblock-sdk workbench. +To build and run it: - $ make dev.run +.. code-block:: bash + + make dev.run The XBlock SDK Workbench, including this XBlock, will be available on the list of XBlocks at http://localhost:8000 Translating -************* +*********** Internationalization (i18n) is when a program is made aware of multiple languages. Localization (l10n) is adapting a program to local language and cultural habits. Use the locale directory to provide internationalized strings for your XBlock project. For more information on how to enable translations, visit the -`Open edX XBlock tutorial on Internationalization `_. +`Enabling Translations on a New Repo `_. -This cookiecutter template uses `django-statici18n `_ +This cookiecutter template uses `django-statici18n `_ to provide translations to static javascript using ``gettext``. The included Makefile contains targets for extracting, compiling and validating translatable strings. @@ -32,10 +36,11 @@ The general steps to provide multilingual messages for a Python program (or an X 4. Use ``gettext`` to translate strings. 1. Mark translatable strings -============================= +============================ -Mark translatable strings in python:: +Mark translatable strings in python: +.. code-block:: python from django.utils.translation import ugettext as _ @@ -45,8 +50,9 @@ Mark translatable strings in python:: See `edx-developer-guide `__ for more information. -You can also use ``gettext`` to mark strings in javascript:: +You can also use ``gettext`` to mark strings in javascript: +.. code-block:: javascript // Translators: This comment will appear in the `.po` file. var message = gettext("Custom message."); @@ -55,7 +61,7 @@ See `edx-developer-guide `_. @@ -63,10 +69,11 @@ use `edx-i18n-tools `_. After marking strings as translatable we have to create the raw message catalogs. These catalogs are created in ``.po`` files. For more information see `GNU PO file documentation `_. -These catalogs can be created by running:: +These catalogs can be created by running: +.. code-block:: bash - $ make extract_translations + make extract_translations The previous command will create the necessary ``.po`` files under ``{{cookiecutter.repo_name}}/{{cookiecutter.package_name}}/conf/locale/en/LC_MESSAGES/text.po``. @@ -75,10 +82,10 @@ The ``text.po`` file is created from the ``django-partial.po`` file created by this is why you will not see a ``django-partial.po`` file. 3. Create language specific translations -============================================== +======================================== 3.1 Add translated strings ---------------------------- +-------------------------- After creating the raw message catalogs, all translations should be filled out by the translator. One or more translators must edit the entries created in the message catalog, i.e. the ``.po`` file(s). @@ -102,49 +109,45 @@ To use translations from transifex use the follow Make target to pull translatio See `config instructions `_ for information on how to set up your transifex credentials. -See `transifex documentation `_ for more details about integrating -django with transiflex. +See `Enabling Translations on a New Repo `_ +for more details about integrating django with transifex. 3.2 Compile translations -------------------------- +------------------------ Once translations are in place, use the following Make target to compile the translation catalogs ``.po`` into -``.mo`` message files:: +``.mo`` message files: + +.. code-block:: bash - $ make compile_translations + make compile_translations The previous command will compile ``.po`` files using ``django-admin compilemessages`` (`compilemessages documentation `_). After compiling the ``.po`` file(s), ``django-statici18n`` is used to create language specific catalogs. See ``django-statici18n`` `documentation `_ for more information. -To upload translations to transiflex use the follow Make target:: - - $ make push_translations - -See `config instructions `_ for information on how to set up your -transifex credentials. - -See `transifex documentation `_ for more details about integrating -django with transiflex. - **Note:** The ``dev.run`` make target will automatically compile any translations. - **Note:** To check if the source translation files (``.po``) are up-to-date run:: + **Note:** To check if the source translation files (``.po``) are up-to-date run: - $ make detect_changed_source_translations +.. code-block:: bash + + make detect_changed_source_translations 4. Use ``gettext`` to translate strings -======================================== +======================================= Django will automatically use ``gettext`` and the compiled translations to translate strings. Troubleshooting -**************** +*************** + +If there are any errors compiling ``.po`` files run the following command to validate your ``.po`` files: -If there are any errors compiling ``.po`` files run the following command to validate your ``.po`` files:: +.. code-block:: bash - $ make validate + make validate See `django's i18n troubleshooting documentation `_ diff --git a/python-template/{{cookiecutter.placeholder_repo_name}}/README.rst b/python-template/{{cookiecutter.placeholder_repo_name}}/README.rst index bc7a6b8e..8c98d965 100644 --- a/python-template/{{cookiecutter.placeholder_repo_name}}/README.rst +++ b/python-template/{{cookiecutter.placeholder_repo_name}}/README.rst @@ -1,5 +1,6 @@ {{cookiecutter.project_name}} -############################# +{%- set heading_underline_length = (cookiecutter.project_name | length) %} +{{ '#' * heading_underline_length }} .. note:: diff --git a/python-template/{{cookiecutter.placeholder_repo_name}}/docs/internationalization.rst b/python-template/{{cookiecutter.placeholder_repo_name}}/docs/internationalization.rst index 9b25877c..bb98088b 100644 --- a/python-template/{{cookiecutter.placeholder_repo_name}}/docs/internationalization.rst +++ b/python-template/{{cookiecutter.placeholder_repo_name}}/docs/internationalization.rst @@ -34,8 +34,6 @@ The `make` targets listed below can be used to push or pull translations. - Description * - pull_translations - Pull translations from Transifex - * - push_translations - - Push source translation files to Transifex Fake Translations *****************