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

com.frameworkset.platform.util.I18nResource Maven / Gradle / Ivy

There is a newer version: 5.6.4
Show newest version
package com.frameworkset.platform.util;

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

import javax.servlet.http.HttpServletRequest;

import org.frameworkset.web.servlet.support.RequestContextUtils;

public abstract class I18nResource implements java.io.Serializable{
	protected Map localeNames;
	protected Map localeDescriptions;
    public Map getLocaleNames() {
		return localeNames;
	}
	public void setLocaleNames(Map localeNames) {
		this.localeNames = localeNames;
	}
	public Map getLocaleDescriptions() {
		return localeDescriptions;
	}
	public void setLocaleDescriptions(Map localeDescriptions) {
		this.localeDescriptions = localeDescriptions;
	}
	public String getName(HttpServletRequest request) {
    	
//    	if(this.localeNames == null)
//    		return null;
//    	Locale locale = RequestContextUtils.getRequestContextLocal(request);
//    	String temp = this.localeNames.get(locale);
//    	if(temp == null)
//    		return null;
//    	return temp;
//    	
    	return getLocaleMessage(localeNames, request);
    }
	
	public String getDescription(HttpServletRequest request) {
    	
//    	if(this.localeDescriptions == null)
//    		return null;
//    	Locale locale = RequestContextUtils.getRequestContextLocal(request);
//    	String temp = this.localeDescriptions.get(locale);
//    	if(temp == null)
//    		return null;
//    	return temp;
    	return getLocaleMessage(localeDescriptions, request);
    }
	
	private String getLocaleMessage(Map messages,HttpServletRequest request) {
    	
    	if(messages == null)
    		return null;
    	Locale locale = RequestContextUtils.getRequestContextLocal(request);
    	String temp = messages.get(locale);
    	if(temp == null)
    		return null;
    	return temp;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy