Announcement Announcement Module
Collapse
No announcement yet.
Intent of application.properties vs messages.properties Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Intent of application.properties vs messages.properties

    A new Roo web app has the following files in its WEB-INF/i18n folder:
    • application.properties
    • messages_de.properties
    • messages_es.properties
    • messages_it.properties
    • messages_nl.properties
    • messages_sv.properties
    • messages.properties
    Both application.properties and the "messages" files support localisation; indeed the latter are already localised into German, Spanish, etc. The application.properties file can likewise be localised by creating files like this:
    • application_de.properties
    • application_es.properties
    • application_it.properties
    • application_nl.properties
    • application_sv.properties
    I'm unclear on the intended purpose of the two families of files; for example, if I want to add a new piece of localisable text to my app, should I put it in application_*.properties or messages_*.properties?

    I realise that I'm at liberty to decide on this for myself, but if there's an existing convention or best practice, I'd prefer to follow that than do something that will be surprising to new developers coming to the project.

    There's no mention of these files in the Roo reference docs.

  • #2
    Hi Andrew,

    The main purpose of two different files here is that the messages_*.properties files contain translations of commonly used labels in a Roo Web UI. Roo does actually not manage these files, it just copies them into the target project. This way, the comments, spaces, and general formatting of these files is preserved.

    The application.properties file contains all labels that are specific to your application (like field labels, entity labels, menu labels). Roo would manage this file if a new field or entity is added but it would obviously not be able to not translate those. So rather than creating new labels for each field in each messages_*.properties file with the wrong locale it just manages a central application.properties to which the resolver will fall back when it can not find the locale specific label in the messages files.

    So the messages files are there for displaying common labels in your scaffolded Web UI, whereas the application file contains application specific labels. You can go ahead and localize these labels by creating application_de.properties or you can copy the file contents to the respective messages files.

    HTH,
    Stefan

    Comment

    Working...
    X