Commit Graph

13 Commits

Author SHA1 Message Date
Superset Dev
fe3fa946c4 fix(i18n): handle JSON-list plural responses from the model
A fresh test run on French exposed a real bug in _apply_translation:
when the model returns a JSON list for a plural entry (e.g.
["form0", "form1"], which is a valid representation since plural forms
are ordered), the previous code took the else branch and broadcast
str(list) — Python list-repr like ['form0', 'form1'] — to every plural
form. Both msgstr[0] and msgstr[1] ended up containing the same
literal Python list-repr string, breaking gettext lookups for that
entry. Spanish dodged it by chance (the model returned dicts that
time); the failure mode is reproducible on French.

Changes:
- Extract _apply_plural_translation helper. Handles dict, list,
  scalar, and non-JSON-string responses. List path distributes forms
  by index and repeats the last form if the model returned fewer
  forms than the language requires (better than leaving slots blank,
  which falls back to displaying the raw English msgid).
- The split also drops _apply_translation's cyclomatic complexity
  back below the C901 threshold.
- Adds 4 regression tests covering: list response, list response
  round-tripped through parse_response, list shorter than required
  forms (last-form-repeats), and empty list (falls back to raw-string
  broadcast).

Verified end-to-end on French: the previously-broken plural entry
"Added 1 new column to the virtual dataset" / "Added %s new columns
to the virtual dataset" now writes msgstr[0] and msgstr[1] correctly
on a fresh run.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-11 17:47:24 -07:00
Superset Dev
795d6e67df test(i18n): cover backfill_po + address review feedback
Addresses sadpandajoe's review on #39448:

1. Adds tests/unit_tests/scripts/translations/backfill_po_test.py with
   19 cases covering parse_response (singular/plural/markdown-fence
   stripping/non-ASCII/non-numeric keys/list-and-scalar rejection/JSON
   errors) and _apply_translation (singular path, plural-dict path,
   plural-scalar fallback, plural invalid-JSON fallback, fuzzy flag,
   attribution append/dedup, end-to-end round-trip from parse_response
   into _apply_translation). The script is loaded via importlib since
   it lives outside the package tree.

2. translate_batch now pipes the prompt over stdin instead of passing
   it as argv. With --batch-size 50 and many reference languages a
   single batch can grow into the tens of KB and approach ARG_MAX on
   some platforms; stdin removes that ceiling.

3. _process_batches now saves the catalog after each batch that wrote
   at least one translation (when not in --dry-run). For sparse
   languages with thousands of missing strings, a crash mid-run now
   only loses the in-flight batch rather than every batch translated
   so far. The full save at end of backfill() is removed since the
   per-batch save covers it.

4. Module docstring referenced --fuzzy/--no-fuzzy but argparse only
   registers --no-fuzzy; doc updated to match the actual flag.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-11 16:59:40 -07:00
Maxime Beauchemin
e51b95ffa8 chore: enforce more ruff rules (#31447)
Co-authored-by: Elizabeth Thompson <eschutho@gmail.com>
2024-12-18 17:41:34 -08:00
Maxime Beauchemin
e0deb704f9 feat: make ephemeral env use supersetbot + deprecate build_docker.py (#30870) 2024-11-22 14:19:08 -08:00
Maxime Beauchemin
2d63722150 chore: set up ruff as a new linter/formatter (#28158) 2024-04-24 17:19:53 -07:00
Jongwoo Han
234a139fb2 chore: Replace deprecated command with environment file (#27304) 2024-02-29 15:16:20 +00:00
lodu
9514300da5 fix(docker): *-dev tags target right stage from Dockerfile (#27116) 2024-02-14 16:58:47 -08:00
Maxime Beauchemin
13915bbb54 feat(docker): allow for docker release builds to be multi-platform (#27055) 2024-02-08 20:58:36 -08:00
Maxime Beauchemin
6b0d8ed265 feat: docker image tags documentation + tweaks (#26923)
Co-authored-by: Sam Firke <sfirke@users.noreply.github.com>
2024-02-01 18:04:23 -08:00
Maxime Beauchemin
4b77129cc9 fix(docker): improve docker tags to be cleared and avoid conflicts (#26787) 2024-01-30 23:03:25 -08:00
Evan Rusackas
785e832e8d chore(actions): generate FOSSA report on master, and ALWAYS check for… (#26857) 2024-01-29 16:18:50 -07:00
Maxime Beauchemin
363a8e6b07 build: Parallelize the CI image builds (continued) (#26698) 2024-01-23 13:44:07 -08:00
Elizabeth Thompson
26498fc099 chore: add latest-official docker tag (#25322) 2023-10-18 16:59:30 -07:00