Class VanEngine

java.lang.Object
dev.vanengine.core.VanEngine

public class VanEngine extends Object
  • Constructor Details

  • Method Details

    • setBasePath

      public void setBasePath(Path basePath)
    • setDefaultLocale

      public void setDefaultLocale(String defaultLocale)
    • getDefaultLocale

      public String getDefaultLocale()
    • setMissingKeyStrategy

      public void setMissingKeyStrategy(MissingKeyStrategy missingKeyStrategy)
    • getMissingKeyStrategy

      public MissingKeyStrategy getMissingKeyStrategy()
    • setGlobalName

      public void setGlobalName(String globalName)
    • addI18nMessages

      public void addI18nMessages(String locale, Map<String,Object> messages)
      Register translation messages for a locale.
    • addI18nFileParser

      public void addI18nFileParser(I18nFileParser parser)
      Register an additional i18n file parser (e.g. YAML).
    • supportedI18nExtensions

      public Set<String> supportedI18nExtensions()
      Return all file extensions currently supported by registered parsers.
    • loadI18nFromStream

      public void loadI18nFromStream(String locale, String extension, InputStream inputStream) throws IOException
      Load i18n messages from a stream. Used by starter for classpath loading.
      Throws:
      IOException
    • getI18nMessages

      public Map<String,Object> getI18nMessages(String locale)
      Get translation messages for the given locale with key-level merge fallback. E.g. for zh-CN: deep-merge en + zh + zh-cn (highest priority last).
    • hasI18nMessages

      public boolean hasI18nMessages()
      Whether any i18n messages have been loaded.
    • getBasePath

      public Path getBasePath()
    • loadI18nFiles

      public void loadI18nFiles(Path i18nDir)
      Scan an i18n directory for translation files and load them. Supports all extensions registered via addI18nFileParser(I18nFileParser).
    • reloadI18nFiles

      public void reloadI18nFiles()
      Clear and reload all i18n files from the basePath/i18n directory.
    • builder

      public static VanEngine.Builder builder()
    • getTemplate

      public VanTemplate getTemplate(String templatePath) throws IOException
      Compile a .van file from the filesystem and return a reusable template.
      Throws:
      IOException
    • getTemplate

      public VanTemplate getTemplate(String entryPath, Map<String,String> files) throws IOException
      Compile from an explicit files map (for classpath resources) and return a reusable template.
      Throws:
      IOException
    • getLiteralTemplate

      public VanTemplate getLiteralTemplate(String templateContent) throws IOException
      Compile an inline template string and return a reusable template.
      Throws:
      IOException
    • getMessage

      public String getMessage(String key, String locale, Map<String,?> params)
      Get a translated message by dot-separated key, with {placeholder} replacement. Returns the formatted message, or the key itself if not found.
    • getMessage

      public String getMessage(String key, String locale)
      Get a translated message by dot-separated key (no parameters).
    • findMissingKeys

      public Map<String, Set<String>> findMissingKeys()
      Find keys present in defaultLocale but missing in other locales. Returns a map of locale → set of missing dot-separated keys.
    • compile

      public String compile(String templatePath, Map<String,?> model) throws IOException
      Compile a .van file and evaluate with model data in one step.
      Throws:
      IOException
    • compileLiteral

      public String compileLiteral(String templateContent, Map<String,?> model) throws IOException
      Compile an inline template and evaluate with model data in one step.
      Throws:
      IOException