Class LocalizedString
Normally instances are sourced from a file which contains all localized strings for a given locale.
Unicode letter, number, and mark membership in placeholder and expression identifiers follows the executing JDK's
Pattern Unicode tables. For cross-JDK portability, author identifiers for the oldest JDK in
the deployment fleet; [A-Za-z_][A-Za-z0-9_-]* is the portable ASCII subset.
- Author:
- Mark Allen
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder used to construct instances ofLocalizedString.static final classAn expression and the generated fragment translation selected when that expression matches.static final classA generated fragment with a required default translation and optional ordered expression-driven alternatives.static final classContainer for per-language-form (gender, case, definiteness, classifier, formality, clusivity, animacy, cardinal, ordinal, phonetic) translation information.static final classContainer for per-language-form cardinality translation information over a range (start, end) of values.static classClosed base type for generated-placeholder definitions. -
Method Summary
Modifier and TypeMethodDescriptionbooleanChecks if this object is equal to another one.Gets alternative expression-driven translations for this string.Gets this string's commentary (usage/translation notes).getKey()Gets this string's translation key.Gets the generated-placeholder definitions declared by this localized string.Gets this string's default translation, if available.inthashCode()A hash code for this object.toString()Generates a bounded diagnosticStringrepresentation of this object.
-
Method Details
-
toString
Generates a bounded diagnosticStringrepresentation of this object.Deep, shared, cyclic, or oversized values may be abbreviated with reference, cycle, or truncation markers.
-
equals
-
hashCode
-
getKey
-
getTranslation
Gets this string's default translation, if available.- Returns:
- this string's default translation, not null
-
getCommentary
Gets this string's commentary (usage/translation notes).- Returns:
- this string's commentary, not null
-
getPlaceholderDefinitions
public @NonNull Map<@NonNull String, @NonNull LocalizedString.PlaceholderDefinition> getPlaceholderDefinitions()Gets the generated-placeholder definitions declared by this localized string.Current concrete types are
LocalizedString.LanguageFormTranslationandLocalizedString.ExpressionTranslation. Consumers should inspect the definition type withinstanceofbefore accessing subtype-specific state and handle unfamiliar future library-defined types defensively.- Returns:
- generated-placeholder definitions keyed by placeholder name, not null
- Since:
- 3.0.0
-
getAlternatives
Gets alternative expression-driven translations for this string.In this context, the
keyfor each alternative is a localization expression, not a translation key.For example, if
bookCount == 0you might want to sayI haven't read any booksinstead ofI read 0 books.- Returns:
- alternative expression-driven translations for this string, not null
-