0
Hello I’m trying to do internationalization with Labels from an Enum:
public enum WeekDay {
MONDAY("msg.week_monday", "mon"),
TUESDAY("msg.week_tuesday", "tue"),
WEDNESDAY("msg.week_wednesday", "wed"),
THURSDAY("msg.week_thursday", "thu"),
FRIDAY("msg.week_friday", "fri"),
SATURDAY("msg.week_saturday", "sat"),
SUNDAY("msg.week_sunday", "sun");
private String label;
private String value;
private WeekDay(String label, String value) {
this.label = label;
this.value = value;
}
public String getLabel() {
return label;
}
public String getValue() {
return this.value;
}
}
and call on the page like this :
<f:selectItems value="#{myMB.weekDays}"
var="dayWeek" itemValue="#{dayWeek}"
itemLabel="#{dayWeek.label}" />
But the result is the literals of the Abels and not their corresponding in my msg.properties file.:
week_monday=Segunda-feira
week_tuesday=Ter\u00E7a-feira
week_wednesday=Quarta-feira
week_thursday=Quinta-feira
week_friday=Sexta-feira
week_saturday=S\u00E1bado
week_sunday=Domingo
When I call it that itemLabel="#{msg.week_monday}"
works, does anyone know how to do it? I’m having the same problem trying to translate fields coming from the bank.
Vlw Renato, I managed to simply change
itemLabel="#{msg[dayWeek.label]}
foritemLabel="#{msg[dayWeek.label]}"
– Ronaldo
I say: Vlw Renato, I managed to simply change
itemLabel="#{dayWeek.label}
foritemLabel="#{msg[dayWeek.label]}"
– Ronaldo