Locale in Bahmni

Hello all–

Not sure if this is a question, a concern, or an fyi, but we made a discovery regarding the way that Bahmni handles locale and wanted to make sure I was understanding it correctly.

  1. It looks like that when you set the locale in Bahmni (via the drop-down on the login page) this does not modify the underlying locale set on the OpenMRS Context object.

  2. One reason this is done is because Bahmni configuration relies on looking up concepts by name, and specifically uses the conceptService.getConceptByName() method, which is dependent on the user’s locale–so if the user’s locale is set to something other than “en” looking up information by concept name will fail.

We discovered this while working on endTB because as “power users” we often navigate to the “old” OpenMRS UI directly to modify Concept names, etc. We are liable to click on the locale options at the bottom of “old” UI, this will change the user’s context, and so when one navigates back to Bahmni things will start to fail because the context is no longer in “en”.

Is my analysis correct, or am I misinterpreting?

Probably worth adding a note on the Bahmni wiki about this, because it puzzles us for quite some time what was going on until we tracked it to the locale.

Thanks and take care! Mark

Hi @mogoodrich, We have a servlet filter which sets users default locale to chosen value in the dropdown.
The assumption here is that a user who logs in with a specific locale (for e.g. French), will always use the same locale through out. We have noticed that if the same user switches across locales, there will be some time lag (or login & logout) before it gets into effect. So, as a workaround, can we have 2 different users - each with different locale - working with their own languages instead of switching.

@bharatak… sorry, this confused me more. :slight_smile:

I’m not referring to the user’s default locale, but rather the actual locale associated with the user’s context. It appears to me that if that gets set to anything other than “en” (at least in endTB) things will start to fail.

For example, the obs flowsheet controller looks up concepts by name to determine what obs to render:

The underlying getConceptByName method depends on the user’s locale:

So if the Context.getLocale() returns the anything but “en”, and the json configuration for the table references concepts by their English names, this method will return null and you’ll get a “Root concept not found for the name” error.

If I change the locale by clicking on the locale links that the bottom of the OpenMRS application, this changes the user’s locale, and when you go back to Bahmni errors start appearing when trying to render data.

However, no matter what I set the user’s locale to in the Bahmni UI, Context.getLocale() appears to always return “en”–which is needed for things to function correctly.

Hope that makes sense!

Take care, Mark

Hi @mogoodrich, Sorry for the confusion. One of the consideration while doing i18n for bahmni was that the json configuration files will always be in en language and the assumption is that the implementer understands english. I see that when you change the locale from OpenMRS Legacy UI, the english concept names are not found in the respective locale. We have highlighted your recommendation in wiki here.

Cool, thanks! Yes, that warning captures what I was saying. Just wanted to help others from puzzling over the same error.

Take care, Mark