Class TranslateBundleFunction

java.lang.Object
com.github.mustachejava.functions.TranslateBundleFunction
All Implemented Interfaces:
TemplateFunction, Function<String,String>

public class TranslateBundleFunction extends Object implements TemplateFunction
Mustache.java translation function based on localized ResourceBundles. Usage code with a class: public class ... { TemplateFunction trans = new TranslateBundleFunction("com.project.locale", Locale.US); ... } Usage code with a Map: HashMap<String, Object> scopes = new HashMap<String, Object>(); scopes.put("trans", new TranslateBundleFunction("com.project.locale", Locale.US)); ... Usage in template: ... {{#trans}}TranslatedLabel1{{/trans}} ... ... {{#trans}}TranslatedLabel2 param1=newparam1 param2=newparma2{{/trans}}
  • Field Details

  • Constructor Details

    • TranslateBundleFunction

      public TranslateBundleFunction(String bundle, Locale locale)
      Constructor for a Mustache.java translation function.
      Parameters:
      bundle - resource bundle name
      locale - translation locale
  • Method Details