Package com.lokalized

Class LocalizedString.Builder

java.lang.Object
com.lokalized.LocalizedString.Builder
Enclosing class:
LocalizedString

@NotThreadSafe public static class LocalizedString.Builder extends Object
Builder used to construct instances of LocalizedString.

This class is intended for use by a single thread.

Author:
Mark Allen
  • Constructor Details

    • Builder

      public Builder(@Nonnull String key)
      Constructs a localized string builder with the given key.
      Parameters:
      key - this string's translation key, not null
  • Method Details

    • translation

      @Nonnull public LocalizedString.Builder translation(@Nullable String translation)
      Applies a default translation to this builder.
      Parameters:
      translation - a default translation, may be null
      Returns:
      this builder instance, useful for chaining. not null
    • commentary

      @Nonnull public LocalizedString.Builder commentary(@Nullable String commentary)
      Applies commentary (usage/translation notes) to this builder.
      Parameters:
      commentary - commentary (usage/translation notes), may be null
      Returns:
      this builder instance, useful for chaining. not null
    • languageFormTranslationsByPlaceholder

      @Nonnull public LocalizedString.Builder languageFormTranslationsByPlaceholder(@Nullable Map<String,LocalizedString.LanguageFormTranslation> languageFormTranslationsByPlaceholder)
      Applies per-language-form translations to this builder.
      Parameters:
      languageFormTranslationsByPlaceholder - per-language-form translations, may be null
      Returns:
      this builder instance, useful for chaining. not null
    • alternatives

      @Nonnull public LocalizedString.Builder alternatives(@Nullable List<LocalizedString> alternatives)
      Applies alternative expression-driven translations to this builder.
      Parameters:
      alternatives - alternative expression-driven translations, may be null
      Returns:
      this builder instance, useful for chaining. not null
    • build

      @Nonnull public LocalizedString build()
      Constructs an instance of LocalizedString.
      Returns:
      an instance of LocalizedString, not null