openforis / sepal

Geographical Data Processing in the Cloud
https://sepal.io/
MIT License
207 stars 46 forks source link

app dashboard translation #112

Closed 12rambau closed 2 years ago

12rambau commented 3 years ago

All the applications are running on instances (from R studio to the voila based app). meaning that at the moment they all fallback in english as it's the instance default language.

We worked to ensure that the rest of the website is translated in both Spanish and French and the procedure would be quite easy if one would like to add an extra language: add a file with the language iso code and copy and translate all the keys from en.json (https://github.com/openforis/sepal/tree/master/modules/gui/frontend/src/locale).

Problem being that this translation mechanism is not transmitted to the instances forcing the applications to fallback to english. As it's a web server Shiny is the only one that can jump from one language to another by reserving the app after clicking on a button.

For Rstudio, JupyterLab and Jupyter Notebook, the LANG (currently defaulting to en_US.UTF-8) need to be changed (the languages are all already internally supported). In the app based on the sepal_ui framework the Translator object can listen to any env variable to guess the language to use.

Would it be possible to align the LANG env variable to the one used in SEPAL when we open a new instance? If not would it be possible to automatically create a custom variable that we can listen to when a new instance is opened?

If you have any other idea to translate the tools available in the app dashboard please add a comment

12rambau commented 2 years ago

multiple updates on this one:

I tried to get the language stored in LocalStorage but as JS is asynchronous I cannot get it when using a voila based App (https://github.com/davidbrochart/ipyurl/issues/2#issuecomment-1010179483)

12rambau commented 2 years ago

We ended up creating a config file for sepal_ui based applications (https://github.com/12rambau/sepal_ui/pull/413). I don't know why we didn't think about that earlier and it works quite well. now it's just a matter of upgrading applications venvs.