diff --git a/Makefile b/Makefile index cef3349..8f01d51 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,6 @@ REPO_ROOT := $(shell pwd) SRC_DIRECTORY := src EXTRACT_DIR := conf/locale/en/LC_MESSAGES -COMBINED_LOCALE_DIR := conf/locale/en/LC_MESSAGES # XBlock directories XBLOCKS=$(shell find $(REPO_ROOT)/$(SRC_DIRECTORY) -mindepth 2 -maxdepth 2 -type d -name 'conf' -exec dirname {} \;) @@ -46,17 +45,19 @@ clean: ## Clean build artifacts ## Localization targets extract_translations: ## extract strings to be translated, outputting .po files under /conf/locale/ - @for xblock in $(XBLOCKS); do \ + @set -e; for xblock in $(XBLOCKS); do \ module_name=$$(basename $$xblock); \ echo "Extracting translations for $$module_name..."; \ - cd $$xblock && i18n_tool extract --no-segment; \ + cd $$xblock; \ + i18n_tool extract --no-segment; \ if [ -f $$xblock/$(EXTRACT_DIR)/djangojs.po ]; then \ msgcat $$xblock/$(EXTRACT_DIR)/django.po $$xblock/$(EXTRACT_DIR)/djangojs.po \ - -o $$xblock/$(EXTRACT_DIR)/django.po && rm -f $$xblock/$(EXTRACT_DIR)/djangojs.po; \ + -o $$xblock/$(EXTRACT_DIR)/django.po; \ + rm -f $$xblock/$(EXTRACT_DIR)/djangojs.po; \ fi; \ mkdir -p $(REPO_ROOT)/$$module_name/$(EXTRACT_DIR); \ if [ -f $$xblock/$(EXTRACT_DIR)/django.po ]; then \ - mv $$xblock/$(EXTRACT_DIR)/django.po $(REPO_ROOT)/$$module_name/$(EXTRACT_DIR)/django.po; \ + mv $$xblock/$(EXTRACT_DIR)/django.po $(REPO_ROOT)/$$module_name/$(EXTRACT_DIR)/django.po; \ fi; \ done diff --git a/README.md b/README.md index dfdfef6..4a0065a 100644 --- a/README.md +++ b/README.md @@ -67,8 +67,12 @@ Localization (l10n) is adapting a program to local language and cultural habits. This project follows [OEP-58](https://docs.openedx.org/en/latest/developers/concepts/oep58.html) for centralized translation management via the [openedx-translations](https://github.com/openedx/openedx-translations) repository. -The daily extraction workflow in openedx-translations clones this repo, runs `make extract_translations`, and pushes -the combined source `.po` file to Transifex for the translation community to translate. +The daily extraction workflow in openedx-translations clones this repo, runs `make extract_translations`, and commits +each XBlock's source `.po` file under `translations/xblocks-extra//conf/locale/`. Each XBlock is a +separate Transifex resource. + +Open edX pulls the translations from openedx-translations with `atlas` +(`make pull_xblock_translations` in openedx-platform). ### Prerequisites @@ -77,52 +81,34 @@ the combined source `.po` file to Transifex for the translation community to tra ### Translation Workflow -1. **Mark translatable strings** in Python and JavaScript using `gettext` / `ugettext`. +1. **Mark translatable strings** in Python and JavaScript using `gettext`. 2. **Extract** source strings: `make extract_translations` -3. **Compile** translations: `make compile_translations` ### Make Targets | Target | Description | |--------|-------------| -| `extract_translations` | Extract translatable strings from all XBlocks into per-xblock `text.po` files, then merge into a combined `conf/locale/en/LC_MESSAGES/django.po` for OEP-58 | -| `compile_translations` | Compile `.po` files into `.mo` message files for each XBlock | -| `dummy_translations` | Generate dummy (Esperanto) `.po` files for testing | -| `build_dummy_translations` | Extract, generate dummy, and compile translations | -| `validate_translations` | Build dummy translations and detect changed source files | -| `detect_changed_source_translations` | Check if source `.po` files are up-to-date | -| `pull_translations` | Pull translations from Transifex | -| `push_translations` | Extract and push source translations to Transifex | -| `install_transifex_client` | Install the Transifex CLI client | +| `extract_translations` | Extract translatable strings into `/conf/locale/` for each XBlock | ### How It Works -Each XBlock in `src/` has its own `conf/locale/` directory with a `config.yaml` and `.tx/config`. -During extraction: +Each XBlock in `src/` has its own `conf/locale/config.yaml`. During extraction: 1. `i18n_tool extract` runs in each XBlock directory, producing `django.po` (and optionally `djangojs.po`). 2. If `djangojs.po` exists, it is merged into `django.po` using `msgcat`. -3. The merged file is renamed to `text.po`. -4. All per-xblock `text.po` files are combined via `msgcat --use-first` into a single - `conf/locale/en/LC_MESSAGES/django.po` at the repository root for the openedx-translations pipeline. +3. The result is moved to `/conf/locale/en/LC_MESSAGES/django.po` at the repository root. ### Verifying Translations ```bash -# Dry-run extraction +# Extract the source strings make extract_translations -# Check the combined output -cat conf/locale/en/LC_MESSAGES/django.po - -# Build and test with dummy translations -make build_dummy_translations - -# Verify Transifex config (requires tx CLI) -cd src/ && tx status +# Check the output for one XBlock +cat feedback/conf/locale/en/LC_MESSAGES/django.po ``` -> **Note:** The `.gitignore` ignores `*.po` and `*.mo` files. This is expected — translation source +> **Note:** The `.gitignore` ignores the extracted `.po` files. This is expected — translation source > files are managed in the [openedx-translations](https://github.com/openedx/openedx-translations) > repository, not committed here. diff --git a/docs/how-tos/internationalization.rst b/docs/how-tos/internationalization.rst index bdac53c..babe593 100644 --- a/docs/how-tos/internationalization.rst +++ b/docs/how-tos/internationalization.rst @@ -19,8 +19,11 @@ This project follows `OEP-58`_ for centralized translation management. Translati 1. Clones this repository 2. Runs ``make extract_translations`` to extract translatable strings -3. Commits the combined source ``.po`` file -4. The Transifex GitHub App syncs the file to Transifex for the translation community +3. Commits each XBlock's source ``.po`` file under ``translations/xblocks-extra//conf/locale/`` +4. The Transifex GitHub App syncs the files to Transifex for the translation community + +Open edX pulls the translations from openedx-translations with ``atlas`` +(``make pull_xblock_translations`` in openedx-platform). .. _OEP-58: https://docs.openedx.org/en/latest/developers/concepts/oep58.html .. _openedx-translations: https://github.com/openedx/openedx-translations @@ -28,32 +31,28 @@ This project follows `OEP-58`_ for centralized translation management. Translati Project Structure ***************** -Each XBlock in ``src/`` has its own locale configuration:: +Each XBlock in ``src/`` has its own locale configuration, and ``make extract_translations`` writes each +XBlock's source strings to ``/conf/locale/`` at the repository root:: src/ ├── audio/ - │ ├── conf/ - │ │ └── locale/ - │ │ ├── config.yaml # i18n-tools configuration - │ │ └── en/LC_MESSAGES/ - │ │ └── text.po # Per-xblock extracted strings - │ └── .tx/ - │ └── config # Transifex resource mapping - ├── feedback/ - │ ├── conf/locale/... - │ └── .tx/config + │ └── conf/ + │ └── locale/ + │ └── config.yaml # i18n-tools configuration + ├── feedback/conf/locale/... + ├── freetextresponse/conf/locale/... ├── imagemodal/... ├── qualtricssurvey/... ├── sql_grader/... └── submit_and_compare/... - conf/ # Repository root - └── locale/ - └── en/LC_MESSAGES/ - └── django.po # Combined file for OEP-58 pipeline - -The combined ``conf/locale/en/LC_MESSAGES/django.po`` at the repository root is what the openedx-translations -pipeline uses. It is generated by merging all per-xblock ``text.po`` files using ``msgcat --use-first``. + audio/ # Repository root, generated by extraction + └── conf/ + └── locale/ + └── en/LC_MESSAGES/ + └── django.po # Source strings for the OEP-58 pipeline + feedback/conf/locale/... + ... Marking Translatable Strings ***************************** @@ -83,52 +82,20 @@ Make Targets * - Target - Description * - ``extract_translations`` - - Extract translatable strings from all XBlocks, merge JS strings into Python catalog, - rename to ``text.po``, then combine all into ``conf/locale/en/LC_MESSAGES/django.po`` - * - ``compile_translations`` - - Compile ``.po`` files into ``.mo`` message files for each XBlock - * - ``dummy_translations`` - - Generate dummy (Esperanto) ``.po`` files for visual testing - * - ``build_dummy_translations`` - - Extract, generate dummy, and compile translations in one step - * - ``validate_translations`` - - Build dummy translations and detect changed source files - * - ``detect_changed_source_translations`` - - Check if source ``.po`` files are up-to-date - * - ``pull_translations`` - - Pull translations from Transifex for each XBlock - * - ``push_translations`` - - Extract and push source translation files to Transifex - * - ``install_transifex_client`` - - Install the Transifex CLI client + - Extract translatable strings from all XBlocks, merge JS strings into the Python catalog, + and move each result to ``/conf/locale/en/LC_MESSAGES/django.po`` Verifying Translations Locally ******************************* -Extract and compile:: +Extract the source strings:: $ make extract_translations - $ make compile_translations - -Check the combined output:: - - $ cat conf/locale/en/LC_MESSAGES/django.po - -Build and test with dummy translations:: - - $ make build_dummy_translations - -Verify Transifex configuration (requires ``tx`` CLI):: - - $ cd src/ && tx status - -Troubleshooting -*************** -If there are any errors compiling ``.po`` files, run the following command to validate:: +Check the output for one XBlock:: - $ make validate_translations + $ cat feedback/conf/locale/en/LC_MESSAGES/django.po -**Note:** The ``.gitignore`` ignores ``*.po`` and ``*.mo`` files. This is expected — translation source +**Note:** The ``.gitignore`` ignores the extracted ``.po`` files. This is expected — translation source files are managed in the `openedx-translations`_ repository, not committed here. The openedx-translations workflow uses ``git add -f`` to force-add the files to its own repository. diff --git a/src/freetextresponse/conf/locale/config.yaml b/src/freetextresponse/conf/locale/config.yaml index cbc5564..a968d94 100644 --- a/src/freetextresponse/conf/locale/config.yaml +++ b/src/freetextresponse/conf/locale/config.yaml @@ -2,7 +2,3 @@ locales: - en # English - Source Language - -# The locales used for fake-accented English, for testing. -dummy_locales: - - eo # Esperanto