2013年2月4日 星期一

Struts2 Internationalization (i18n) & Localization (l10n)

細節可參考:Localization
但這裡想要強調的是Resource Bundle Search Order,官方文件說明如下:
Resource bundles are searched in the following order:
  1. ActionClass.properties
  2. Interface.properties (every interface and sub-interface)
  3. BaseClass.properties (all the way to Object.properties)
  4. ModelDriven's model (if implements ModelDriven), for the model object repeat from 1
  5. package.properties (of the directory where class is located and every parent directory all the way to the root directory)
  6. search up the i18n message key hierarchy itself
  7. global resource properties
在程式開發的時候,一開始為了避免同時修改properties可能會盡量從ActionClass.properties做起,但隨著系統開發過程應該將公用的部分逐漸往search order下方移,又或是在SA / SD階段就整理出已確定會公用的部分,直接一開始就寫在package.properties甚至是global resource properties裡面,但不管如何,這些properties的整理雖然很繁瑣,但卻不可忽視。