Failed to load messages from messages.properties file using "emr.loadMessages()"

Am trying to work on RA-995 . But according to this discussion , am expected to do my changes in angular format. Now before I was loading messages using

“${ui.message(“openmrs.demo.label”)}”

But since I moved my code to a pure .js script, I had to change to something like

roller(“changeLanguageController”, function($scope){ emr.loadMessages(“adminui.account.primaryLang.desc”,function(){ alert(emr.message(“adminui.account.primaryLang.desc”)); });

But this isn’t working. Can someone help me on this! Full js file https://dpaste.de/Qmxw#L3,4 cc: @dkayiwa , @k.joseph , @ssmusoke , @wyclif

I haven’t really looked at your issue in details, but loadMessages(..) has a callback (see here):

emr.loadMessages(msgCodes, function(msgs) {
  $scope.msgs = msgs;
});

See a working Angular example here.

@samuel34 did you try the above suggestion?

@mksd Thanks for the reply. I think it was just stubbornly refusing :grinning:

Just to clarify, when you provide a call back function you have to directly use the returned translated message rather than looking it up calling emr.message(“code”) as you’re doing because it hasn’t yet been added to the translated messages map on the client side.