Skip to content

Commit

Permalink
Merge pull request #475 from CodeWithEmad/fix/readme
Browse files Browse the repository at this point in the history
Fix: Readme
  • Loading branch information
feanil authored Nov 4, 2024
2 parents 4128161 + 6e6ea44 commit 26118b9
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 56 deletions.
5 changes: 1 addition & 4 deletions cookiecutter-django-app/{{cookiecutter.repo_name}}/Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
*****************
Expand Down
5 changes: 1 addition & 4 deletions cookiecutter-django-ida/{{cookiecutter.repo_name}}/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
*****************
Expand Down
5 changes: 1 addition & 4 deletions cookiecutter-xblock/{{cookiecutter.repo_name}}/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Expand Down Expand Up @@ -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.
Expand Down
75 changes: 39 additions & 36 deletions cookiecutter-xblock/{{cookiecutter.repo_name}}/README.rst
Original file line number Diff line number Diff line change
@@ -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 <https://edx.readthedocs.org/projects/xblock-tutorial/en/latest/edx_platform/edx_lms.html>`_.
`Enabling Translations on a New Repo <https://docs.openedx.org/en/latest/developers/how-tos/enable-translations-new-repo.html>`_.

This cookiecutter template uses `django-statici18n <https://django-statici18n.readthedocs.io/en/latest/>`_
This cookiecutter template uses `django-statici18n <https://django-statici18n.readthedocs.io/>`_
to provide translations to static javascript using ``gettext``.

The included Makefile contains targets for extracting, compiling and validating translatable strings.
Expand All @@ -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 _
Expand All @@ -45,8 +50,9 @@ Mark translatable strings in python::
See `edx-developer-guide <https://edx.readthedocs.io/projects/edx-developer-guide/en/latest/internationalization/i18n.html#python-source-code>`__
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.");
Expand All @@ -55,18 +61,19 @@ See `edx-developer-guide <https://edx.readthedocs.io/projects/edx-developer-guid
for more information.

2. Run i18n tools to create Raw message catalogs
=================================================
================================================

This cookiecutter template offers multiple make targets which are shortcuts to
use `edx-i18n-tools <https://github.com/openedx/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 <https://www.gnu.org/software/gettext/manual/html_node/PO-Files.html>`_.
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``.
Expand All @@ -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).
Expand All @@ -102,49 +109,45 @@ To use translations from transifex use the follow Make target to pull translatio
See `config instructions <https://github.com/openedx/i18n-tools#transifex-commands>`_ for information on how to set up your
transifex credentials.

See `transifex documentation <https://docs.transifex.com/integrations/django>`_ for more details about integrating
django with transiflex.
See `Enabling Translations on a New Repo <https://docs.openedx.org/en/latest/developers/how-tos/enable-translations-new-repo.html>`_
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 <https://docs.djangoproject.com/en/3.2/topics/i18n/translation/#compiling-message-files>`_).
After compiling the ``.po`` file(s), ``django-statici18n`` is used to create language specific catalogs. See
``django-statici18n`` `documentation <https://django-statici18n.readthedocs.io/en/latest/>`_ for more information.

To upload translations to transiflex use the follow Make target::

$ make push_translations

See `config instructions <https://github.com/openedx/i18n-tools#transifex-commands>`_ for information on how to set up your
transifex credentials.

See `transifex documentation <https://docs.transifex.com/integrations/django>`_ 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
<https://docs.djangoproject.com/en/3.2/topics/i18n/translation/#troubleshooting-gettext-incorrectly-detects-python-format-in-strings-with-percent-signs>`_
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{{cookiecutter.project_name}}
#############################
{%- set heading_underline_length = (cookiecutter.project_name | length) %}
{{ '#' * heading_underline_length }}

.. note::

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
*****************
Expand Down

0 comments on commit 26118b9

Please sign in to comment.