Class LocalizationMap
java.lang.Object
net.dv8tion.jda.api.interactions.commands.localization.LocalizationMap
- All Implemented Interfaces:
SerializableData
Class which contains a mapping from
This is used for command, option, and choice localization.
DiscordLocale
to a translated String, similar to a Map<DiscordLocale, String>
.
This is used for command, option, and choice localization.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionget
(DiscordLocale locale) Gets the localized string for the specifiedDiscordLocale
.void
setTranslation
(DiscordLocale locale, String localizedString) Sets the given localized string to be used for the specified locale.void
Adds all the translations from the supplied map into this LocalizationMap.toData()
SerializedDataObject
for this object.toMap()
Gets the unmodifiable map representing this LocalizationMap.
-
Field Details
-
LOG
public static final org.slf4j.Logger LOG
-
-
Constructor Details
-
LocalizationMap
-
-
Method Details
-
toData
Description copied from interface:SerializableData
SerializedDataObject
for this object.- Specified by:
toData
in interfaceSerializableData
- Returns:
DataObject
-
setTranslation
Sets the given localized string to be used for the specified locale.- Parameters:
locale
- The locale on which to apply the localized stringlocalizedString
- The localized string to use- Throws:
IllegalArgumentException
-- If the locale is null
- If the localized string is null
- If the locale is
DiscordLocale.UNKNOWN
- If the localized string does not pass the corresponding attribute check
-
setTranslations
Adds all the translations from the supplied map into this LocalizationMap.- Parameters:
map
- The map containing the localized strings- Throws:
IllegalArgumentException
-- If the map is null
- If the map contains an
DiscordLocale.UNKNOWN
key - If the map contains a localized string which does not pass the corresponding attribute check
-
get
Gets the localized string for the specifiedDiscordLocale
.- Parameters:
locale
- The locale from which to get the localized string- Returns:
- Possibly-null localized string
-
toMap
Gets the unmodifiable map representing this LocalizationMap.
The changes on this LocalizationMap will be reflected on the returned map.- Returns:
- The unmodifiable map of this LocalizationMap
-