Package com.lokalized

Class LocalizedString

java.lang.Object
com.lokalized.LocalizedString

@Immutable public class LocalizedString extends Object
Represents a single localized string - its key, translated value, and any associated translation rules.

Normally instances are sourced from a file which contains all localized strings for a given locale.

Author:
Mark Allen
  • Method Details

    • toString

      @Nonnull public String toString()
      Generates a String representation of this object.
      Overrides:
      toString in class Object
      Returns:
      a string representation of this object, not null
    • equals

      public boolean equals(@Nullable Object other)
      Checks if this object is equal to another one.
      Overrides:
      equals in class Object
      Parameters:
      other - the object to check, null returns false
      Returns:
      true if this is equal to the other object, false otherwise
    • hashCode

      public int hashCode()
      A hash code for this object.
      Overrides:
      hashCode in class Object
      Returns:
      a suitable hash code
    • getKey

      @Nonnull public String getKey()
      Gets this string's translation key.
      Returns:
      this string's translation key, not null
    • getTranslation

      @Nonnull public Optional<String> getTranslation()
      Gets this string's default translation, if available.
      Returns:
      this string's default translation, not null
    • getCommentary

      @Nonnull public Optional<String> getCommentary()
      Gets this string's commentary (usage/translation notes).
      Returns:
      this string's commentary, not null
    • getLanguageFormTranslationsByPlaceholder

      Gets per-language-form translations that correspond to a placeholder value.

      For example, language form MASCULINE might be translated as He for placeholder subject.

      Returns:
      per-language-form translations that correspond to a placeholder value, not null
    • getAlternatives

      @Nonnull public List<LocalizedString> getAlternatives()
      Gets alternative expression-driven translations for this string.

      In this context, the key for each alternative is a localization expression, not a translation key.

      For example, if bookCount == 0 you might want to say I haven't read any books instead of I read 0 books.

      Returns:
      alternative expression-driven translations for this string, not null