Help with configuration to achieve locale switching

Hi,

Thank you in advance for reading this :slight_smile:

With Chinese locale in version 1.8, we would really like to make use of it. In the ood documentation, it seems it only provides a way to do configuration by admin so that either Chinese or English locale is used. However, what we want is to have the users gain the ability to make the choice of locale instead of administrator.

We learned on page Rails Internationalization (I18n) API ā€” Ruby on Rails Guides that it is possible for users of rails application to choose which locale to use through url params. However, we are using openid connect with keycloak for authentication. In the authentication process, users will firstly be directed to keycloak and then back to a redirect url specified in the configuration file (auth_openidc.conf), which is clearly the url of ondemand site before. But in our case of wishing to use url params, namely we would have two urls to access the same ondemand site from my understanding, we are not sure how to configure two redirect urls and how to match the url used to access the site with the right redirect url?

Iā€™m considering about setting up two clients in keycloak, each representing one of the two urls and configure ondemand site to be linked to the two clients. Maybe each keycloak client has one of the two urls as its root url. But I have no idea how to do configuration on the ondemand site side to achieve this. Or is it possible to do it this way?

We would really appreciate it if any suggestion is given. Thank you so much and look forward to your reply.

Best wishes,
Kaiyue Wu

I donā€™t think you would need 2 sites for this. I believe all the redirects are for URL paths and wouldnā€™t be affected by query paramters.

I believe weā€™d have to enable this in the source itself. Whatā€™s more, even if the APIs accepted the query parameter, thatā€™s kind of clunky, so a better approach would be just to allow the user to choose a different locale and ā€˜it all just worksā€™ without them having to use query parameters.

We donā€™t have user based configurations/preferences yet, but when we do, Iā€™ve added this ticket to enable users to save and use their locale preference. Iā€™m going to move this topic into Feature requests now as it seems like thatā€™s what it is at this point.

Thanks for reaching out!

Until we are able to provide a more streamlined solution like Jeff mentioned, here is one that may work.

Add /etc/ood/config/apps/dashboard/initializers/locale.rb with this content:

# $XDG_CONFIG_HOME which defaults to $HOME/.config
ENV['OOD_LOCALE'] = "zh-CN" if File.file?(File.join(Dir.home, '.config', 'ondemand', 'chinese'))
  • I didnā€™t think XDG_CONFIG_HOME was set in the PUN env so figured I would just use the default. This is where we will likely be storing OnDemand user settings in the future.
  • You will actually need to add this file to the other app config directories with translations as well (/etc/ood/config/apps/myjobs/initializers/locale.rb and /etc/ood/config/apps/activejobs/initializers/locale.rb).

Then you can tell your users that want to use the Chinese translation to open the terminal app and execute:

mkdir -p ~/.config/ondemand
touch  ~/.config/ondemand/chinese

And then in the OnDemand dashboard, select ā€œHelp => Restart Web Serverā€.

We welcome any reports of missing translations that could be added and of course if you know what the translation should be. You can share via a GitHub issue posted to Issues Ā· OSC/ondemand Ā· GitHub.

Hi,

Thank you so much for making it a feature request and considering realizing this functionality! We look forward to seeing it in future releases.

And thank you so much for providing the solution for now, we will try it out.

Best wishes,
Kaiyue