Openmrs-translate from openmrs-web-angularjs-api: where is locale set

I’m getting a little lost figuring out how the openmrs-translate module gets set with the locale of the current user. Is there any explanation about this, or a description of the proper way to use this functionality?

While testing the programs and program status dashboard widgets that I’ve created, I noticed that for the program status widget I needed to pass in the locale and the openmrsTranslate object in the controller and explicitly set the language used or it would always just use the default language, English.

However, with the Programs widget, I didn’t need to set the locale–it seems to happen “magically”.

I’m guessing that the different is not in the two widgets, but rather that I used the Programs widget on a page with other widgets, while the Programs Status widget is used on a page by itself–so I’m assuming that something else is setting the locale in the former case, but I can’t figure out what is is. Thoughts? What is the “correct” way to set this up?

fyi @raff

Take care, Mark

@mogoodrich, I see this snippet of code in the Programs widget:

so it does set the language manually…

I’ve just released a new version of angularjs-openmrs-api, which should set the language automatically as soon as you inject openmrsTranslate. It requires the latest snapshot of webservices.rest with this fix https://issues.openmrs.org/browse/RESTWS-660

@raff Sorry, to clarify I added that line in afterwards to make it consistent with the other widget, and to make sure it worked, since I didn’t know why it was working without it.

That being said, having openmrsTranslate getting the locale via REST is like the right solution… I will most likely just upgrade to the latest of angularjs-openmrs-api and Web Services and pull this manually settings back out… thanks for adding that! I didn’t realize we had already created a REST call to return the locale.

Take care, Mark