--- name: skill-doli-translation description: "Use when asking question on translation or synchronizing translations with Transifex (running the scripts dev/translation/txpull.sh and dev/translation/txpush.sh). Explains the Transifex workflow: en_US is the only editable source, all other locales are pulled from Transifex." license: MIT user-invocable: true allowed-tools: - read_file - write_file - bash - grep --- # Translations management with Transifex ## Golden rule - **Only the `en_US` language files are edited by hand**: For the core project: `htdocs/langs/en_US/*.lang` - For external modules: `htdocs//langs/en_US/*.lang`. - All other locales (`fr_FR`, `de_DE`, ...) are **never edited manually** in this repository. They are produced and synchronized by Transifex (external tool). This is the rule stated in the project AGENTS.md ("Internationalisation" section) and it overrides any request to "also add the French translation". - When a new key is needed: 1. Add it only to `htdocs//langs/en_US/.lang` (PascalCase key names, `Key=English value`). 2. Push the source to Transifex with `txpush.sh` (translators translate it there). 3. Pull the translated key back into the locale files with `txpull.sh`. - If a French/other-locale string is needed immediately before a pull, it is acceptable to add it manually, but be aware that the next Transifex pull may overwrite it — the authoritative flow remains push/pull. ## Transifex project layout - Organization / project / resources are defined in `.tx/config` at the repository root. - Organization: Defined after the `[o:`, project: defined after the `:p:`. - One resource per `.lang` file: `r:admin`, `r:cabinetmed`, etc. - For each resource: - `source_file = htdocs//langs/en_US/.lang` (the reference language) - `file_filter = htdocs//langs//.lang` (where translated files are written) - `type = MOZILLAPROPERTIES` (the .lang format `key=value`) - The scripts refuse to run if `.tx/` does not exist at the repository root (they assume the root as working directory). - **Resource slug rule (before any `-r` option)**: the full resource slug is `.` where `` is the value after `:p:` and `` the value after `r:` in `.tx/config` — NOT the module name. - Always read `.tx/config` (or run `tx status`) to get the exact slug before pushing or pulling a single resource. The tx client (v1.6.x) exits with code 1 and prints NO error message when the slug is unknown, so a wrong slug fails silently. - Transifex client installation / update (see `dev/translation/README`): `sudo pip install --upgrade transifex-client` - The direct transifex URL to make translations is: https://app.transifex.com///translate/ ## dev/translation/txpush.sh — push local files to Transifex Usage (from the repository root): ``` ./dev/translation/txpush.sh (source|xx_XX) [-r projectname.] [-f] [--no-interactive] ``` - `txpush.sh source` → runs `tx push -s`: pushes the en_US source files to Transifex. **This is the command to run after editing en_US files.** - `txpush.sh fr_FR` (or any `xx_XX`) → loops over `htdocs//langs/xx_XX/*.lang` and runs `tx push --skip -r projectname. -t -l xx_XX` for each: pushes a local translation file into Transifex as a translation. Only used to feed Transifex with a locally-corrected translation. - A local translation file is skipped if the Transifex side is newer. `-f` forces the overwrite of the translation on Transifex (but not the translation memory). - `-r projectname.` limits the push to one resource, e.g. `-r projectname.myfile`. ## dev/translation/txpull.sh — pull translated files from Transifex Usage (from the repository root): ``` ./dev/translation/txpull.sh (all|xx_XX) [-r projectname.] [-f] [-s] ``` - `txpull.sh all` → loops over every directory in `htdocs//langs/*` except `en_US` and runs `tx pull -l ` for each: downloads all translated files from Transifex into the local tree. - `txpull.sh fr_FR` (or any `xx_XX`) → `tx pull -l xx_XX`: downloads only that language. - A local file is skipped if the local copy is newer than the Transifex one. `-f` forces the local file to be overwritten (does not work with `all`). - `-r projectname.` limits the pull to one resource. - The script ends by reminding to also run: `dev/tools/fixaltlanguages.sh fix all` (see below). ## Check that translations do not contain the keyword "notranslate" After a pull, check that no translated value contains the keyword `notranslate` (it must never be part of a translation): ``` grep -rn "notranslate" htdocs/langs/ --include=*.lang | grep -v "/en_US/" ``` or for an external module ``` grep -rn "notranslate" htdocs//langs/ --include=*.lang | grep -v "/en_US/" ``` - Such translations must not be fixed in the local files (they would be overwritten by the next pull) but on Transifex. - For each language `ll_CC` found (e.g. `fr_FR`), the following link opens the Transifex page listing the translations to fix: - Link with the source text: `https://app.transifex.com///translate/#ll_CC/$?q=text%3ASourceTextToSearch` - Link with the translated text: `https://app.transifex.com///translate/#ll_CC/$?q=translation_text%3ATranslatedTextToSearch` - Link with the translation key: `https://app.transifex.com///translate/#ll_CC/$?q=key%3ATranslationText` - Link to non translated keys: `https://app.transifex.com///translate/#ll_CC/$?q=translated%3Ano` - Once fixed on Transifex, pull the language again with `txpull.sh ll_CC`. ## Complete workflow for a new translation key Example: add the key `DossierMedical=Dossier médical` feature string. 1. Add the English key to `htdocs//langs/en_US/.lang`. 2. Commit/push the en_US change following the project git workflow. 3. Run `./dev/translation/txpush.sh source -r projectname.modulename` (or without `-r` for all files). 4. Wait for translators (or the translation memory) to translate it on Transifex. 5. Run `./dev/translation/txpull.sh fr_FR` (or `all`) to get the translated files. 6. Run `dev/tools/fixaltlanguages.sh fix all` to deduplicate entries that already exist in the parent language file. 7. Check that no translation contains the keyword `notranslate` (see above) and fix them on Transifex if any. ## Related tools in dev/translation/ - `README` — installation of the Transifex client (`transifex-client` pip package). - `strip_language_file.php [file.lang|all]` — strips from a secondary language file the entries redundant with its primary file (run from `htdocs/langs`). - `sanity_check_en_langfiles.php` — HTML report checking the en_US language files. - `autotranslator.php` — automatic translation helper. - `fixaltlanguages.sh (list|fix) [ll_CC]` — deduplicates alternate language files (xx_YY) with their parent (xx_XX) across all modules; recommended by txpull.sh after each pull. This script is NOT into dev/translation/ but into dev/tools/. In this repository run `./dev/tools/fixaltlanguages.sh fix` from the root (it calls `strip_language_file.php`, which accepts module-relative lang dir paths). Note: the `[ll_CC]` argument is currently ignored, the script always processes all languages. - `dev/tools/fixduplicatelangkey.sh` — removes duplicate keys inside language files. ## Dolibarr i18n reminders (apply when writing keys) - Keys use PascalCase (`MyModuleLabel`), values are English text. - `$langs->trans('Key')` for direct HTML output, `$langs->transnoentities('Key')` when the result feeds an escaping/encoding function (PDF, emails). - Language file loaded with `$langs->loadLangs(array("main", "cabinetmed@cabinetmed"))`. - No hardcoded user-facing strings in PHP — always a trans key. - Locale files other than en_US must keep `CHARSET=UTF-8` on their first line.