Class Translation

java.lang.Object
io.rocketbase.commons.translation.Translation
All Implemented Interfaces:
Serializable

public class Translation extends Object implements Serializable
See Also:
  • Constructor Details

    • Translation

      public Translation()
  • Method Details

    • of

      public static Translation of(Locale locale, String value)
      init Translation
      Parameters:
      locale - Locale of value
      value - 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)
    • getLocales

      public Set<Locale> getLocales()
    • 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 the LocaleFilter function to search if locale could be found
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object