Overriding Messages in Other Modules from Custom Module

(Stephen Senkomago Musoke) #1

In the Reference App infrastructure, is there a provision for overriding messages in dependent modules, as this could help reduce the amount of page and fragment overriding to get a custom title or label.

(Stephen Senkomago Musoke) #2

@dkayiwa Do you have any idea if this is possible, if so how it can be done?

(Kaweesi Joseph) #3

we can’t overwrite messages yet, its tricky with spring localization approach and how openmrs loads message files.

A simple way-out i can think of for now could be using AOP.

tap into Context.getMessageSourceService().getMessage before it runs with AOP with your specific message code (edited) and overwrite your message code with one in your module @ssmusoke that’s the simplest way i can for now think around it. may be use some naming convention for overwrites, like; moduleid.overwrite.appointmentschedulingui.message so that when appointmentschedulingui.message is received when it’s overwrite match is existing in moduleid, you use your module’s one

(Daniel Kayiwa) #4

Just try using the same exact message key in your custom module. For instance: coreapps.findPatient.app.label=Find Patient Record From Uncle Muso

(Kaweesi Joseph) #5

i could have tried that and still retrieved the former message

(Daniel Kayiwa) #6

Then and now are different. :smile:

(Dimitri R) #7

Surely this depends on which module is loaded first. I wonder if Initializer could help you with such overrides as it allows to provide .properties files on the fly? (example here).