2012-10-29 26 views
1

我正在對一個相當大的GWT UIbinder代碼庫進行本地化,並且在設置屬性的過程不起作用的幾個實例中運行。如何本地化DateLabel和NumberLabel customFormat屬性?

DateLabel javadoc

NumberLabel javadoc

我需要指定爲DateLabel和NumberLabel小窗口的LocalizableResource_xx.properties文件中的日期格式和數字格式。

我試圖轉換使用the ui:attribute method該片段

<g:DateLabel styleName="{style.formPromptData}" 
     ui:field="createDate" customFormat="MMM d, yyyy" /> 

沒有成功

調用發生器com.google.gwt.uibinder.rebind.UiBinderGenerator [ERROR]無方法發現應用消息屬性customFormat Element(:63)

有沒有一種方法來定位這些元素?

+0

爲什麼你需要本地化他們?只要您使用PredefinedFormat,它們已經是特定於語言環境的。 –

+0

@AndreiVolgin問題是關於'customFormat',而不是預定義的格式。 –

+0

@ThomasBroyer準確無誤。那麼爲什麼試圖本地化customFormat,當他們可以使用已經本地化的PredefinedFormat。 –

回答

3

customFormat="XXX"轉換爲DateTimeFormat.getFormat("XXX")與本地化無關:也就是說,它不是本地化的。

如果你想有一個本地化的自定義格式,使用CustomDateTimeFormat(目前依靠ICU4J的DateTimePatternGenerator)或ConstantsMessages接口。用<ui:with>實例化它並使用customFormat="{intf.customPattern}"(實際上如果使用CustomDateTimeFormat,則爲format="{intf.customPattern}")。