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 String
Gets the short date format pattern for the current locale.static String
Gets the decimal separator for numbers in the current locale.static String
Gets the grouping separator for numbers in the current locale.static String
Gets the medium time format pattern for the current locale.static String
Gets the short time format pattern for the current locale.void
static String
Translates a text using the specified key and the best matching source locale.static String
Translates a text using the specified key and source locale.static String
Translates a text using the specified key, source locale, and target locale.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.static String
translate
(String key, String text, NuclosLocale sourceLocale) Translates a text using the specified key and Nuclos source locale.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.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.static String
Translates a text using the specified source and target locales.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.static String
translate
(String text, NuclosLocale sourceLocale, NuclosLocale targetLocale) Translates a text using the specified Nuclos source and target locales.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.static String
translate_de
(String key, String deText) Translates a text from German using the specified key.static String
translate_en
(String key, String enText) Translates a text from English using the specified key.static String
translateChecked
(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 String
translateChecked
(String key, String text, Locale sourceLocale) Translates a text using the specified key and source locale and throws an exception if translation fails.static String
translateChecked
(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 String
translateChecked
(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 String
translateChecked
(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 String
translateChecked
(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 String
translateChecked
(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 String
translateChecked
(String text, Locale sourceLocale, Locale targetLocale) Translates a text and throws an exception if translation fails.static String
translateChecked
(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 String
translateChecked
(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 String
translateChecked
(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 String
translateChecked_de
(String key, String deText) Translates a text from German using the specified key and throws an exception if translation fails.static String
translateChecked_en
(String key, String enText) Translates a text from English using the specified key and throws an exception if translation fails.static String
Translates a text in memory only (not persisted) and throws an exception if translation fails.static String
translateCheckedInMemory
(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 String
translateCheckedInMemory
(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 String
translateCheckedInMemory
(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 String
translateCheckedInMemory
(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 String
translateCheckedInMemory
(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 String
translateCheckedInMemory
(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 String
translateInMemory
(String text) Translates a text in memory only (not persisted) using the best matching source locale.static String
translateInMemory
(String text, Locale sourceLocale) Translates a text in memory only (not persisted) using the specified source locale.static String
translateInMemory
(String text, Locale sourceLocale, Locale targetLocale) Translates a text in memory only (not persisted) using the specified source and target locales.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.static String
translateInMemory
(String text, NuclosLocale sourceLocale) Translates a text in memory only (not persisted) using the specified Nuclos source locale.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.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.
-
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
-