From 2f4626e8ae1613590c85153166abd211108967b0 Mon Sep 17 00:00:00 2001 From: Emad Rad Date: Thu, 1 Aug 2024 11:34:25 +0330 Subject: [PATCH 1/6] fix: make heading dynamic With this, we're not worried about teh size of the project_desc and the generated rst file is always working. --- cookiecutter-xblock/{{cookiecutter.repo_name}}/README.rst | 3 ++- .../{{cookiecutter.placeholder_repo_name}}/README.rst | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/cookiecutter-xblock/{{cookiecutter.repo_name}}/README.rst b/cookiecutter-xblock/{{cookiecutter.repo_name}}/README.rst index 9c91e7cf..f41d6fc9 100644 --- a/cookiecutter-xblock/{{cookiecutter.repo_name}}/README.rst +++ b/cookiecutter-xblock/{{cookiecutter.repo_name}}/README.rst @@ -1,5 +1,6 @@ {{cookiecutter.project_desc}} -############################# +{%- set heading_underline_length = (cookiecutter.project_desc | length) %} +{{ '#' * heading_underline_length }} Testing with Docker ******************** 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:: From ba8010503ed58aa2997e9fab1584a6b5e7df28d1 Mon Sep 17 00:00:00 2001 From: Emad Rad Date: Thu, 1 Aug 2024 11:37:22 +0330 Subject: [PATCH 2/6] chore: heading symbol length The size of the heading symbols should be the same size as the titles, otherwise might act funny in different environments --- .../{{cookiecutter.repo_name}}/README.rst | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/cookiecutter-xblock/{{cookiecutter.repo_name}}/README.rst b/cookiecutter-xblock/{{cookiecutter.repo_name}}/README.rst index f41d6fc9..2159240b 100644 --- a/cookiecutter-xblock/{{cookiecutter.repo_name}}/README.rst +++ b/cookiecutter-xblock/{{cookiecutter.repo_name}}/README.rst @@ -3,7 +3,7 @@ {{ '#' * 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:: @@ -12,7 +12,7 @@ This XBlock comes with a Docker test environment ready to build, based on the xb 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. @@ -33,7 +33,7 @@ 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:: @@ -56,7 +56,7 @@ See `edx-developer-guide `_. @@ -76,10 +76,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). @@ -107,7 +107,7 @@ See `transifex documentation `_ django with transiflex. 3.2 Compile translations -------------------------- +------------------------ Once translations are in place, use the following Make target to compile the translation catalogs ``.po`` into ``.mo`` message files:: @@ -136,12 +136,12 @@ django with transiflex. $ 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:: From 5c8baf83669c4eb71550e1fb5c0a96deda668ead Mon Sep 17 00:00:00 2001 From: Emad Rad Date: Thu, 1 Aug 2024 11:40:31 +0330 Subject: [PATCH 3/6] chore: code-block added This will add a copy button + syntax highlighting in GitHub. --- .../{{cookiecutter.repo_name}}/README.rst | 40 +++++++++++++------ 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/cookiecutter-xblock/{{cookiecutter.repo_name}}/README.rst b/cookiecutter-xblock/{{cookiecutter.repo_name}}/README.rst index 2159240b..879b7af8 100644 --- a/cookiecutter-xblock/{{cookiecutter.repo_name}}/README.rst +++ b/cookiecutter-xblock/{{cookiecutter.repo_name}}/README.rst @@ -5,9 +5,12 @@ 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 @@ -35,8 +38,9 @@ The general steps to provide multilingual messages for a Python program (or an X 1. Mark translatable strings ============================ -Mark translatable strings in python:: +Mark translatable strings in python: +.. code-block:: python from django.utils.translation import ugettext as _ @@ -46,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."); @@ -64,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``. @@ -110,9 +116,11 @@ django with transiflex. ------------------------ 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 `_). @@ -121,7 +129,9 @@ After compiling the ``.po`` file(s), ``django-statici18n`` is used to create lan To upload translations to transiflex use the follow Make target:: - $ make push_translations +.. code-block:: bash + + make push_translations See `config instructions `_ for information on how to set up your transifex credentials. @@ -131,9 +141,11 @@ 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 ======================================= @@ -143,9 +155,11 @@ Django will automatically use ``gettext`` and the compiled translations to trans 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 `_ From c07b2e41c999edbba15e35f06017f79e7f410a22 Mon Sep 17 00:00:00 2001 From: Emad Rad Date: Thu, 1 Aug 2024 11:41:01 +0330 Subject: [PATCH 4/6] chore: typo fixed transiflex -> transifex --- .../{{cookiecutter.repo_name}}/db_keyword_overrides.yml | 2 +- cookiecutter-xblock/{{cookiecutter.repo_name}}/README.rst | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) 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-xblock/{{cookiecutter.repo_name}}/README.rst b/cookiecutter-xblock/{{cookiecutter.repo_name}}/README.rst index 879b7af8..4d5a4a89 100644 --- a/cookiecutter-xblock/{{cookiecutter.repo_name}}/README.rst +++ b/cookiecutter-xblock/{{cookiecutter.repo_name}}/README.rst @@ -110,7 +110,7 @@ See `config instructions `_ for more details about integrating -django with transiflex. +django with transifex. 3.2 Compile translations ------------------------ @@ -127,7 +127,7 @@ The previous command will compile ``.po`` files using 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:: +To upload translations to transifex use the follow Make target: .. code-block:: bash @@ -137,7 +137,7 @@ See `config instructions `_ for more details about integrating -django with transiflex. +django with transifex. **Note:** The ``dev.run`` make target will automatically compile any translations. From 7864f088c613d7d0518f7ee7ef2c2b9bd4d996c8 Mon Sep 17 00:00:00 2001 From: Emad Rad Date: Sat, 3 Aug 2024 18:36:05 +0330 Subject: [PATCH 5/6] fix: old links with 404 status updated --- cookiecutter-xblock/{{cookiecutter.repo_name}}/README.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cookiecutter-xblock/{{cookiecutter.repo_name}}/README.rst b/cookiecutter-xblock/{{cookiecutter.repo_name}}/README.rst index 4d5a4a89..6588afdc 100644 --- a/cookiecutter-xblock/{{cookiecutter.repo_name}}/README.rst +++ b/cookiecutter-xblock/{{cookiecutter.repo_name}}/README.rst @@ -22,9 +22,9 @@ 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. @@ -109,8 +109,8 @@ 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 transifex. +See `Enabling Translations on a New Repo `_ +for more details about integrating django with transifex. 3.2 Compile translations ------------------------ From 6e6ea4421bad39c16db23cb6ca334bce754ab00b Mon Sep 17 00:00:00 2001 From: Emad Rad Date: Sun, 15 Sep 2024 15:59:51 +0330 Subject: [PATCH 6/6] chore: push_translations no longer exists as of OEP-58 --- .../{{cookiecutter.repo_name}}/Makefile | 5 +---- .../docs/internationalization.rst | 2 -- .../{{cookiecutter.repo_name}}/Makefile | 5 +---- .../docs/internationalization.rst | 2 -- .../{{cookiecutter.repo_name}}/Makefile | 5 +---- .../{{cookiecutter.repo_name}}/README.rst | 12 ------------ .../docs/internationalization.rst | 2 -- 7 files changed, 3 insertions(+), 30 deletions(-) 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}}/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 6588afdc..b452e774 100644 --- a/cookiecutter-xblock/{{cookiecutter.repo_name}}/README.rst +++ b/cookiecutter-xblock/{{cookiecutter.repo_name}}/README.rst @@ -127,18 +127,6 @@ The previous command will compile ``.po`` files using 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 transifex use the follow Make target: - -.. code-block:: bash - - 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 transifex. - **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: 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 *****************