Page 1 of 1

Best way to override default messages

Posted: Mon Oct 01, 2012 9:23 am
by denis
Hi !

We would like to know what is the best way to override messages in properties files.

eg : we want modify some messages in the file CustomerCareMessages_fr.properties : should we override the complete file or there is an other mean to do that.

Thanks in advance !

Re: Best way to override default messages

Posted: Mon Oct 01, 2012 9:41 am
by Valdus
Overriding the file you want to change is typically the fastest way to accomplish what you want, and in your case it should be the easiest solution. Now I am not affiliated with Broadleaf in any way but in my experience with this solution overriding files is incredibly simply and you should have no trouble with it. But because the backend is gwt you may have to override the class file that is getting the messages as well otherwise it may not find them since the names would be in a different language.

Re: Best way to override default messages

Posted: Mon Oct 01, 2012 1:18 pm
by denis
Thanks for your answer !

Re: Best way to override default messages

Posted: Tue Oct 02, 2012 10:14 am
by phillipuniverse
Hey Denis,

I would also say that if you're doing this specifically in the admin translations project (https://github.com/BroadleafCommerce/AdminLanguagePack), the best thing to do would be to pull down that project from GitHub, make the changes that you need to the properties files themselves and then mvn install that module locally so the admin can pick it up.

Also, if you see anything that is translated incorrectly (or translations that are not there), we would love for you to actually fork the project yourselves and submit a pull request to us so that we can get the right things in the framework. Not only does this help us, this also ensures that you all do not have to continue to support a specialized version. Github has some documentation on this process: https://help.github.com/articles/using-pull-requests. In your case, you would create a fork and base the changes off of the 'master' branch. Let me know if you need any further help with this process.

Re: Best way to override default messages

Posted: Thu Oct 04, 2012 6:41 am
by denis
Hey Philip,

First of all, thanks for your reply. I have forked the project on github, we think that it's the best solution too.

When changes are made i will submit you a pull request ;-).

Re: Best way to override default messages

Posted: Fri Oct 12, 2012 4:27 am
by denis
If i want to add more messages (in CustomerCareMessages for example) what is the best solution :

- override CustomerCareMessages.java and CustomerCareMessages.properties
- or extends CustomerCareMessages.java with MyCustomerCareMessages.java , add a new properties file MyCustomerCareMessages.properties, ovveride CustomerCareModule and add into method onModuleLoad() the line addConstants(GWT.<ConstantsWithLookup>create(MyCustomerCareMessages.class));

Thanks !

Re: Best way to override default messages

Posted: Fri Oct 12, 2012 10:19 am
by phillipuniverse
I would definitely go with the second option. Although you don't really have to extend, you just create a new interface for MyCustomerCareMessages.java and do the addConstants(...) in your module subclass. As long as you are calling super.onModuleLoad() then you shouldn't have issues.

Also, since your locale is probably French for the admin, you should annotate the MyCustomerCareMessages.java with @DefaultLocale("fr").

Re: Best way to override default messages

Posted: Fri Oct 12, 2012 12:59 pm
by denis
Thanks philip. I have used the second option and it works like a charm. However i haven't seen a problem if i put a default locale en_US or fr, messages are both loaded from myCustomerCareMessage.properties