-
- All Implemented Interfaces:
-
android.os.Parcelable,org.readium.r2.shared.JSONable
public final class LocalizedString implements JSONable, Parcelable
Represents a string with multiple translations indexed by a BCP 47 language tag.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public final classLocalizedString.Translationpublic classLocalizedString.Companion
-
Field Summary
Fields Modifier and Type Field Description private final LocalizedString.TranslationdefaultTranslationprivate final Stringstringprivate final StringsingleStringprivate final Map<String, String>multiStringprivate final Map<String, LocalizedString.Translation>translations
-
Constructor Summary
Constructors Constructor Description LocalizedString(String value, String lang)Shortcut to create a LocalizedString using a single string for a given language. LocalizedString(Map<String, LocalizedString.Translation> translations)
-
Method Summary
-
-
Constructor Detail
-
LocalizedString
LocalizedString(String value, String lang)
Shortcut to create a LocalizedString using a single string for a given language.
-
LocalizedString
LocalizedString(Map<String, LocalizedString.Translation> translations)
-
-
Method Detail
-
getDefaultTranslation
final LocalizedString.Translation getDefaultTranslation()
-
getSingleString
final String getSingleString()
-
getMultiString
final Map<String, String> getMultiString()
-
getTranslations
final Map<String, LocalizedString.Translation> getTranslations()
-
getOrFallback
final LocalizedString.Translation getOrFallback(String language)
-
copyWithString
final LocalizedString copyWithString(String language, String string)
Returns a new LocalizedString after adding (or replacing) the translation with the given language.
-
mapLanguages
final LocalizedString mapLanguages(Function1<Entry.Map<String, LocalizedString.Translation>, String> transform)
Returns a new LocalizedString after applying the transform function to each language.
-
mapTranslations
final LocalizedString mapTranslations(Function1<Entry.Map<String, LocalizedString.Translation>, LocalizedString.Translation> transform)
Returns a new LocalizedString after applying the transform function to each translation.
-
toJSON
JSONObject toJSON()
Serializes a LocalizedString to its RWPM JSON representation.
-
-
-
-