How to override a service message?

82 Views Asked by At

I am using an OOTB service in Moqui for eg, say any service from PartyServices.xml then the message that are displayed comes from the services itself but I want a minor modification in the message that is displayed so for that I am currently overriding the service in my component only to change the message.

So I wanted to know that am I following best practice ? or is there any other way to do the same ?

1

There are 1 best solutions below

0
On BEST ANSWER

You can use the automatic internationalization for this. Just add a record for the LocalizedMessage entity with the message from the code as the "original", the desired locale (can be "en" even if the original is in English), and the desired message in the "localized" field.

Note that the "original" should be the actual text coming from the code. If it has a ${} string expansion that should be left as-is. In other words, the localization is done BEFORE string expansion so that the placeholders can be moved around as needed (or even changed...) to handle different languages or to customize messages.

The UI to add/edit l10n messages is in the Application => Tool => Localization => Messages screen.

On a side note, you can see the strings that are cached along with the locale used and the resulting localized string at runtime by looking at the "l10n.message" cache (in Application => Tool => System => Cache List).