- In '${TOMCAT_HOME}/shared/classes/alfresco/web-extension' create a context file by naming it to 'custom-slingshot-application-context.xml'. I believe the only important thing here is that it ends with '-context.xml'.
- In this file define a Spring Bean by using the following code:
<?xml version='1.0' encoding='UTF-8'?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:hz="http://www.hazelcast.com/schema/config" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.hazelcast.com/schema/config http://www.hazelcast.com/schema/config/hazelcast-spring.xsd"> <bean id='localeResolver' class='de.ecmgeek.alfresco.MyLocaleResolver'/> </beans>
Now you can just implement your own LocaleResolver and put it to the classpath (E.G. as a JAR file):
package de.ecmgeek.alfresco;
import java.util.Locale;
import javax.servlet.http.HttpServletRequest;
import org.springframework.extensions.surf.mvc.LocaleResolver;
import org.springframework.extensions.surf.util.I18NUtil;
public class MyLocaleResolver extends LocaleResolver
{
@Override
public Locale resolveLocale(HttpServletRequest request)
{
/* Here we could set the locale by getting the value of the
cookie with the name ALFRESCO_UI_PREFLANG or by handling
a request parameter. For now this value is just null. */
Locale locale = null;
if (locale == null)
{
//To set a constant value
locale = I18NUtil.parseLocale("en_EN");
}
I18NUtil.setLocale(locale);
return locale;
}
}
No comments:
Post a Comment