Overriding Messages in Other Modules from Custom Module

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.

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

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

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

i could have tried that and still retrieved the former message

Then and now are different. :smile:

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).