Package freemarker.template
Class LocalizedString
java.lang.Object
freemarker.template.LocalizedString
- All Implemented Interfaces:
TemplateModel,TemplateScalarModel
- Direct Known Subclasses:
ResourceBundleLocalizedString
An abstract base class for scalars that vary by locale.
Here is a silly usage example.
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";
}
};
-
Field Summary
Fields inherited from interface freemarker.template.TemplateModel
NOTHINGFields inherited from interface freemarker.template.TemplateScalarModel
EMPTY_STRING -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns theStringrepresentation of this model.abstract StringgetLocalizedString(Locale locale)
-
Constructor Details
-
LocalizedString
public LocalizedString()
-
-
Method Details
-
getAsString
Description copied from interface:TemplateScalarModelReturns theStringrepresentation of this model. Returningnullis illegal, and may cause exception in the calling code. (Except, in classic-compatible mode the engine will convertnullinto empty string.)- Specified by:
getAsStringin interfaceTemplateScalarModel- Throws:
TemplateModelException
-
getLocalizedString
- Throws:
TemplateModelException
-