Language Labels from Database

i want to load messages/labels not only from properties files but also from a database.

so i extended AbstractMessages and annotated the Component as Primary.


@Component( "custom_Messages" )

public class CustomMessagesImpl extends AbstractMessages {

This works but exists a recommended way to do this?

Hi & welcome to the CUBA community :slight_smile:

this should work just fine, but I think you have to replace the existing Component identifier which is: cuba_Messages). Alternative it should be possible to override it in the spring.xml.

Note that in case of the Messages API, CUBA defines a web client bean and for the backend as well. So you have to do two implementations for the web client and for the backend implementation. Reason is that on the web client the messages are cached.

Not sure if I understand your requirement correct, but if you want to load message translations from the DB then you might be interested in the fact that there is an addon already available which does exactly this. See: DB-Localization – CUBA Platform


1 Like