Class Translation
- java.lang.Object
-
- io.rocketbase.commons.translation.Translation
-
- All Implemented Interfaces:
Serializable
public class Translation extends Object implements Serializable
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classTranslation.TranslationBuilder
-
Constructor Summary
Constructors Constructor Description Translation()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Translationadd(Locale locale, String value)add translation to list - overwrite existingstatic Translation.TranslationBuilderbuilder()Translationchinese(String value)Translationenglish(String value)Translationfrench(String value)Translationgerman(String value)Set<Locale>getLocales()StringgetTranslated()lookup with locale of LocaleContextHolderStringgetTranslated(Locale locale)lookup for locale in following order: lookup for exact locale (de-DE-bayrisch) afterwards for only parts of the locale-tag (de-DE, de) afterwards fpr (en) then for (ROOT "") when only one translation exists return itbooleanhasLocale(Locale locale)exactly search within map if locale containsbooleanhasLocaleLooselyFilter(Locale locale)uses theLocaleFilterfunction to search if locale could be foundTranslationitalian(String value)Translationjapanese(String value)Translationkorean(String value)static Translationof(Locale locale, String value)init TranslationTranslationroot(String value)static Translationtranslation(String translation)init Translation with value for Locale of LocaleContextHolder
-
-
-
Method Detail
-
of
public static Translation of(Locale locale, String value)
init Translation- Parameters:
locale- Locale of valuevalue- text- Returns:
- new Translation instant
-
translation
public static Translation translation(String translation)
init Translation with value for Locale of LocaleContextHolder- Parameters:
translation- value- Returns:
- new Translation instant
-
builder
public static Translation.TranslationBuilder builder()
-
add
public Translation add(Locale locale, String value)
add translation to list - overwrite existing
-
english
public Translation english(String value)
-
french
public Translation french(String value)
-
german
public Translation german(String value)
-
italian
public Translation italian(String value)
-
japanese
public Translation japanese(String value)
-
korean
public Translation korean(String value)
-
chinese
public Translation chinese(String value)
-
root
public Translation root(String value)
-
getTranslated
@Nullable public String getTranslated(Locale locale)
lookup for locale in following order:- lookup for exact locale (de-DE-bayrisch)
- afterwards for only parts of the locale-tag (de-DE, de)
- afterwards fpr (en)
- then for (ROOT "")
- when only one translation exists return it
- Parameters:
locale- exact match locale- Returns:
- translated value when found
-
getTranslated
@Nullable public String getTranslated()
lookup with locale of LocaleContextHolder- Returns:
- translated value when found
-
hasLocale
public boolean hasLocale(Locale locale)
exactly search within map if locale contains
-
hasLocaleLooselyFilter
public boolean hasLocaleLooselyFilter(Locale locale)
uses theLocaleFilterfunction to search if locale could be found
-
-