|
| 1 | +# AI-Assisted Spanish Translation Rules |
| 2 | + |
| 3 | +This document defines the current rules for AI-assisted Spanish localization in `superdesk-client-core`. |
| 4 | + |
| 5 | +## 1. Scope |
| 6 | + |
| 7 | +- Source of truth for new and changed strings is `po/superdesk.pot`. |
| 8 | +- Initial write target is `po/es.po` only. |
| 9 | +- Do not modify runtime JSON files directly. |
| 10 | +- Run `npm run gettext-update-po -- es` before asking AI to translate. |
| 11 | +- Do not change extraction, compile, or validation tooling. |
| 12 | +- Existing compile and validation steps remain the final safety net. |
| 13 | + |
| 14 | +## 2. Translation Rules |
| 15 | + |
| 16 | +- Translate only entries that exist in `po/superdesk.pot`. |
| 17 | +- Update only matching entries in `po/es.po`. |
| 18 | +- Let the sync step add or remove catalog entries structurally. |
| 19 | +- Never modify `msgid`. |
| 20 | +- Never rewrite unrelated entries. |
| 21 | +- Do not overwrite existing non-empty Spanish translations. |
| 22 | +- Only fill empty Spanish translations that are safe and clear. |
| 23 | +- Keep wording neutral Spanish unless the source clearly requires a specific term. |
| 24 | +- Keep diffs minimal and easy to review. |
| 25 | + |
| 26 | +## 3. Placeholder Preservation Rules |
| 27 | + |
| 28 | +- Preserve all `{{...}}` placeholders exactly as they appear in the source. |
| 29 | +- Preserve placeholder spacing exactly, including forms like `{{name}}`, `{{ name }}`, `{{ $count}}`, and nested expressions such as `{{user.full_name}}`. |
| 30 | +- Do not translate, rename, reorder, add, or remove placeholders. |
| 31 | +- Preserve plural structures exactly: `msgid`, `msgid_plural`, and every `msgstr[n]` slot required by the target entry. |
| 32 | +- Never collapse plural entries into singular entries or vice versa. |
| 33 | +- Preserve inline markup and escaped characters exactly when translating around them. |
| 34 | + |
| 35 | +## 4. Skip Conditions |
| 36 | + |
| 37 | +Skip an entry if any of the following is true: |
| 38 | + |
| 39 | +- The entry already has a non-empty `msgstr` or plural `msgstr[n]`. |
| 40 | +- The entry is HTML-heavy or contains markup that makes safe translation unclear. |
| 41 | +- The meaning is ambiguous without product or UI context. |
| 42 | +- The entry contains unsafe or unclear placeholder usage. |
| 43 | +- The entry has unusual formatting, broken source text, or translator notes suggesting manual review is safer. |
| 44 | +- The entry would require changing anything outside the exact target message block. |
| 45 | + |
| 46 | +When skipping, leave the entry unchanged. |
| 47 | + |
| 48 | +## 5. Validation Steps |
| 49 | + |
| 50 | +After preparing changes: |
| 51 | + |
| 52 | +1. Refresh the template with `npm run gettext-extract`. |
| 53 | +2. Sync the Spanish catalog with `npm run gettext-update-po -- es`. |
| 54 | +3. Ensure AI changes are limited to translation content in `po/es.po`. |
| 55 | +4. Ensure `msgid` values are untouched. |
| 56 | +5. Ensure placeholders and plural structures still match the source exactly. |
| 57 | +6. Run the existing compile/validation flow so current tooling can reject invalid placeholder changes: |
| 58 | + |
| 59 | +```bash |
| 60 | +npm run gettext-extract |
| 61 | +npm run gettext-update-po -- es |
| 62 | +grunt nggettext_compile |
| 63 | +``` |
| 64 | + |
| 65 | +If a broader build check is needed, use the normal project build flow instead of editing generated JSON by hand. |
| 66 | + |
| 67 | +## 6. Definition Of Done |
| 68 | + |
| 69 | +The translation step is done when: |
| 70 | + |
| 71 | +- `po/superdesk.pot` has been refreshed from source. |
| 72 | +- `po/es.po` has been structurally synced from the POT via `npm run gettext-update-po -- es`. |
| 73 | +- Only safe, empty Spanish entries in `po/es.po` were filled by the AI step. |
| 74 | +- Runtime JSON files were not modified. |
| 75 | +- No existing non-empty Spanish translations were overwritten. |
| 76 | +- All placeholders, plural forms, and source identifiers were preserved exactly. |
| 77 | +- The diff is small, targeted, and reviewable. |
| 78 | +- Existing compile/validation tooling passes or remains the final blocker for anything invalid. |
0 commit comments