i18n filter ver. 1.3


This is a Java servlet filter (as per Servlet API 2.3). This filter provides a simple tool for the localization. Incoming requests say to some page index.jsp could be redirected to page index-eng.jsp, index-ru.jsp etc. depending on the locale in the request.

How to use it:

a) download i18nflt.jar and save it in WEB-INF/lib

b) describe this filter in web.xml.
 


<filter>
  <filter-name>I18nFilter</filter-name>
  <filter-class>com.cj.i18n.I18nFilter</filter-class>
</filter>

c) describe a mapping for this filter in web.xml
 


<filter-mapping>
  <filter-name>I18nFilter</filter-name>
  <url-pattern>*</url-pattern>
</filter-mapping>

in this case filter will be on for the each .jsp file for example.

Suppose now mypage.jsp is requested and incoming locale is English. Filter will check out file mypage-eng.jsp. If such a file exists than request will be redirected, otherwise it will be processed as is.

You can add also an additional parameter suffix, describes how to find a localized version of the file. Here FILE is a name of the source file (without extension), LANG - detected language, EXT - an original extension.
 


<filter-mapping>
  <filter-name>I18nFilter</filter-name>
  <url-pattern>*</url-pattern>
  <init-param>
   <param-name>suffix</param-name>
   <param-value>FILE-LANG.EXT</param-value>
  </init-param>
</filter-mapping>

default suffix is FILE-LANG.EXT.

   For downloading:

    i18n filter:  i18nflt.jar
 

 ©  Coldbeans     Comments?

See also JSOS - the largest collection of servlets and filters.

Also in JSOS: