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

   ### SUMMARY
   
   The "Datetime format" help in the dataset editor came from five `t()` calls 
and two links. Translators could not reorder the words around the links. One of 
the five msgids also kept the line breaks and indentation of the source file. 
All 29 non-English catalogs translate the first pieces, but only `de` 
translates the last one. Users of 28 languages see the help half in English. 
#45963 describes the problem.
   
   This PR makes the help one translatable sentence:
   
   - `DatasourceEditor.tsx` calls `t()` once. The two links are markdown links 
with named URL placeholders, for example `[ISO 8601](%(iso_url)s)`. 
`SafeMarkdown` renders the result. The URLs stay out of the msgid.
   - An `i18n:` translator note asks to keep the link syntax and both 
placeholders. It reaches `messages.pot` and every catalog as `#. i18n: …`.
   - The Python link moves from the Python 2 documentation to 
`https://docs.python.org/3/library/datetime.html#strftime-strptime-behavior`.
   - The English words stay the same. Only the structure changes, so the 
backticks around `epoch_s`, `epoch_ms` and `epoch_us` now render as code.
   
   `babel_update.sh` regenerated `messages.pot` and the 30 catalogs. The 
template gains the new msgid and loses the five old ones. The catalogs also 
gain 7 msgids that `messages.pot` already had on master, for example "Loading 
the view shared with you…".
   
   The second commit translates the new msgid into Spanish. The third commit 
adds a short rule to the developer how-to: keep a sentence in one `t()` call. 
The translation guide tells translators to keep the link syntax.
   
   Why `SafeMarkdown`: Superset has no component that puts React elements into 
a translated string. `SafeMarkdown` already renders markdown inside a tooltip 
in `WarningIconWithTooltip`. It sanitizes the result. Markdown link syntax is 
familiar to translators.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   Spanish UI, dataset editor, Columns tab, info icon of the "Datetime format" 
field. Master on the left, this branch on the right:
   
   `[upload datetime-format-description-es_3-side-by-side.png]`
   
   ### TESTING INSTRUCTIONS
   
   1. Build the frontend and compile the Spanish catalog: `npm run 
build-translation` in `superset-frontend`, then `pybabel compile --use-fuzzy -d 
superset/translations -l es`.
   2. Set `LANGUAGES` to include `es`, then switch the UI to Spanish.
   3. Open a chart, edit its dataset, open the Columns tab and expand a column.
   4. Hover the info icon next to «Formato de fecha y hora». The help is one 
Spanish sentence with two links.
   5. Switch to English and hover the icon again. The text matches the previous 
English text, and `epoch_s` renders as code.
   6. Run `npx jest 
src/components/Datasource/components/DatasourceEditor/tests/DatasourceEditorDatetimeFormat.test.tsx`
 in `superset-frontend`.
   
   The new Jest file has two tests. The first renders the editor and hovers the 
icon. It reads the sentence msgid from the `t()` calls and checks the whole 
rendered text, both link targets and the code elements. The second records 
every msgid the editor passes to `t()`. Exactly one must hold both 
placeholders, and none of the old fragments may remain. Against master's 
source, both tests fail. With the Python 2 link put back, or with plain text 
instead of `SafeMarkdown`, the first test fails. A wording change inside the 
sentence keeps both tests green.
   
   `npx jest src/components/Datasource` passes: 30 suites and 392 tests. A 
Playwright check in a production build passes in Spanish and in English: the 
text, both link targets and the code elements.
   
   Local check skipped: the related-tests step of my pre-push script. 
`DatasourceEditor.tsx` has 690 related Jest suites, more than the step's 
30-minute limit on my machine. A separate full run stopped at 214 suites when 
the machine ran low on memory. 202 passed, and the 12 timeouts passed when 
rerun alone. CI runs the full frontend suite on this PR.
   
   ### ADDITIONAL INFORMATION
   
   - [x] Has associated issue: Fixes #45963
   - [ ] 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
   
   The new msgid starts untranslated in every catalog except `es`. Until a 
language translates it, its users see the whole help in English instead of half 
of it. `check_translation_regression.py` reports no regression. Each catalog 
drops its entries for the old fragments: 4 in most catalogs and 5 in `de`, some 
of them fuzzy. No catalog gains a fuzzy entry.
   
   #45963 lists 14 more sentences that the code splits around a link. Several 
of those links open in a new tab, and `SafeMarkdown` drops the `target` 
attribute. This PR leaves them for a decision in the issue.
   
   #45958 changes the Spanish msgstr of the first old fragment. This PR removes 
that msgid. If #45958 merges first, I will regenerate the catalogs here with 
`babel_update.sh`.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
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]

Reply via email to