Class TranslatableText

java.lang.Object
velox.gui.utils.localization.translatable.TranslatableText
All Implemented Interfaces:
TranslatableComponent

public class TranslatableText extends Object implements TranslatableComponent
You can use this class instead of LocalizedBundle.getString(String key, Map args) if the given text can be used on several locales at the same time.

This class support chainging with other TranslatableComponent classes when they passed as arguments
For a convenient use, extend this class with you own add-on specific class with a constructor that will call super constructor with a specific bundleName and classLoader (to not pass the bundleName and classLoader explicitly every time you create a new instance of TranslatableText)
See Also:
  • DemoStrategies see velox.api.layer1.simpledemo.localization.LocalizedAlertDemoTranslatableText class for an example
  • Constructor Details

    • TranslatableText

      public TranslatableText(String key, Map<String,Object> args, String bundleName, ClassLoader classLoader, boolean throwException)
      Get locale specific text by given key, and insert given arguments
      Parameters:
      key - translation key
      args - named arguments that should inserted in text
      bundleName - in which key is located
      classLoader - with which your classes were loaded from the jar
      throwException - if true we throw an exception if the key is not found in the given bundleName, otherwise return the key as is
    • TranslatableText

      public TranslatableText(String key, String bundleName, ClassLoader classLoader, boolean throwException)
      Get locale specific text by given key, without arguments
      Parameters:
      key - translation key
      bundleName - in which key is located
      classLoader - with which your classes were loaded from the jar
      throwException - if true we throw an exception if the key is not found in the given bundleName, otherwise return the key as is
  • Method Details