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