docs(i18n): note locale/*.po are git-ignored (generated by az_locale)

Reflects the switch to untracking az.po/ru.po: they're overwritten by
setup_locale on every migrate, so they're gitignored now (main.pot stays
tracked). Also documents the targeted per-app compile and the _(VAR)/session-
language gotchas.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ali 2026-07-21 10:43:07 +00:00
parent 47f57d5bb9
commit 09c1036db9
1 changed files with 6 additions and 2 deletions

View File

@ -72,12 +72,16 @@ Configured tools: `ruff`, `eslint`, `prettier`, `pyupgrade`.
Translations live in **gettext PO files** under `jey_wizard/locale/` (`main.pot` is the extracted template; `az.po` / `ru.po` carry the strings). The legacy `translations/*.csv` are gone — Frappe v16 still reads CSV, but PO/MO is the modern path and overrides it.
**Source of truth is the `az_locale` app, not this repo.** `az_locale/locale/translations_az/jey_wizard/az.po` and `translations_ru/jey_wizard/ru.po` are the masters. On every `bench migrate`, `az_locale`'s `after_migrate``setup_locale()` **copies those over `jey_wizard/locale/*.po` and force-compiles** the runtime `.mo` into `sites/assets/locale/<lang>/LC_MESSAGES/jey_wizard.mo`. So: edit the PO in `az_locale` (or here, then mirror to `az_locale`), never hand-edit the `.mo`. The copies committed in this repo are kept in sync but will be clobbered by `az_locale` on the next migrate.
**Source of truth is the `az_locale` app, not this repo.** `az_locale/locale/translations_az/jey_wizard/az.po` and `translations_ru/jey_wizard/ru.po` are the masters. On every `bench migrate`, `az_locale`'s `after_migrate``setup_locale()` **copies those over `jey_wizard/locale/*.po` and force-compiles** the runtime `.mo` into `sites/assets/locale/<lang>/LC_MESSAGES/jey_wizard.mo`. So: edit the PO in `az_locale` (or here, then mirror to `az_locale`), never hand-edit the `.mo`.
**`jey_wizard/locale/*.po` (az.po/ru.po) are git-ignored, not committed.** Because `setup_locale()` overwrites them on every migrate, tracking them dirtied the working tree and made `git pull` abort ("local changes would be overwritten by merge"). They're now untracked via `.gitignore` (`jey_wizard/locale/*.po`); only `main.pot` stays tracked. The on-disk copies still exist (regenerated each migrate) — just don't try to commit them, and don't rely on their git history. Same treatment is applied across the other az_locale-managed apps (invoice_az, taxes_az, kapital_bank, jey_theme, jey_erp).
Workflow to add/refresh strings:
1. `bench generate-pot-file --app jey_wizard` — re-extract `__()` (JS) + `_()` (Python) + DocType labels into `locale/main.pot`.
2. `bench update-po-files --app jey_wizard` — fold new msgids into `az.po` / `ru.po` (empty msgstr = falls back to the English source; fine for proper nouns like `IBAN`, `ƏMAS`, `Stores`).
3. Fill the empty `msgstr`, copy both PO into `az_locale`, then `bench migrate` (or run `az_locale.locale.setup_locale.setup_locale`) to compile + activate. `bench clear-cache` to drop the `merged_translations` Redis cache.
3. Fill the empty `msgstr`, copy both PO into `az_locale` (the masters), then compile + activate. Options: `bench migrate` / `az_locale.locale.setup_locale.setup_locale` recompiles **all** apps — but that also re-copies every app's masters, clobbering any *uncommitted* PO edits in other apps. To recompile just this app, run `bench --site <site> execute frappe.gettext.translate.compile_translations --kwargs "{'target_app': 'jey_wizard', 'force': True}"` (kwargs is eval'd as Python — use `True`, not `true`). Either way, `bench clear-cache` to drop the `merged_translations` Redis cache.
> `msgstr` referenced only via a Python constant (e.g. `_(SOME_VAR)`) is **not** extracted by `generate-pot-file` — add that msgid to the PO by hand. And server-side `_()` renders in the *session user's* language, so an `az` user sees Azerbaijani even when the site default is `en`.
Switching language on step 1 calls `frappe.desk.page.setup_wizard.setup_wizard.load_messages``get_messages_for_boot()``get_all_translations(lang)`, which merges every app's CSV **and** MO, so the new PO strings render after compile. The constructor does this automatically on boot if `frappe.boot.lang` differs from the default (`az`).