Package freemarker.template

Source Code of freemarker.template.LocalizedString

package freemarker.template;

import freemarker.core.Environment;
import java.util.Locale;

/**
* An abstract base class for scalars that vary by locale.
* Here is a silly usage example.
* <code>
*    TemplateScalarModel localizedYes = new LocalizedString() {
*        public String getLocalizedString(java.util.Locale locale) {
*            String lang = locale.getLanguage();
*            if "fr".equals(lang)
*               return "oui";
*            else if "de".equals(lang)
*               return "s�";
*            else
*               return "yes";
*        } 
*    };
* </code>
* @author Jonathan Revusky
*/

abstract public class LocalizedString implements TemplateScalarModel {
 
 
  public String getAsString() throws TemplateModelException {
    Environment env = Environment.getCurrentEnvironment();
    Locale locale = env.getLocale();
    return getLocalizedString(locale);
  }
 
  abstract public String getLocalizedString(Locale locale) throws TemplateModelException;
}
TOP

Related Classes of freemarker.template.LocalizedString

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.