留言板
FreeMarker - Request local language
Does anyone know how to request the current language local the user is using like "en_US"?
I want to use this variable in a template.
Thanks in advance.
Best,
Markus
I want to use this variable in a template.
Thanks in advance.
Best,
Markus
Nikolai Reisch,修改在6 年前。
RE: FreeMarker - Request local language
New Member 帖子: 14 加入日期: 09-2-25 最近的帖子
${w3c_language_id}
Many thanks for your reply.
But this doesn't work for me: <a>${w3c_language_id}</a>
Do I have to assign it in a special way?
But this doesn't work for me: <a>${w3c_language_id}</a>
Do I have to assign it in a special way?
Nikolai Reisch,修改在6 年前。
RE: FreeMarker - Request local language
New Member 帖子: 14 加入日期: 09-2-25 最近的帖子
it comes from init.ftl:
<#assign language = locale.getLanguage() />
<#assign language_id = user.getLanguageId() />
<#assign w3c_language_id = localeUtil.toW3cLanguageId(theme_display.getLanguageId()) />
<#assign time_zone = user.getTimeZoneId() />
<#assign language = locale.getLanguage() />
<#assign language_id = user.getLanguageId() />
<#assign w3c_language_id = localeUtil.toW3cLanguageId(theme_display.getLanguageId()) />
<#assign time_zone = user.getTimeZoneId() />
Hi Markus,
I have used that variable like this:
I have used that variable like this:
<#assign langId = themeDisplay.getLanguageId() />
<#if langId == "es_ES" >
${langId}
<!--#if-->
Many thanks for your replies!
Finally, that solution worked for me:
<#assign langId = request['theme-display']['language-id'] />
Finally, that solution worked for me:
<#assign langId = request['theme-display']['language-id'] />
André Biegel,修改在6 年前。
RE: FreeMarker - Request local language
Junior Member 帖子: 31 加入日期: 13-11-11 最近的帖子
<#assign langId = request['theme-display']['language-id'] /> worked !
Special variables are variables defined by the FreeMarker engine itself. To access them, you use the .variable_name syntax.locale: Returns the current value of the locale setting. This is a string, for example en_US. For more information about locale strings see the setting directive.So to access the current local within a Freemarker template you would use
[code]The current locale is: ${.locale}
To use it in a conditional statement as per your requirements, you would do:[code]<#if .locale == "DE">
...
<#else>
...
<!--#if-->
[u][color=#2b4259][font="Source Sans Pro", sans-serif][size=4][b][/b][/size][/font][/color][/u]
Upsers