Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Create a session scoped managed bean like follows:</p> <pre><code>@ManagedBean @SessionScoped public class LocaleManager { private Locale locale; @PostConstruct public void init() { locale = FacesContext.getCurrentInstance().getExternalContext().getRequestLocale(); } public Locale getLocale() { return locale; } public String getLanguage() { return locale.getLanguage(); } public void setLanguage(String language) { locale = new Locale(language); FacesContext.getCurrentInstance().getViewRoot().setLocale(locale); } } </code></pre> <p>To set the current locale of the views, bind it to the <code>&lt;f:view&gt;</code> of your master template.</p> <pre class="lang-html prettyprint-override"><code>&lt;f:view locale="#{localeManager.locale}"&gt; </code></pre> <p>To change it, bind it to a <code>&lt;h:selectOneMenu&gt;</code> with language options.</p> <pre class="lang-html prettyprint-override"><code>&lt;h:form&gt; &lt;h:selectOneMenu value="#{localeManager.language}" onchange="submit()"&gt; &lt;f:selectItem itemValue="en" itemLabel="English" /&gt; &lt;f:selectItem itemValue="nl" itemLabel="Nederlands" /&gt; &lt;f:selectItem itemValue="es" itemLabel="Español" /&gt; &lt;/h:selectOneMenu&gt; &lt;/h:form&gt; </code></pre> <p>To improve SEO of your internationalized pages (otherwise it would be marked as duplicate content), bind language to <code>&lt;html&gt;</code> as well.</p> <pre class="lang-html prettyprint-override"><code>&lt;html lang="#{localeManager.language}"&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload