Hi Will!

If you set up the i18n correctly for a site, the output of content in the 
correct language should be transparent to you.

So, assuming you enable english and german, and set german as the default 
language, then if the site is accessed via:

www.mysite.com/siteroot/contentpage   --> contentpage will show up in German
www.mysite.com/en/siteroot/contentpage   --> contentpage will show up in English

In the same way, ${content.field} will return the correct value, based on the 
currently selected language.

You can find the currently selected language via 
getAggregationState().getLocale()
You can find the user's preferred language via getUser().getLocale()
You can find the browser's language via getContext().getLocale()

Normally, you should not have to mess with those variables though. The only 
reason I found for reading those variables was in order to create a navigation 
for switching language on the public site. On the author site you can switch 
language using the controls in the pagebar.
On the public site you may want to provide flag-buttons, they can link to the 
current page in a different language by setting the link to something like:  
${contextPath + "/en" + content.@handle}
In order to highlight the currently selected language, you can test [# if 
state.locale.language=="en"] ... [/#if]
--> remember, the aggregationState contains the selected language!

Regards from Vienna,

Richie




-----Ursprüngliche Nachricht-----
Von: [email protected] [mailto:[email protected]] 
Im Auftrag von Will Scheidegger
Gesendet: Dienstag, 01. März 2011 15:46
An: Magnolia User-List
Betreff: [magnolia-user] Freemarker i18n: Selecting the right node data to 
output


Dear Magnolians

Already my next stk / freemarker question that I could not answer with the help 
of the documentation...

Let's say you have a localized title stored in the node datas "title_en" and 
"title_fr". What's the correct way to output the right version now? If you have 
the current language somewhere (be that in the site or whatever, for now just 
say in a variable "language") the best I could come up with is 

${content['title_' + language]}

but I was kind of expecting to find a special Magnolia trick for this... or am 
I missing something again?

Thanks
-will




----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------





----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------

Reply via email to