content: package org.agoncal.application.petstore.view;
  
  import org.agoncal.application.petstore.util.Loggable;
  
  import javax.enterprise.context.SessionScoped;
  import javax.enterprise.inject.Produces;
  import javax.faces.context.FacesContext;
  import javax.inject.Named;
  import java.io.Serializable;
  import java.util.Locale;
  
  /**
   * @author Antonio Goncalves
   *         http://www.antoniogoncalves.org
   *         --
   */
  
  @Named
  @SessionScoped
  @Loggable
  public class LocaleBean implements Serializable {
  
      @Produces
      private Locale locale = FacesContext.getCurrentInstance().getViewRoot().getLocale();
  
      // ======================================
      // =          Business methods          =
      // ======================================
  
      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);
      }
  }