alex-poor opened a new pull request, #40679:
URL: https://github.com/apache/superset/pull/40679

   ### SUMMARY
   
   Revives **[SIP-161](https://github.com/apache/superset/issues/32854)** 
(Translating Superset asset metadata) with a focused, minimal-core 
implementation of the **read path**.
   
   Superset's built-in i18n (Flask-Babel/gettext) translates UI chrome but not 
user-authored content — chart names, dashboard titles, axis/metric labels. This 
PR lets a deployment localize that metadata so a chart named "Sales" can 
display as "Ventes" / "Hokohoko" per the viewer's locale, while the **canonical 
stored name is never changed**.
   
   **Design — aligned with the maintainer direction on the SIP** 
(mistercrunch/rusackas, Apr 2025): keep core minimal and push storage/authoring 
to deployments.
   
   - A configurable **`TRANSLATION_HOOK`** `(default_text, locale, **context) 
-> str | None` is the only integration point. Superset core **does not store 
translations** — the hook decides where they live (static map, external MT 
service, a table, `.po` catalogs, …).
   - A **`{{ i18n('...') }}` Jinja macro** lets templated fields opt in.
   - Gated by the **`ENABLE_I18N_ASSET_TRANSLATIONS`** feature flag **and** a 
multi-language `LANGUAGES` config, so single-language deployments pay zero cost.
   - The canonical text is always a safe fallback (missing/erroring hook → 
original text), and **edit flows always operate on the canonical name** — a 
translation can never be persisted over the real name.
   
   This is the read path only. Storage and an authoring UI are intentionally 
left out of core; a self-contained database-backed reference (table + hook + 
seeding) is provided under `examples/` to show end-to-end authoring without 
shipping it as a supported component.
   
   **Surfaces localized:** chart/dashboard lists & cards, dashboard view 
header, chart panel titles, home "Recents" cards, and `{{ i18n() }}`-wrapped 
templated fields.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   Verified locally end-to-end with a demo hook (en + Māori): list pages, 
cards, dashboard header, and chart panels display the localized name; edit 
modals/inline title editing show the canonical English name. _(Screenshots to 
be added.)_
   
   ### TESTING INSTRUCTIONS
   
   1. In `superset_config.py`:
      ```python
      FEATURE_FLAGS = {"ENABLE_I18N_ASSET_TRANSLATIONS": True}
      LANGUAGES = {"en": {"flag": "us", "name": "English"},
                   "fr": {"flag": "fr", "name": "French"}}
      def TRANSLATION_HOOK(default_text, locale, **kwargs):
          return {("fr", "Sales"): "Ventes"}.get((locale, default_text))
      ```
   2. Name a chart "Sales", switch language to French, and view the 
chart/dashboard lists, cards, and dashboard — the name displays as "Ventes".
   3. Open the chart's Properties modal — the Name field still shows "Sales" 
(canonical).
   4. Switch back to English — the name reverts.
   
   Automated: `pytest tests/unit_tests/utils/i18n_test.py` and the new 
`recent_activity` localization integration test in 
`tests/integration_tests/log_api_tests.py`; SliceHeader render tests cover the 
view-vs-edit behavior.
   
   ### ADDITIONAL INFORMATION
   
   - [x] Has associated issue: revives #32854 (SIP-161)
   - [x] Required feature flags: `ENABLE_I18N_ASSET_TRANSLATIONS`
   - [x] Changes UI
   - [ ] Includes DB Migration
   - [x] Introduces new feature or API
   - [ ] Removes existing feature or API
   
   Opened as a **draft to restart the SIP-161 discussion** with a concrete, 
reviewable read-path implementation. Storage/authoring deliberately deferred — 
feedback welcome on whether the hook contract is the right minimal-core surface.
   


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