Package com.suncode.pwfl.translation
Class LocalizedString
java.lang.Object
com.suncode.pwfl.translation.LocalizedString
Dynamically translated String.
Message for given key is retrived within get()
method. If there is no forced
Locale
, user current locale will be used.
- Author:
- Cezary Kozar 11 sie 2015
-
Constructor Summary
ConstructorsConstructorDescriptionLocalizedString
(String key, Translator translator, Object... args) LocalizedString
(String key, String[] fallbackKeys, String defaultValue, Translator translator, Locale locale, Object... args) LocalizedString
(String key, String defaultValue, Translator translator, Locale locale, Object... args) -
Method Summary
Modifier and TypeMethodDescriptionboolean
get()
Returns translated message.Returns translated message or key value if translation does not exists.static String
getOrEmpty
(LocalizedString string) Returns value of localized string or empty string "" if specified localized string is null.int
hashCode()
static LocalizedString
Creates LocalizedString with static value.toString()
-
Constructor Details
-
LocalizedString
-
LocalizedString
public LocalizedString(String key, String defaultValue, Translator translator, Locale locale, Object... args) -
LocalizedString
-
-
Method Details
-
of
Creates LocalizedString with static value.- Parameters:
value
- value- Returns:
LocalizedString
which always returns given value
-
getOrEmpty
Returns value of localized string or empty string "" if specified localized string is null.- Parameters:
string
- localized string- Returns:
- not empty value
-
get
Returns translated message.- Throws:
NoTranslationException
- no translation found and no default value specified
-
getOptional
Returns translated message or key value if translation does not exists.- See Also:
-
equals
-
hashCode
public int hashCode() -
toString
-