diff --git a/doc/docbook/acegi.xml b/doc/docbook/acegi.xml index 8dce5b71ec..108f32235b 100644 --- a/doc/docbook/acegi.xml +++ b/doc/docbook/acegi.xml @@ -405,6 +405,65 @@ context property on the HttpSessionContextIntegrationFilter bean. + + + Localization + + From 1.0.0, Acegi Security supports localization of exception + messages that end users are likely to see. Such exceptions include + authentication failures and access being denied (authorization + failures). Exceptions and logging that is focused on developers or + system deployers (including incorrect attributes, interface contract + violations, using incorrect constructors, startup time validation, + debug-level logging) etc are not localized and instead are hard-coded + in English within Acegi Security's code. + + Shipping in the acegi-security-xx.jar inside + the org.acegisecurity package is a + messages.properties file. 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 Spring documentation + for further details on using LocaleContextHolder + and the helper classes that can automatically set it for you (eg + AcceptHeaderLocaleResolver, + CookieLocaleResolver, + FixedLocaleResolver, + SessionLocaleResolver etc) +