if statement - Grails GSP - Display different textfields dependant on locale -
i'm having issue trying display different g:textfield dependant on users locale using grails 2.4.3.
i've found bypass issue raised in grails 2.4.3 have set variable on gsp page:
<g:set var="lang" value="${session.'org.springframework.web.servlet.i18n.sessionlocaleresolver.locale'}" />
i can display ${lang} correctly , see correct value on screen.
i have display different textfield dependant on locale value assumed use following doesn't work?
<g:if test="${lang.equals('de')}"> german textfield </g:if>
i have tried lang.equals , lang == de i've shown here each de , en
<g:elseif test="${lang == 'en'}"> english textfield </g:elseif> <g:else> no language support </g:else>
do this:
<g:if test="${lang == locale.german}"> ...
i recommend current locale this:
<%@ page import="org.springframework.web.servlet.support.requestcontextutils" %> <g:set var="lang" value="${requestcontextutils.getlocale(request)}" />
Comments
Post a Comment