title: Localization with Hindi language in JSF 2.0
body: <p>I'm using <a href="http://vikku.info/indian-language-unicode-converter/hindi-unicode-converter.html" rel="nofollow">this</a> English to Hindi Unicode converter. The code produced is placed in the <code>MessageBundle_hi_IN.properties</code> file. </p>
  
  <p>When a constraint is violated like a mandatory text field. A corresponding error message should be picked up from this file and displayed in Hindi language but it displays the same Unicode as in the file without any conversion like,</p>
  
  <pre><code>&amp;#2326;&amp;#2366;&amp;#2354;&amp;#2367; &amp;#2344;&amp;#2361;&amp;#2367; &amp;#2352;&amp;#2326; &amp;#2358;&amp;#2325;&amp;#2340;&amp;#2375;&amp;#46;
  </code></pre>
  
  <p>It is expected to be shown in Hindi like.</p>
  
  <p>&#2326;&#2366;&#2354;&#2367; &#2344;&#2361;&#2367; &#2352;&#2326; &#2358;&#2325;&#2340;&#2375;&#46;</p>
  
  <p>It means "<em>Cannot be left blank.</em>"</p>
  
  <hr>
  
  <p>The XHTML page.</p>
  
  <pre><code>&lt;?xml version='1.0' encoding='UTF-8' ?&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  
  &lt;html lang="#{localeBean.language}"
        xmlns="http://www.w3.org/1999/xhtml"      
        xmlns:h="http://java.sun.com/jsf/html"
        xmlns:p="http://primefaces.org/ui"
        xmlns:ui="http://java.sun.com/jsf/facelets"
        xmlns:f="http://java.sun.com/jsf/core"&gt;
  
          &lt;f:view locale="#{localeBean.locale}"&gt;
  
          &lt;h:head&gt;
              &lt;title&gt;Title&lt;/title&gt;
          &lt;/h:head&gt;
  
          &lt;h:body&gt;                
  
              &lt;h:form&gt;
                  &lt;h:selectOneMenu id="languages" value="#{localeBean.language}" onchange="submit();" style="position: absolute; right: 0; top: 50px;"&gt;
                      &lt;f:selectItem itemValue="en" itemLabel="English" /&gt;
                      &lt;f:selectItem itemValue="hi" itemLabel="Hindi" /&gt;
                  &lt;/h:selectOneMenu&gt;
              &lt;/h:form&gt;
  
          &lt;/h:body&gt;
      &lt;/f:view&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>The corresponding managed bean.</p>
  
  <pre><code>package admin.mangedbean;
  
  import java.io.Serializable;
  import java.util.Locale;
  import javax.annotation.PostConstruct;
  import javax.faces.context.FacesContext;
  
  @ManagedBean
  @SessionScoped
  public final class LocaleBean implements Serializable
  {
      private Locale locale;
      private static final long serialVersionUID = 1L;
  
      public LocaleBean() {}
  
      @PostConstruct
      private void init()
      {
          locale = FacesContext.getCurrentInstance().getViewRoot().getLocale();
      }
  
      public Locale getLocale()
      {
          return locale;
      }
  
      public String getLanguage()
      {
          return locale.getLanguage();
      }
  
      public void setLanguage(String language)
      {
          if(language.equals("hi"))
          {
              locale = new Locale(language, "IN");
          }
          else
          {
              locale = new Locale(language);
          }
  
          FacesContext.getCurrentInstance().getViewRoot().setLocale(locale);
      }
  }
  </code></pre>
  
  <hr>
  
  <p>The faces-config.xml file.</p>
  
  <pre><code>&lt;application&gt;
      &lt;message-bundle&gt;
          messages.MessageBundle
      &lt;/message-bundle&gt;
  
      &lt;locale-config&gt;
          &lt;default-locale&gt;en&lt;/default-locale&gt;
          &lt;supported-locale&gt;hi_IN&lt;/supported-locale&gt;
      &lt;/locale-config&gt;
  
      &lt;resource-bundle&gt;
          &lt;base-name&gt;messages.ResourceBundle&lt;/base-name&gt;
          &lt;var&gt;messages&lt;/var&gt;
      &lt;/resource-bundle&gt;
  &lt;/application&gt;
  </code></pre>
  
  <hr>
  
  <p>This works in JSP something like,</p>
  
  <pre><code>&lt;fmt:setLocale value="hi_IN"/&gt;
  &lt;fmt:setBundle basename="bundles.resourceBundle_hi_IN" var="resourceBundle"/&gt; 
  
  &lt;fmt:message key="someKey" bundle="${resourceBundle}"/&gt;
  </code></pre>
  
  <p>What is going wrong here? Am I using a wrong <a href="http://vikku.info/indian-language-unicode-converter/hindi-unicode-converter.html" rel="nofollow">converter</a>? Is this language not supported by JSF?</p>