鷹翔宇空

          學習和生活

          BlogJava 首頁 新隨筆 聯系 聚合 管理
            110 Posts :: 141 Stories :: 315 Comments :: 1 Trackbacks
          原文引自:http://fjy26.itpub.net/

          1. configure web.xml,insert following tag:
            <init-param>
            <param-name>locale</param-name>
            <param-value>true</param-value>
            </init-param>
            codes above enable localization.
          2. configure web.xml,insert following tag:
            <init-param>
            <param-name>application</param-name>
            <paramvalue>ApplicationResources</param-value>
            </init-param>
            codes above indicate where default resource(ApplicationResources.properties) file reside in.If a specific resource locale is required, the actionServlet will look for resource file named ApplicationResources_xx_XX.properties according to locale. for example:ApplicationResources_en_us.properties
            hint:the default path of resource file is WEB-INF/classes/.
          3. using the struts framework locale object.
            after above two steps, struts stores a locale object in session context,you can get the object using following codes:
            Locale locale=(Locale)request.getSession().getAttribute(Action.LOCALE_KEY);
          4. changing user's locale
            Since locale is immutable ,you must create a new locale object to replace existing one:
            Locale locale=new Locale(myForm.getLanguage(),myForm.getCountry());
            HttpSession session=request.getSession(true);
            session.setAttribute(Action.LOCALE_KEY,locale);
          5. placing labels and messages in properties files.
          6. creating language-specified properties file for every locale you will support. if properly named,these files will be loaded automatically.if the application can't find a key in the resource for a user's locale,it will use the resource for the default locale.
          7. localization-aware components VS other components
            usually,most struts components support I18N automatically.for the components that do not have lacalization built in,you can usually use<bean:message> to provide localized message.
          8. localizing other components: validation and tiles
            validation:all the labels and messages used by validator are linked to resource file and will be localized automatically.if additional localization be needed ,say to verify the format of a postal code or telephone number ,you can define a locale-specfic formset element like this:
            <form name="testform" locale="fr" country="CA">...
            tiles:you can define xml file according to locale like resource file :
            tiles_fr_CA.xml
          posted on 2006-04-20 17:03 TrampEagle 閱讀(347) 評論(0)  編輯  收藏 所屬分類: 技術文摘
          主站蜘蛛池模板: 万州区| 罗田县| 温宿县| 阿鲁科尔沁旗| 宾阳县| 固镇县| 肃宁县| 金坛市| 遂溪县| 扎囊县| 南郑县| 牙克石市| 广饶县| 龙江县| 抚顺市| 香格里拉县| 咸阳市| 庆元县| 宁城县| 苍梧县| 金华市| 基隆市| 道孚县| 永年县| 宁南县| 扶余县| 长寿区| 女性| 莒南县| 通海县| 柳河县| 枣庄市| 巫山县| 榕江县| 凌海市| 讷河市| 黄浦区| 鸡东县| 嘉善县| 城步| 平凉市|