java.lang.Object
net.dv8tion.jda.api.interactions.commands.localization.LocalizationMap
All Implemented Interfaces:
SerializableData

public class LocalizationMap extends Object implements SerializableData
Class which contains a mapping from DiscordLocale to a translated String, similar to a Map<DiscordLocale, String>.
This is used for command, option, and choice localization.
  • Field Details

    • LOG

      public static final org.slf4j.Logger LOG
  • Constructor Details

  • Method Details

    • toData

      @Nonnull public DataObject toData()
      Description copied from interface: SerializableData
      Serialized DataObject for this object.
      Specified by:
      toData in interface SerializableData
      Returns:
      DataObject
    • setTranslation

      public void setTranslation(@Nonnull DiscordLocale locale, @Nonnull String localizedString)
      Sets the given localized string to be used for the specified locale.
      Parameters:
      locale - The locale on which to apply the localized string
      localizedString - 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

      public void setTranslations(@Nonnull Map<DiscordLocale,String> map)
      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

      @Nullable public String get(@Nonnull DiscordLocale locale)
      Gets the localized string for the specified DiscordLocale.
      Parameters:
      locale - The locale from which to get the localized string
      Returns:
      Possibly-null localized string
    • toMap

      @Nonnull public Map<DiscordLocale,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