villebro commented on issue #13442:
URL: https://github.com/apache/superset/issues/13442#issuecomment-829789084


   This is a use case I have personally seen needed multiple times, and one 
that I could see being beneficial in environments where the same official truth 
needs to be made available to stakeholders using different languages. To give 
an example, all main EU regulation is required to be made available in [24 
officially supported European 
languages](https://europa.eu/european-union/about-eu/eu-languages_en) (check 
the top right hand corner): 
https://europa.eu/european-union/law/legal-acts_en#directives . If the EU were 
ever to add proper visualizations to their reporting (one can always dream..), 
they would likely need a feature like this to ensure that only one copy of each 
dashboard/chart needs to be maintained.
   
   One option would be to not change the metadata db schema and just Rison 
encode i18n strings where needed. For example, if we have a Metric called 
"Cars" and wanted to add a few optional translations to it. In this case we 
could replace the Metric name "Cars" with the string 
`(default:en,en:Cars,fi:Autoja,se:Bilar)`, which in JSON is equivalent to
   ```json
   {
     "default": "en",
     "en": "Cars",
     "fi": "Autoja",
     "se": "Bilar"
   }
   ```
   When rendering the chart we would then just check if the metric name is a 
regular string or Rison parseable:
   1) if it's a regular string, do nothing (current behavior)
   2) if it parses, we'd check the selected language and pick the correct 
version, and in this case fall back to the English version if the chosen 
language is not supported.
   
   To give proper native support for this introducing a new React component for 
the i18n input would be created (like in the original proposal), which would 
make it as uninvasive as possible to give an untranslated value at first, but 
then add additional languages where needed. This component could work something 
like this:
   - when entering an untranslated value, a greyed out localization icon would 
be visible in the right hand corner (left hand corner for RTL languages when 
supported). Something like the wikipedia one comes to mind: 
   
![image](https://user-images.githubusercontent.com/33317356/116646873-dab36f80-a981-11eb-8339-c352681f24a9.png)
   - when clicking on the localization icon, a modal would appear which makes 
it possible to enter additional languages and define a fallback langugage
   - when saved, the default translation would be visible, with the 
corresponding flag icon instead of the localization icon, indicating that this 
is a translated value.


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

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