Class TranslationUtils

java.lang.Object
com.inductiveautomation.factorypmi.application.i18n.TranslationUtils

public class TranslationUtils extends Object
Tools used for translating component properties.
  • Constructor Details

    • TranslationUtils

      public TranslationUtils()
  • Method Details

    • isClientTranslationEnabled

      protected static boolean isClientTranslationEnabled()
    • getComponentTranslations

      public static MutableTranslationPackage getComponentTranslations(JComponent comp, boolean createIfNecessary)
    • createComponentTranslations

      public static MutableTranslationPackage createComponentTranslations(JComponent comp)
    • putComponentTranslations

      public static void putComponentTranslations(JComponent comp, TranslationPackage translations)
    • merge

      public static MutableTranslationPackage merge(@Nullable TranslationPackage first, @Nullable TranslationPackage second)
      Creates a new TranslationPackage with all the keys from first, potentially overwritten by any duplicate keys from second.
    • t

      public static String t(JComponent component, String term)
      NOT FOR BUNDLE KEYS. Short form version of translate().
    • t

      public static String t(String term)
      NOT FOR BUNDLE KEYS, and not for components. Short form of translate()
    • translate

      public static String translate(JComponent component, String term)
      This class returns the best translation available for the specified term in the provided component. It will first look for a translation package on the component, and then will go to the client localization manager.
      Parameters:
      term - generally the name of the property on the component, but may be more complex for more advanced term situations.
    • translate

      public static String translate(JComponent component, String term, boolean strict)
    • translateSimple

      public static String translateSimple(String term)
    • _t

      public static String _t(JComponent component, String bundleKey, Object... args)
      FOR BUNDLE KEYS. This is a short-form version of translateBundleString(). See that function for more information. In short, it translates a bundle key through the translation system if possible, otherwise going to the bundle system.
    • _t

      public static String _t(String bundleKey, Object... args)
      FOR BUNDLE KEYS NOT IN COMPONENTS. Any components that support local localization should use the other overload that accepts the component as a parameter. This version tries to get a translation for this term from the translation system if possible, and then goes to the bundle system.
    • translateBundleString

      public static String translateBundleString(JComponent component, String bundleKey, Object... args)
      This function first attempts to locate the english version of the bundleKey, translate it through the client translation system, and then if unsuccessful, it will try to get the translation from bundleutil.
    • isTranslatable

      public static boolean isTranslatable(JComponent source)
    • getTranslatedDataset

      public static Dataset getTranslatedDataset(Dataset ds, int labelColumnIndex, JComponent component)
    • getTranslatedDataset

      public static Dataset getTranslatedDataset(Dataset ds, int labelColumnIndex, JComponent component, boolean translateColumnNames)
    • translateTimeString

      public static String translateTimeString(JComponent component, String time, String dayKey, String hourKey, String minKey, String secKey)
      Translates a Formatted Time String containing string literal time units delimited by either commas or spaces. example: "23 minutes, 14 seconds" will be converted to active translation language equivalent.

      Possible (likely) this won't work for all locales/languages, should really only be used in situations where the string source is a Gateway generated English string, and other translation methods aren't available.

      Parameters:
      component - the Vision component that the bundlekeys are registered with
      time - the String which has English time units (days, hours, minutes or seconds) to be translated
      secKey - the BundleUtil bundlekeys for each respective property wanting to translate