OSC / ood-documentation

Documentation for Open OnDemand generated using Sphinx
https://osc.github.io/ood-documentation/latest/
MIT License
8 stars 51 forks source link

Bundle internationalization files with apps? #798

Closed ltalirz closed 1 year ago

ltalirz commented 1 year ago

The documentation explains how to add internationalization to apps, via /etc/ood/config/locales/en.yml.

This works, but it mixes the translation strings of different apps in the same file, which makes it not so easy to maintain the file as apps are added/removed/updated.

Is there a way to ship internationalization files together with an app, say inside an i18n subfolder of the app, and have OOD read them from there when the app folder is copied to /var/www/ood/apps/sys ?

I see one can use the OOD_LOCALES_ROOT variable to tell OOD where to look for i18n files, but from the documentation I understand this is a global variable, rather than "per app"?

cc @matt-chan

┆Issue is synchronized with this Asana task by Unito

johrstrom commented 1 year ago

Is there a way to ship internationalization files together with an app, say inside an i18n subfolder of the app, and have OOD read them from there when the app folder is copied to /var/www/ood/apps/sys ?

I don't quite follow this, as this may already happen. The default internationalizations are held in that directory, for example the dashboard's default localizations are in /var/www/ood/apps/sys/dashboard/config/locales. Though you should not be modifying these files as they will be overwritten on updates.

I see one can use the OOD_LOCALES_ROOT variable to tell OOD where to look for i18n files, but from the documentation I understand this is a global variable, rather than "per app"?

This could be per app if you set it in /etc/ood/config/apps/<app>/env for example /etc/ood/config/apps/dashboard/env just for the dashboard.

johrstrom commented 1 year ago

I see one can use the OOD_LOCALES_ROOT variable to tell OOD where to look for i18n files, but from the documentation I understand this is a global variable, rather than "per app"?

This could be per app if you set it in /etc/ood/config/apps//env for example /etc/ood/config/apps/dashboard/env just for the dashboard.

Note that things set in this env file only populate new environment variables and won't override existing ones. So if you set OOD_LOCALES_ROOT in nginx_stage, which is global, it won't be overwritten in the env file.

ltalirz commented 1 year ago

Hi @johrstrom, thanks a lot for the quick reply!

Since there was a bit of confusion about what exactly I was asking, let me try to make an example using the bc_example_jupyter app:

From your replies, do I understand correctly that I should

If I do that, should the en.yml file be recognized automatically? (in my case, the app landing page says translation missing: en.bc_example_jupyter.my_string)

Do I also need to add a file /etc/ood/config/apps/bc_example_jupyter/env with content

OOD_LOCALES_ROOT=/var/www/ood/apps/sys/bc_example_jupyter/config/locales

(also this does not seem to have an effect in my case)

johrstrom commented 1 year ago

Oh I see. No that won't work. You're referring to localizing a batch connect application, which - in this context - is really a part of the dashboard application, not it's own thing properly (with regard to translations and env files).

So whatever translations you're trying to add to any given batch connect application, you're really trying to add them to the dashboard. Which in turn means, you're editing 1 single file, no matter the location.

What's the problem you're trying to solve here - maybe localization isn't the right approach.

ltalirz commented 1 year ago

I see, thanks for the clarification!

What's the problem you're trying to solve here - maybe localization isn't the right approach.

I was indeed looking into how we would go about providing a translation of the landing pages of a few batch connect applications in a way that is maintainable.

What approach would you recommend for this - edit the /var/www/ood/apps/sys/dashboard/config/locales/*.yml files?

johrstrom commented 1 year ago

What approach would you recommend for this - edit the /var/www/ood/apps/sys/dashboard/config/locales/*.yml files?

No, these files will be overwritten when you re-install/update. Seems like if you need translations, then you need to add them to /etc/ood/config/locales/*.yml (that being the easiest because again, you'll be editing 1 single file per locale, so it may as well be the default).

ltalirz commented 1 year ago

Great, thanks for the help!

johrstrom commented 1 year ago

Thanks! Sorry there's not a better solution than 1 single file.

That said - we're always looking for translations if you want to add any to the distribution.