Search code examples
javajsfrichfaces

<rich:calendar> Locale.US (translate to czech)


is there any way to translate rich calendar to language which is not supported by Locale.XX ??

Thanks for help

UPDATE: part of my calendar bean

@RequestScoped
@ManagedBean(name="calendarBean")
public class CalendarBean implements Serializable
{    
  /**/
  private static final long serialVersionUID = -219499296173801537L; 
  private Locale locale;    
  private String pattern;  
  private Date currentDate;  
  private Date selectedDate;  

  public Locale getLocale() {  
    return locale;  
  }  
  public void setLocale(Locale locale) {  
    this.locale = locale;  
  }  
  public String getPattern() {  
    return pattern;  
  }  
  public void setPattern(String pattern) {  
    this.pattern = pattern;  
  }  

  /* Constructor */
  public CalendarBean() {  
    locale = Locale.US;  
    pattern = "MMM d, yyyy";  
  }  

  public void selectLocale(ValueChangeEvent event) {  
    String tLocale = (String) event.getNewValue();  
    if (tLocale != null) 
    {  
      String lang = tLocale.substring(0, 2);  
      String country = tLocale.substring(3);  
      locale = new Locale(lang, country, "");  
    }  
  }  

  public Date getCurrentDate() {  
    return currentDate;  
  }  
  public void setCurrentDate(Date currentDate) {  
    this.currentDate = currentDate;  
  }  
  public Date getSelectedDate() {  
    return selectedDate;  
  }  
  public void setSelectedDate(Date selectedDate) {  
    this.selectedDate = selectedDate;  
  }  
}  

UPDATE: (rich:calendar) with EXAMPLE ON WEB

<rich:calendar mode="ajax" 
               boundaryDatesMode="scroll" 
               value="#{myBdeCheck.calendar.selectedDate}"  
               locale="#{calendarBean.locale}"  
               datePattern="#{calendarBean.pattern}"                        
               cellWidth="24px" cellHeight="22px" style="width:200px"/>

Solution

  • Generally speaking, locales are not limited. Just use the constructor new Locale("your language")

    For the calendar - it has a property for each i18nable thing, so you can use your #{msg.foo} there:

    The documentation writes:

    The component allows to use "header" , "footer" , "optionalHeader" , "optionalFooter" facets. The following elements are available in these facets: {currentMonthControl}, {nextMonthControl}, {nextYearControl}, {previousYearControl}, {previousMonthControl}, {todayControl}, {selectedDateControl}. These elements could be used for labels output.