Fórum

FreeMarker - Request local language

Mar Kus, modificado 6 Anos atrás.

FreeMarker - Request local language

New Member Postagens: 5 Data de Entrada: 14/03/16 Postagens Recentes
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
thumbnail
Nikolai Reisch, modificado 6 Anos atrás.

RE: FreeMarker - Request local language

New Member Postagens: 14 Data de Entrada: 25/02/09 Postagens Recentes
${w3c_language_id}
Mar Kus, modificado 6 Anos atrás.

RE: FreeMarker - Request local language

New Member Postagens: 5 Data de Entrada: 14/03/16 Postagens Recentes
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?
thumbnail
Nikolai Reisch, modificado 6 Anos atrás.

RE: FreeMarker - Request local language

New Member Postagens: 14 Data de Entrada: 25/02/09 Postagens Recentes
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() />
Aitor Ibañez, modificado 6 Anos atrás.

RE: FreeMarker - Request local language

New Member Postagens: 15 Data de Entrada: 05/06/17 Postagens Recentes
Hi Markus,
I have used that variable like this:

&lt;#assign langId = themeDisplay.getLanguageId() /&gt; 
&lt;#if langId == "es_ES" &gt;
		${langId}
<!--#if-->
Mar Kus, modificado 6 Anos atrás.

RE: FreeMarker - Request local language

New Member Postagens: 5 Data de Entrada: 14/03/16 Postagens Recentes
Many thanks for your replies!

Finally, that solution worked for me:
<#assign langId = request['theme-display']['language-id'] />
André Biegel, modificado 6 Anos atrás.

RE: FreeMarker - Request local language

Junior Member Postagens: 31 Data de Entrada: 11/11/13 Postagens Recentes
<#assign langId = request['theme-display']['language-id'] /> worked !
bunix nic, modificado 4 Anos atrás.

RE: FreeMarker - Request local language

New Member Mensagem: 1 Data de Entrada: 28/02/20 Postagens Recentes
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]&lt;#if .locale == "DE"&gt;
   ...
&lt;#else&gt;
   ...
<!--#if-->
​​​​​​​[u][color=#2b4259][font="Source Sans Pro", sans-serif][size=4][b][/b][/size][/font][/color][/u]
Upsers