package rs.etf;

import java.util.Locale;
import java.util.Map;
import javax.faces.bean.ApplicationScoped;

import javax.faces.bean.ManagedBean; 
import javax.faces.bean.RequestScoped;
import javax.faces.bean.SessionScoped;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;

@ManagedBean // or @Named
@ApplicationScoped
public class LocaleChanger {
   public void changeLocale() {
    FacesContext context = FacesContext.getCurrentInstance();
    String jezik = getLanguageCode(context);
    context.getViewRoot().setLocale(new Locale(jezik));
   }
   private String getLanguageCode(FacesContext context) {
      Map<String, String> parametri = context.getExternalContext().getRequestParameterMap();
      return (String) parametri.get("atributJezik");
   }
}