All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.frameworkset.web.servlet.i18n.LanguageLocaleResolver Maven / Gradle / Ivy

Go to download

bboss is a j2ee framework include aop/ioc,mvc,persistent,taglib,rpc,event ,bean-xml serializable and so on.http://www.bbossgroups.com

The newest version!
/**
 *  Copyright 2008 biaoping.yin
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.  
 */
package org.frameworkset.web.servlet.i18n;

import java.util.Locale;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.frameworkset.spi.InitializingBean;

import com.frameworkset.util.SimpleStringUtil;

/**
 * 

CharsetLocaleResolver.java

*

Description:

*

bboss workgroup

*

Copyright (c) 2005-2013

* * @Date 2013年11月26日 * @author biaoping.yin * @version 1.0 */ public class LanguageLocaleResolver extends AbstractLocaleResolver implements InitializingBean{ private String language = "zh_CN"; private Locale locale; public LanguageLocaleResolver() { // TODO Auto-generated constructor stub } @Override public Locale resolveLocale(HttpServletRequest request) { // TODO Auto-generated method stub return locale != null?locale:defaultLocal; } @Override public void afterPropertiesSet() throws Exception { if(this.language == null || this.language.equals("")) { language = "zh_CN"; } Map locales = SimpleStringUtil.getAllLocales(); locale = locales.get(language); } public String resolveLocaleCode(HttpServletRequest request) { return this.language; } public String getLanguage() { return language; } public void setLanguage(String language) { this.language = language; } @Override public void setLocale(HttpServletRequest request, HttpServletResponse response, Locale locale) { if(locale == null) return; this.language = locale.toString(); this.locale = locale; } @Override public void setLocale(HttpServletRequest request, HttpServletResponse response, String locale) { if(locale == null || locale.equals("")) return; this.language = locale; Map locales = SimpleStringUtil.getAllLocales(); this.locale = locales.get(language); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy