Tuesday, 24 May 2016

Setting locale for fmt tags.

Add the following just above header.
<c:set var="language" value="${not empty param.language ? param.language : not empty language ? language : pageContext.request.locale}" scope="session" />
<fmt:setLocale value="${language}" />
<html lang="${language}">

Add the following where ever you require the local drop down to appear.
<form>
                        <select id="language" name="language" onchange="submit()">
                            <option value="en" ${language == 'en' ? 'selected' : ''}>English</option>
                            <option value="es" ${language == 'es' ? 'selected' : ''}>EspaƱol</option>
                        </select>
                    </form>

No comments:

Post a Comment