Changing OpenMRS site language via REST

Hi all, is it possible to change language site via REST same as it is in the legacy UI at the bottom of the page ?

Could you please post your findings so far i.e. what you tried?

I did try to update property “proficientLocales” in admin user via REST, but I’m not sure how the request body should look. Something like “proficientLocales”:“es” does not work. I do not have any other ideas how to accomplish this.

EDIT: here is the exception thrown when sending post with the above body to “/user/uuid” endpoint

I would try:

POST .../user/{uuid}
{ "userProperties": { "proficientLocales": "es" } }

Note that this will probably rewrite any other user properties, so maybe you need to GET them first and merge them together.

I haven’t tried this, so let us know if it works.

I did test it and it is not working. The site language is not changed.

@adamg how about if you try a user property with name “defaultLocale”?

I did try changing both proficientLocales and defaultLocale

@adamg after setting defaultLocale, does it get properly saved in the database user_property table? If yes, does the locale change after restarting tomcat?

@dkayiwa If you change language via legacy UI you still get same values via rest so it seems like there is no connection between those values ang language site.

Sending this value via rest saves it in DB I guess because later when requesting this value via rest I got the changed value

Can i see the full url and post contents that you are using? I want to try it out locally.




{“userProperties”: { “defaultLocale”: “en”, “notification”: “”, “loginAttempts”: “0”, “showVerbose”: “false”, “lockoutTimestamp”: “”, “proficientLocales”: “fr_RW”, “notificationAddress”: “”, “showRetired”: “false”, “defaultLocation”: “8” } }

(Stepping back…)

There are two different language settings: (1) your current session’s locale, and (2) your default locale, which is applied when you log in.

I don’t think it’s possible to change the current session locale via REST (though it might just work if you append ?lang=xyz to any request, because of the LocaleChangeInterceptor in the legacyui module, but I don’t know if this catches REST requests). We should add an intentional feature for this, e.g. something like a user/uuid/locale subresource with explicit properties for currentSessionLocale and defaultLocale.

Also, we should improve the REST API so that the user properties are exposed individually as some sort of intentional resource, rather than as an obscure json object.