Chapter 11. Messages
為了設置資源綁定,你應該如下例所示在/WEB-INF/web.xml文件中聲明一個context-param,并 指定你的資源文件的路徑:
<context-param>
<param-name>extremecomponentsMessagesLocation</param-name>
<param-value>org/extremesite/resource/extremecomponentsResourceBundle</param-value>
</context-param>
本示例中資源文件為extremecomponentsResourceBundle,它可以為任何名或者使用已經存在的資源文件。
如果你不指定locale,則它將根據你的servlet request來決定使用哪個資源文件。 在eXtremeTable中可以通過使用TableTag的locale屬性來設置它。
<ec:table
items="presidents"
action="${pageContext.request.contextPath}/public/demo/locale.jsp"
title="table.title.president"
locale="de_DE"
>
...
</ec:table>
在這里eXtremeTable將尋找德文資源文件。
eXtremeTable使用一些全局的keys來與用戶交互,包括:狀態欄的文本信息,Rows Displayed droplist和不同的tooltips。如果你足夠幸運,eXtremeTable已經提供了相應的語言支持 的話,那么你什么也不用擔心。否則的話,你需要申明下列keys:
statusbar.resultsFound={0} results found, displaying {1} to {2}
statusbar.noResultsFound=There were no results found.
toolbar.firstPageTooltip=First Page
toolbar.lastPageTooltip=Last Page
toolbar.prevPageTooltip=Previous Page
toolbar.nextPageTooltip=Next Page
toolbar.filterTooltip=Filter
toolbar.clearTooltip=Clear
toolbar.clearText=Clear
toolbar.firstPageText=First
toolbar.lastPageText=Last
toolbar.nextPageText=Next
toolbar.prevPageText=Prev
toolbar.filterText=Filter
column.headercell.sortTooltip=Sort By
column.calc.total=Total
column.calc.average=Average
現在僅支持英語和德語。如果你使用其他語言的話,并能提供相應的翻譯的話我將不勝感激。你可以通過 extremecomponents@gmail.com發送給我。
譯者注:我已經提供了中文和日文的資源文件。
TableTag屬性中能夠使用locale方式指定的是:imagePath和title。
在eXtremeTable中,imagePath屬性有一個特定的key:table.imagePath。你可以在你的資源文件中 設置這個key為特定語言的目錄結構。例如:德文圖片可能放在de文件夾下,那么你可以在相應的資源文件中 進行如下設置:
table.imagePath=/extremesite/images/table/de/*.gif
title有一點不同,如果你指定的title屬性值包含dot (.)并且你定義了一個資源文件,那么 eXtremeTable將尋找匹配的key。例如,如果你像下例一樣在表中指定屬性title="table.title.president":
<ec:table
items="presidents"
action="${pageContext.request.contextPath}/public/demo/locale.jsp"
title="table.title.president"
>
...
</ec:table>
那么eXtremeTable將在屬性文件中尋找匹配的key:
table.title.president=US Pr?sidenten
ColumnTag屬性中能夠使用locale方式指定的是:format和title。
在eXtremeTable中,format屬性有一個特定的key:table.fomat.type。參考屬性文件的討論 來了解更多的細節,他們具有同樣的概念。日期和貨幣的format類型定義可能如下所示:
column.format.date=MM/dd/yyyy
column.format.currency=$###,###,##0.00
title有一點不同,如果你指定的title屬性值包含dot (.)并且你定義了一個資源文件,那么 eXtremeTable將尋找匹配的key。例如,如果你像下例一樣在列中指定屬性title="table.column.nickName":
<ec:table
items="presidents"
action="${pageContext.request.contextPath}/public/demo/locale.jsp"
title="table.title.president"
>
<ec:row>
<ec:column property="nickName" title="table.column.nickName" />
</ec:row>
</ec:table>
那么eXtremeTable將在屬性文件中尋找匹配的key:
table.column.nickName=Spitzname
posted on 2006-02-28 09:54 Lucky 閱讀(680) 評論(0) 編輯 收藏 所屬分類: extremeComponents