AmoghAtreya opened a new pull request, #46049:
URL: https://github.com/apache/superset/pull/46049

   ### SUMMARY
   <!--- Describe the change below, including rationale and design decisions -->
   
   `ParameterErrorMessage` built its "Did you mean" line with a `tn()` plural 
whose singular and plural forms used different placeholders (`%(suggestion)s` 
and `%(firstSuggestions)s` / `%(lastSuggestion)s`). gettext requires every 
`msgstr[N]` to use the placeholders declared in `msgid_plural`, so translators 
fell into one of three outcomes:
   
   - 20 catalogs used `%(suggestion)s`. That's the natural choice, but `msgfmt 
--check` rejects it: fatal today in fr, it, pt and sl, and latent in the 16 
fuzzy catalogs.
   - 5 catalogs (lv, ru, sr, sr_Latn, uk) used `%(firstSuggestions)s 
%(lastSuggestion)s`. That passes the check, but renders a leading gap or a 
dangling "or" for a single suggestion.
   - 4 catalogs used `%(lastSuggestion)s` alone. That is valid and correct, but 
nothing in the source points to it.
   
   There was also a logic bug: `tn()` picks a form by the locale's plural 
rules, not by "one versus several" suggestions. In Russian, for example, 21 
suggestions select the singular form.
   
   **Changes**
   
   - Replace the `tn()` call with two `t()` messages, one for a single 
suggestion and one for several, chosen by `templateKeys.length === 1`. Each 
message declares only its own placeholders, so no translation can mismatch them.
   - Add `i18n:` translator comments explaining each placeholder. These are 
extracted into the `.pot` and every catalog.
   - Fix the English typo: `"%(undefinedParameter)s?"` becomes 
`"%(undefinedParameter)s"?`.
   - Migrate the existing translations into the two new entries in all 29 
catalogs instead of dropping them:
     - Single suggestion: the form each locale used for n=1, normalised to 
`%(suggestion)s`.
     - Several suggestions: the form each locale used for n=2.
     - Fuzzy flags are preserved.
     - The misplaced `?` is corrected where the catalog's own plural form 
showed the intended placement.
     - pt and pt_BR: the untranslated English "or" is replaced with "ou".
   - The new catalog entries match `babel_update.sh` output exactly, so the 
pot-drift check stays clean.
   
   **Known gaps**
   
   - ja, ko, th, tr, zh, zh_TW and nl never translated the several-suggestions 
form, so that message shows in English until the next backfill. Their 
single-suggestion translation is kept.
   - A few catalogs (ta, ko, th, nl, pt, pt_BR, cs, sk, uk) keep a `"X?"` quote 
placement copied from the old English string, because there was no in-catalog 
evidence of the intended form. Native reviewers can adjust these.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   <!--- Skip this if not applicable -->
   
   Single suggestion, rendered text:
   
   | Locale | Before | After |
   |---|---|---|
   | en | `"state" instead of "stat?"` | `"state" instead of "stat"?` |
   | ru | `␣или "state" вместо "stat"?` (dangling "or") | `"state" вместо 
"stat"?` |
   | lv | `␣"state" vietā "stat"?` (leading gap) | `"state" vietā "stat"?` |
   | fr | catalog fails `msgfmt --check` | `"state" au lieu de "stat"?` |
   
   ### TESTING INSTRUCTIONS
   <!--- Required! What steps can be taken to manually verify the changes? -->
   
   1. Run the unit tests:
      ```bash
      npm run test -- src/components/ErrorMessage/ParameterErrorMessage.test.tsx
      ```
   2. Validate the catalogs, including fuzzy entries. None should report an 
error on this message, and the previously failing fr, it, pt and sl catalogs 
now pass:
      ```bash
      for f in superset/translations/*/LC_MESSAGES/messages.po; do
        msgfmt --check --use-fuzzy -o /dev/null "$f"
      done
      ```
   3. Confirm extraction is stable: run 
`./scripts/translations/babel_update.sh` and check that the suggestion entries 
are unchanged.
   4. Manually: in SQL Lab, with template parameters `{"state": "CA"}`, run 
`SELECT '{{ stat }}'`, open "See more", and check the suggestion line in 
English and in a translated locale such as ru or fr.
   
   ### ADDITIONAL INFORMATION
   <!--- Check any relevant boxes with "x" -->
   <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
   - [x] Has associated issue: Fixes #45988
   - [ ] Required feature flags:
   - [x] Changes UI
   - [ ] Includes DB Migration (follow approval process in 
[SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

  • [PR] fix(i1... AmoghAtreya (via GitHub) via notifications
    • Re: [P... codecov[bot] (via GitHub) via notifications
    • Re: [P... AmoghAtreya (via GitHub) via notifications
    • Re: [P... codeant-ai-for-open-source[bot] (via GitHub) via notifications
    • Re: [P... netlify[bot] (via GitHub) via notifications

Reply via email to