Package org.nuclos.api.provider
Class LocalizationProvider
java.lang.Object
org.nuclos.api.provider.LocalizationProvider
Provider class for localization and translation services in the Nuclos system.
This class offers methods to translate text with or without persistence, get formatting information,
and handle locale-specific operations.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringGets the short date format pattern for the current locale.static StringGets the decimal separator for numbers in the current locale.static StringGets the grouping separator for numbers in the current locale.static StringGets the medium time format pattern for the current locale.static StringGets the short time format pattern for the current locale.voidstatic StringTranslates a text using the specified key and the best matching source locale.static StringTranslates a text using the specified key and source locale.static StringTranslates a text using the specified key, source locale, and target locale.static Stringtranslate(String key, String text, Locale sourceLocale, Locale targetLocale, int timeoutMillisForTranslatorRequest) Translates a text using the specified key, source locale, target locale, and custom timeout.static Stringtranslate(String key, String text, NuclosLocale sourceLocale) Translates a text using the specified key and Nuclos source locale.static Stringtranslate(String key, String text, NuclosLocale sourceLocale, NuclosLocale targetLocale) Translates a text using the specified key, Nuclos source locale, and Nuclos target locale.static Stringtranslate(String key, String text, NuclosLocale sourceLocale, NuclosLocale targetLocale, int timeoutMillisForTranslatorRequest) Translates a text using the specified key, Nuclos source locale, Nuclos target locale, and custom timeout.static StringTranslates a text using the specified source and target locales.static Stringtranslate(String text, Locale sourceLocale, Locale targetLocale, int timeoutMillisForTranslatorRequest) Translates a text using the specified source and target locales with a custom timeout.static Stringtranslate(String text, NuclosLocale sourceLocale, NuclosLocale targetLocale) Translates a text using the specified Nuclos source and target locales.static Stringtranslate(String text, NuclosLocale sourceLocale, NuclosLocale targetLocale, int timeoutMillisForTranslatorRequest) Translates a text using the specified Nuclos source and target locales with a custom timeout.static Stringtranslate_de(String key, String deText) Translates a text from German using the specified key.static Stringtranslate_en(String key, String enText) Translates a text from English using the specified key.static StringtranslateChecked(String key, String text) Translates a text using the specified key and the best matching source locale and throws an exception if translation fails.static StringtranslateChecked(String key, String text, Locale sourceLocale) Translates a text using the specified key and source locale and throws an exception if translation fails.static StringtranslateChecked(String key, String text, Locale sourceLocale, Locale targetLocale) Translates a text using the specified key, source locale, and target locale and throws an exception if translation fails.static StringtranslateChecked(String key, String text, Locale sourceLocale, Locale targetLocale, int timeoutMillisForTranslatorRequest) Translates a text using the specified key, source locale, target locale, and custom timeout and throws an exception if translation fails.static StringtranslateChecked(String key, String text, NuclosLocale sourceLocale) Translates a text using the specified key and Nuclos source locale and throws an exception if translation fails.static StringtranslateChecked(String key, String text, NuclosLocale sourceLocale, NuclosLocale targetLocale) Translates a text using the specified key, Nuclos source locale, and Nuclos target locale and throws an exception if translation fails.static StringtranslateChecked(String key, String text, NuclosLocale sourceLocale, NuclosLocale targetLocale, int timeoutMillisForTranslatorRequest) Translates a text using the specified key, Nuclos source locale, Nuclos target locale, and custom timeout and throws an exception if translation fails.static StringtranslateChecked(String text, Locale sourceLocale, Locale targetLocale) Translates a text and throws an exception if translation fails.static StringtranslateChecked(String text, Locale sourceLocale, Locale targetLocale, int timeoutMillisForTranslatorRequest) Translates a text using the specified source and target locales with a custom timeout and throws an exception if translation fails.static StringtranslateChecked(String text, NuclosLocale sourceLocale, NuclosLocale targetLocale) Translates a text using the specified Nuclos source and target locales and throws an exception if translation fails.static StringtranslateChecked(String text, NuclosLocale sourceLocale, NuclosLocale targetLocale, int timeoutMillisForTranslatorRequest) Translates a text using the specified Nuclos source and target locales with a custom timeout and throws an exception if translation fails.static StringtranslateChecked_de(String key, String deText) Translates a text from German using the specified key and throws an exception if translation fails.static StringtranslateChecked_en(String key, String enText) Translates a text from English using the specified key and throws an exception if translation fails.static StringTranslates a text in memory only (not persisted) and throws an exception if translation fails.static StringtranslateCheckedInMemory(String text, Locale sourceLocale) Translates a text in memory only (not persisted) using the specified source locale and throws an exception if translation fails.static StringtranslateCheckedInMemory(String text, Locale sourceLocale, Locale targetLocale) Translates a text in memory only (not persisted) using the specified source and target locales and throws an exception if translation fails.static StringtranslateCheckedInMemory(String text, Locale sourceLocale, Locale targetLocale, int timeoutMillisForTranslatorRequest) Translates a text in memory only (not persisted) using the specified source and target locales with a custom timeout and throws an exception if translation fails.static StringtranslateCheckedInMemory(String text, NuclosLocale sourceLocale) Translates a text in memory only (not persisted) using the specified Nuclos source locale and throws an exception if translation fails.static StringtranslateCheckedInMemory(String text, NuclosLocale sourceLocale, NuclosLocale targetLocale) Translates a text in memory only (not persisted) using the specified Nuclos source and target locales and throws an exception if translation fails.static StringtranslateCheckedInMemory(String text, NuclosLocale sourceLocale, NuclosLocale targetLocale, int timeoutMillisForTranslatorRequest) Translates a text in memory only (not persisted) using the specified Nuclos source and target locales with a custom timeout and throws an exception if translation fails.static StringtranslateInMemory(String text) Translates a text in memory only (not persisted) using the best matching source locale.static StringtranslateInMemory(String text, Locale sourceLocale) Translates a text in memory only (not persisted) using the specified source locale.static StringtranslateInMemory(String text, Locale sourceLocale, Locale targetLocale) Translates a text in memory only (not persisted) using the specified source and target locales.static StringtranslateInMemory(String text, Locale sourceLocale, Locale targetLocale, int timeoutMillisForTranslatorRequest) Translates a text in memory only (not persisted) using the specified source and target locales with a custom timeout.static StringtranslateInMemory(String text, NuclosLocale sourceLocale) Translates a text in memory only (not persisted) using the specified Nuclos source locale.static StringtranslateInMemory(String text, NuclosLocale sourceLocale, NuclosLocale targetLocale) Translates a text in memory only (not persisted) using the specified Nuclos source and target locales.static StringtranslateInMemory(String text, NuclosLocale sourceLocale, NuclosLocale targetLocale, int timeoutMillisForTranslatorRequest) Translates a text in memory only (not persisted) using the specified Nuclos source and target locales with a custom timeout.
-
Field Details
-
DEFAULT_TRANSLATOR_REQUEST_TIMEOUT_IN_MILLIS
public static final int DEFAULT_TRANSLATOR_REQUEST_TIMEOUT_IN_MILLIS- See Also:
-
-
Constructor Details
-
LocalizationProvider
LocalizationProvider()
-
-
Method Details
-
setLocalizationService
-
getDateFormatShort
Gets the short date format pattern for the current locale.- Returns:
- The short date format pattern
-
getTimeFormatShort
Gets the short time format pattern for the current locale.- Returns:
- The short time format pattern
-
getTimeFormatMedium
Gets the medium time format pattern for the current locale.- Returns:
- The medium time format pattern
-
getGroupingSeparator
Gets the grouping separator for numbers in the current locale.- Returns:
- The grouping separator
-
getDecimalSeparator
Gets the decimal separator for numbers in the current locale.- Returns:
- The decimal separator
-
translateInMemory
Translates a text in memory only (not persisted) using the best matching source locale.- Parameters:
text- The text to translate- Returns:
- The translated text
-
translateInMemory
Translates a text in memory only (not persisted) using the specified source locale.- Parameters:
text- The text to translatesourceLocale- The source locale of the text- Returns:
- The translated text
-
translateInMemory
Translates a text in memory only (not persisted) using the specified Nuclos source locale.- Parameters:
text- The text to translatesourceLocale- The Nuclos source locale of the text- Returns:
- The translated text
-
translateInMemory
Translates a text in memory only (not persisted) using the specified source and target locales.- Parameters:
text- The text to translatesourceLocale- The source locale of the texttargetLocale- The target locale for translation- Returns:
- The translated text
-
translateInMemory
public static String translateInMemory(String text, NuclosLocale sourceLocale, NuclosLocale targetLocale) Translates a text in memory only (not persisted) using the specified Nuclos source and target locales.- Parameters:
text- The text to translatesourceLocale- The Nuclos source locale of the texttargetLocale- The Nuclos target locale for translation- Returns:
- The translated text
-
translateInMemory
public static String translateInMemory(String text, NuclosLocale sourceLocale, NuclosLocale targetLocale, int timeoutMillisForTranslatorRequest) Translates a text in memory only (not persisted) using the specified Nuclos source and target locales with a custom timeout.- Parameters:
text- The text to translatesourceLocale- The Nuclos source locale of the texttargetLocale- The Nuclos target locale for translationtimeoutMillisForTranslatorRequest- The timeout in milliseconds for the translator request- Returns:
- The translated text
-
translateInMemory
public static String translateInMemory(String text, Locale sourceLocale, Locale targetLocale, int timeoutMillisForTranslatorRequest) Translates a text in memory only (not persisted) using the specified source and target locales with a custom timeout.- Parameters:
text- The text to translatesourceLocale- The source locale of the texttargetLocale- The target locale for translationtimeoutMillisForTranslatorRequest- The timeout in milliseconds for the translator request- Returns:
- The translated text
-
translate
Translates a text using the specified source and target locales.- Parameters:
text- The text to translatesourceLocale- The source locale of the texttargetLocale- The target locale for translation- Returns:
- The translated text
-
translate
Translates a text using the specified Nuclos source and target locales.- Parameters:
text- The text to translatesourceLocale- The Nuclos source locale of the texttargetLocale- The Nuclos target locale for translation- Returns:
- The translated text
-
translate
public static String translate(String text, NuclosLocale sourceLocale, NuclosLocale targetLocale, int timeoutMillisForTranslatorRequest) Translates a text using the specified Nuclos source and target locales with a custom timeout.- Parameters:
text- The text to translatesourceLocale- The Nuclos source locale of the texttargetLocale- The Nuclos target locale for translationtimeoutMillisForTranslatorRequest- The timeout in milliseconds for the translator request- Returns:
- The translated text
-
translate
public static String translate(String text, Locale sourceLocale, Locale targetLocale, int timeoutMillisForTranslatorRequest) Translates a text using the specified source and target locales with a custom timeout.- Parameters:
text- The text to translatesourceLocale- The source locale of the texttargetLocale- The target locale for translationtimeoutMillisForTranslatorRequest- The timeout in milliseconds for the translator request- Returns:
- The translated text
-
translate_en
Translates a text from English using the specified key.- Parameters:
key- The localization keyenText- The English text to translate- Returns:
- The translated text
-
translate_de
Translates a text from German using the specified key.- Parameters:
key- The localization keydeText- The German text to translate- Returns:
- The translated text
-
translate
Translates a text using the specified key and the best matching source locale.- Parameters:
key- The localization keytext- The text to translate- Returns:
- The translated text
-
translate
Translates a text using the specified key and source locale.- Parameters:
key- The localization keytext- The text to translatesourceLocale- The source locale of the text- Returns:
- The translated text
-
translate
Translates a text using the specified key and Nuclos source locale.- Parameters:
key- The localization keytext- The text to translatesourceLocale- The Nuclos source locale of the text- Returns:
- The translated text
-
translate
Translates a text using the specified key, source locale, and target locale.- Parameters:
key- The localization keytext- The text to translatesourceLocale- The source locale of the texttargetLocale- The target locale for translation- Returns:
- The translated text
-
translate
public static String translate(String key, String text, NuclosLocale sourceLocale, NuclosLocale targetLocale) Translates a text using the specified key, Nuclos source locale, and Nuclos target locale.- Parameters:
key- The localization keytext- The text to translatesourceLocale- The Nuclos source locale of the texttargetLocale- The Nuclos target locale for translation- Returns:
- The translated text
-
translate
public static String translate(String key, String text, NuclosLocale sourceLocale, NuclosLocale targetLocale, int timeoutMillisForTranslatorRequest) Translates a text using the specified key, Nuclos source locale, Nuclos target locale, and custom timeout.- Parameters:
key- The localization keytext- The text to translatesourceLocale- The Nuclos source locale of the texttargetLocale- The Nuclos target locale for translationtimeoutMillisForTranslatorRequest- The timeout in milliseconds for the translator request- Returns:
- The translated text
-
translate
public static String translate(String key, String text, Locale sourceLocale, Locale targetLocale, int timeoutMillisForTranslatorRequest) Translates a text using the specified key, source locale, target locale, and custom timeout.- Parameters:
key- The localization keytext- The text to translatesourceLocale- The source locale of the texttargetLocale- The target locale for translationtimeoutMillisForTranslatorRequest- The timeout in milliseconds for the translator request- Returns:
- The translated text
-
translateCheckedInMemory
Translates a text in memory only (not persisted) and throws an exception if translation fails.- Parameters:
text- The text to translate- Returns:
- The translated text
- Throws:
Exception- If translation fails
-
translateCheckedInMemory
Translates a text in memory only (not persisted) using the specified source locale and throws an exception if translation fails.- Parameters:
text- The text to translatesourceLocale- The source locale of the text- Returns:
- The translated text
- Throws:
Exception- If translation fails
-
translateCheckedInMemory
public static String translateCheckedInMemory(String text, NuclosLocale sourceLocale) throws Exception Translates a text in memory only (not persisted) using the specified Nuclos source locale and throws an exception if translation fails.- Parameters:
text- The text to translatesourceLocale- The Nuclos source locale of the text- Returns:
- The translated text
- Throws:
Exception- If translation fails
-
translateCheckedInMemory
public static String translateCheckedInMemory(String text, Locale sourceLocale, Locale targetLocale) throws Exception Translates a text in memory only (not persisted) using the specified source and target locales and throws an exception if translation fails.- Parameters:
text- The text to translatesourceLocale- The source locale of the texttargetLocale- The target locale for translation- Returns:
- The translated text
- Throws:
Exception- If translation fails
-
translateCheckedInMemory
public static String translateCheckedInMemory(String text, NuclosLocale sourceLocale, NuclosLocale targetLocale) throws Exception Translates a text in memory only (not persisted) using the specified Nuclos source and target locales and throws an exception if translation fails.- Parameters:
text- The text to translatesourceLocale- The Nuclos source locale of the texttargetLocale- The Nuclos target locale for translation- Returns:
- The translated text
- Throws:
Exception- If translation fails
-
translateCheckedInMemory
public static String translateCheckedInMemory(String text, NuclosLocale sourceLocale, NuclosLocale targetLocale, int timeoutMillisForTranslatorRequest) throws Exception Translates a text in memory only (not persisted) using the specified Nuclos source and target locales with a custom timeout and throws an exception if translation fails.- Parameters:
text- The text to translatesourceLocale- The Nuclos source locale of the texttargetLocale- The Nuclos target locale for translationtimeoutMillisForTranslatorRequest- The timeout in milliseconds for the translator request- Returns:
- The translated text
- Throws:
Exception- If translation fails
-
translateCheckedInMemory
public static String translateCheckedInMemory(String text, Locale sourceLocale, Locale targetLocale, int timeoutMillisForTranslatorRequest) throws Exception Translates a text in memory only (not persisted) using the specified source and target locales with a custom timeout and throws an exception if translation fails.- Parameters:
text- The text to translatesourceLocale- The source locale of the texttargetLocale- The target locale for translationtimeoutMillisForTranslatorRequest- The timeout in milliseconds for the translator request- Returns:
- The translated text
- Throws:
Exception- If translation fails
-
translateChecked
public static String translateChecked(String text, Locale sourceLocale, Locale targetLocale) throws Exception Translates a text and throws an exception if translation fails.- Parameters:
text- The text to translatesourceLocale- The source locale of the texttargetLocale- The target locale for translation- Returns:
- The translated text
- Throws:
Exception- If translation fails
-
translateChecked
public static String translateChecked(String text, NuclosLocale sourceLocale, NuclosLocale targetLocale) throws Exception Translates a text using the specified Nuclos source and target locales and throws an exception if translation fails.- Parameters:
text- The text to translatesourceLocale- The Nuclos source locale of the texttargetLocale- The Nuclos target locale for translation- Returns:
- The translated text
- Throws:
Exception- If translation fails
-
translateChecked
public static String translateChecked(String text, NuclosLocale sourceLocale, NuclosLocale targetLocale, int timeoutMillisForTranslatorRequest) throws Exception Translates a text using the specified Nuclos source and target locales with a custom timeout and throws an exception if translation fails.- Parameters:
text- The text to translatesourceLocale- The Nuclos source locale of the texttargetLocale- The Nuclos target locale for translationtimeoutMillisForTranslatorRequest- The timeout in milliseconds for the translator request- Returns:
- The translated text
- Throws:
Exception- If translation fails
-
translateChecked
public static String translateChecked(String text, Locale sourceLocale, Locale targetLocale, int timeoutMillisForTranslatorRequest) throws Exception Translates a text using the specified source and target locales with a custom timeout and throws an exception if translation fails.- Parameters:
text- The text to translatesourceLocale- The source locale of the texttargetLocale- The target locale for translationtimeoutMillisForTranslatorRequest- The timeout in milliseconds for the translator request- Returns:
- The translated text
- Throws:
Exception- If translation fails
-
translateChecked_en
Translates a text from English using the specified key and throws an exception if translation fails.- Parameters:
key- The localization keyenText- The English text to translate- Returns:
- The translated text
- Throws:
Exception- If translation fails
-
translateChecked_de
Translates a text from German using the specified key and throws an exception if translation fails.- Parameters:
key- The localization keydeText- The German text to translate- Returns:
- The translated text
- Throws:
Exception- If translation fails
-
translateChecked
Translates a text using the specified key and the best matching source locale and throws an exception if translation fails.- Parameters:
key- The localization keytext- The text to translate- Returns:
- The translated text
- Throws:
Exception- If translation fails
-
translateChecked
public static String translateChecked(String key, String text, Locale sourceLocale) throws Exception Translates a text using the specified key and source locale and throws an exception if translation fails.- Parameters:
key- The localization keytext- The text to translatesourceLocale- The source locale of the text- Returns:
- The translated text
- Throws:
Exception- If translation fails
-
translateChecked
public static String translateChecked(String key, String text, NuclosLocale sourceLocale) throws Exception Translates a text using the specified key and Nuclos source locale and throws an exception if translation fails.- Parameters:
key- The localization keytext- The text to translatesourceLocale- The Nuclos source locale of the text- Returns:
- The translated text
- Throws:
Exception- If translation fails
-
translateChecked
public static String translateChecked(String key, String text, Locale sourceLocale, Locale targetLocale) throws Exception Translates a text using the specified key, source locale, and target locale and throws an exception if translation fails.- Parameters:
key- The localization keytext- The text to translatesourceLocale- The source locale of the texttargetLocale- The target locale for translation- Returns:
- The translated text
- Throws:
Exception- If translation fails
-
translateChecked
public static String translateChecked(String key, String text, NuclosLocale sourceLocale, NuclosLocale targetLocale) throws Exception Translates a text using the specified key, Nuclos source locale, and Nuclos target locale and throws an exception if translation fails.- Parameters:
key- The localization keytext- The text to translatesourceLocale- The Nuclos source locale of the texttargetLocale- The Nuclos target locale for translation- Returns:
- The translated text
- Throws:
Exception- If translation fails
-
translateChecked
public static String translateChecked(String key, String text, NuclosLocale sourceLocale, NuclosLocale targetLocale, int timeoutMillisForTranslatorRequest) throws Exception Translates a text using the specified key, Nuclos source locale, Nuclos target locale, and custom timeout and throws an exception if translation fails.- Parameters:
key- The localization keytext- The text to translatesourceLocale- The Nuclos source locale of the texttargetLocale- The Nuclos target locale for translationtimeoutMillisForTranslatorRequest- The timeout in milliseconds for the translator request- Returns:
- The translated text
- Throws:
Exception- If translation fails
-
translateChecked
public static String translateChecked(String key, String text, Locale sourceLocale, Locale targetLocale, int timeoutMillisForTranslatorRequest) throws Exception Translates a text using the specified key, source locale, target locale, and custom timeout and throws an exception if translation fails.- Parameters:
key- The localization keytext- The text to translatesourceLocale- The source locale of the texttargetLocale- The target locale for translationtimeoutMillisForTranslatorRequest- The timeout in milliseconds for the translator request- Returns:
- The translated text
- Throws:
Exception- If translation fails
-