Enum标签的国际化

时间:2016-03-30 11:50:38

标签: java enums internationalization

我正试图将来自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;

        }
    }

在我的selectOneMenu上我得到了这个标签的列表:

    <f:selectItems value="#{myMB.weekDays}"
                                        var="dayWeek" itemValue="#{dayWeek}"
                                        itemLabel="#{dayWeek.label}" />

我在message.properties上有一些翻译,但我无法用Enum标签显示翻译。如果我使用简单的itemLabel="#{msg.week_monday}"作品。

0 个答案:

没有答案