生命在于運動

          Chapter 3. Supporting Infrastructure (todo)

          第三章 支撐體系

          本章我們將介紹Acegi Security用到的輔助架構和支撐架構。Acegi Security具有的那些不是直接和安全相關的功能將在討論。

           

          3.1. Localization(本地化)

          Acegi Security 支持本地化的異常信息,終端用戶顯然會更喜歡看到這些本地化的信息。如果你的應用程序是針對英文用戶開發的,那么恭喜你,你不用做任何的工作,默認情況下Acegi Security信息都是英文的。如果你要支持其他的本地化特性,那么你需要了解這章節所有的信息了。所有的異常信息都可以本地化的,包括驗證失敗、訪問被拒。開發者或者系統配置人員所關心的異常和日志(包括錯誤屬性、interface contract violations, 錯誤使用構造方法、啟動時候的驗證、debug-level日志)等是不能本地化的,這些是用英文被硬編碼在Acegi Security的代碼中了。打開acegi-security-xx.jar,在org.acegisecurity包下面可以找到messages.properties文件。

          This should be referred to by your ApplicationContext, as Acegi Security classes implement Spring's MessageSourceAware interface and expect the message resolver to be dependency injected at application context startup time. Usually all you need to do is register a bean inside your application context to refer to the messages. An example is shown below:

          <bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">

          <property name="basename"><value>org/acegisecurity/messages</value></property>

          </bean>

          The messages.properties is named in accordance with standard resource bundles and represents the

          default language supported by Acegi Securtiy messages. This default file is in English. If you do not

          register a message source, Acegi Security will still work correctly and fallback to hard-coded English

          versions of the messages.

          If you wish to customize the messages.properties file, or support other languages, you should copy the

          file, rename it accordingly, and register it inside the above bean definition. There are not a large

          number of message keys inside this file, so localization should not be considered a major initiative. If

          you do perform localization of this file, please consider sharing your work with the community by

          logging a JIRA task and attaching your appropriately-named localized version of messages.properties.

          Rounding out the discussion on localization is the Spring ThreadLocal known as

          org.springframework.context.i18n.LocaleContextHolder. You should set the LocaleContextHolder to

          represent the preferred Locale of each user. Acegi Security will attempt to locate a message from the

          message source using the Locale obtained from this ThreadLocal. Please refer to Springdocumentation

          for further details on using LocaleContextHolder and the helper classes that can automatically set it for

          you (eg AcceptHeaderLocaleResolver, CookieLocaleResolver, FixedLocaleResolver, SessionLocaleResolver

          etc)

          //本地化實在是個好東西,只是現在工作用不到,所以留在后面翻譯了。

          posted on 2008-01-10 17:33 burrows 閱讀(247) 評論(0)  編輯  收藏 所屬分類: Acegi Security 參考文檔翻譯

          主站蜘蛛池模板: 将乐县| 鹿邑县| 兴城市| 绥宁县| 高淳县| 雷山县| 迭部县| 嘉义县| 揭阳市| 嫩江县| 枣庄市| 清新县| 长宁县| 嘉黎县| 武清区| 巩留县| 卢龙县| 化隆| 治多县| 类乌齐县| 邹城市| 永兴县| 贵溪市| 崇信县| 兴宁市| 阳高县| 江口县| 克什克腾旗| 中江县| 鸡西市| 龙川县| 乌鲁木齐县| 贡觉县| 南宫市| 宁津县| 屏山县| 桑日县| 德钦县| 葵青区| 阿勒泰市| 大同市|