Class TranslationUtils
java.lang.Object
com.inductiveautomation.factorypmi.application.i18n.TranslationUtils
Tools used for translating component properties.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
FOR BUNDLE KEYS NOT IN COMPONENTS.static String
_t
(JComponent component, String bundleKey, Object... args) FOR BUNDLE KEYS.static MutableTranslationPackage
static MutableTranslationPackage
getComponentTranslations
(JComponent comp, boolean createIfNecessary) static Dataset
getTranslatedDataset
(Dataset ds, int labelColumnIndex, JComponent component) static Dataset
getTranslatedDataset
(Dataset ds, int labelColumnIndex, JComponent component, boolean translateColumnNames) protected static boolean
static boolean
isTranslatable
(JComponent source) static MutableTranslationPackage
merge
(TranslationPackage first, TranslationPackage second) Creates a new TranslationPackage with all the keys fromfirst
, potentially overwritten by any duplicate keys fromsecond
.static void
putComponentTranslations
(JComponent comp, TranslationPackage translations) static String
NOT FOR BUNDLE KEYS, and not for components.static String
t
(JComponent component, String term) NOT FOR BUNDLE KEYS.static String
translate
(JComponent component, String term) This class returns the best translation available for the specified term in the provided component.static String
translate
(JComponent component, String term, boolean strict) 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.static String
translateSimple
(String term) 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.
-
Constructor Details
-
TranslationUtils
public TranslationUtils()
-
-
Method Details
-
isClientTranslationEnabled
protected static boolean isClientTranslationEnabled() -
getComponentTranslations
public static MutableTranslationPackage getComponentTranslations(JComponent comp, boolean createIfNecessary) -
createComponentTranslations
-
putComponentTranslations
-
merge
public static MutableTranslationPackage merge(@Nullable TranslationPackage first, @Nullable TranslationPackage second) Creates a new TranslationPackage with all the keys fromfirst
, potentially overwritten by any duplicate keys fromsecond
. -
t
NOT FOR BUNDLE KEYS. Short form version of translate(). -
t
NOT FOR BUNDLE KEYS, and not for components. Short form of translate() -
translate
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
-
translateSimple
-
_t
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
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
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
-
getTranslatedDataset
-
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 withtime
- the String which has English time units (days, hours, minutes or seconds) to be translatedsecKey
- the BundleUtil bundlekeys for each respective property wanting to translate
-