jeudi 4 juin 2015

Grails GSP - Display different textfields dependant on locale

I'm having an issue trying to display a different g:textfield dependant on the users locale using Grails 2.4.3.

I've found that to bypass an issue raised in Grails 2.4.3 I have to set the a variable on my gsp page:

<g:set var="lang" value="${session.'org.springframework.web.servlet.i18n.SessionLocaleResolver.LOCALE'}" />

I can display ${lang} correctly and see the correct value on screen.

I have to display a different textfield dependant on the locale value so I assumed I could use the following but it doesn't work?

<g:if test="${lang.equals('de')}">
    German Textfield
</g:if>

I have tried the lang.equals and lang == de which I've shown here with each de and en

<g:elseif test="${lang == 'en'}">
    English Textfield
</g:elseif>

<g:else>
    no language support
</g:else>

Aucun commentaire:

Enregistrer un commentaire