[BLOSSOM-185] Explain @I18nBasename in Blossom-Components Created: 22/Jul/14  Updated: 19/Sep/14  Resolved: 19/Sep/14

Status: Closed
Project: Blossom
Component/s: None
Affects Version/s: 3.0.2
Fix Version/s: None

Type: Task Priority: Major
Reporter: Adi De Masi Assignee: Tobias Mattsson
Resolution: Not an issue Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Magnolia 5.3


Template:
Acceptance criteria:
Empty
Task DoR:
Empty
Date of First Response:

 Description   

The Documentation (https://documentation.magnolia-cms.com/display/DOCS/Blossom+module) says that I have to set the @I18nBasename with "the resource bundle you want to use". But it is unclear what value I have to set. Should it match the module name, the module package, artifactID + groupdID, the messages_locale.properties file name or something else? And do the keys in the properties file have to match with a special convention or can i use whatever key i want?

Other sources say, that the "Basename" in general is deprecated (http://magnolia.namics.com/2013/12/20/i18n-in-magnolia-5/), but removing the @I18nBasename will lead to a "i18n is undefined"-error in the freemarker-templates.

Also, explain in the documentation how to use i18n in the java-code of a blossom-component or page.



 Comments   
Comment by Adi De Masi [ 24/Jul/14 ]

I noticed that e.g. in the standard-templating-kit, some property-files are directly in the package info.magnolia.module.templatingkit of the jar with the names messages_en.properties, etc.

I therefore put a messages_en.properties in the package of my module and set the @I18nBasename to this package and this worked.

Comment by Tobias Mattsson [ 25/Jul/14 ]

It's standard Java SE resource bundle conventions. The resource bundle 'messages' in package 'info.magnolia.module.templatingkit' is referred to as: 'info.magnolia.module.templatingkit.messages'.

In java code you can resolve messages using info.magnolia.i18nsystem.TranslationService. The older info.magnolia.cms.i18n.MessagesManager will also work, although it is deprecated now.

To stay with Spring APIs there's a MessageSource implementation in Blossom that bridges to Magnolia's i18n support. Configure it like this:

<bean id="messageSource" class="info.magnolia.module.blossom.context.MagnoliaMessageSource" />
Generated at Sun Feb 11 23:30:59 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.