Class LanguageService

java.lang.Object
de.presti.ree6.language.LanguageService

public class LanguageService extends Object
Utility used to work with Languages.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final HashMap<net.dv8tion.jda.api.interactions.DiscordLocale,Language>
    A Hashmap containing the locale as key and the YamlConfiguration as value.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    Called to download every Language file from the GitHub Repository.
    static @NotNull String
    getByEvent(@NotNull CommandEvent commandEvent, @NotNull String key, @Nullable Object... parameter)
    Called to get a specific String from the Guild specific Language file.
    static @NotNull String
    getByEvent(@NotNull net.dv8tion.jda.api.events.guild.GenericGuildEvent commandEvent, @NotNull String key, @Nullable Object... parameter)
    Called to get a specific String from the Guild specific Language file.
    static @NotNull String
    getByGuild(long guildId, @NotNull String key, @Nullable Object... parameter)
    Called to get a specific String from the Language file.
    static @NotNull String
    getByGuild(net.dv8tion.jda.api.entities.Guild guild, @NotNull String key, @Nullable Object... parameter)
    Called to get a specific String from the Language file.
    static @NotNull String
    getByGuildOrInteraction(net.dv8tion.jda.api.entities.Guild guild, net.dv8tion.jda.api.interactions.Interaction interaction, @NotNull String key, @Nullable Object... parameter)
    Called to get a specific String from the Language file.
    static @NotNull String
    getByInteraction(net.dv8tion.jda.api.interactions.Interaction interaction, @NotNull String key, @Nullable Object... parameter)
    Called to get a specific String from the Language file.
    static @NotNull String
    getByLocale(@NotNull String locale, @NotNull String key, @Nullable Object... parameters)
    Called to get a specific String from the Language file.
    static @NotNull String
    getByLocale(@NotNull net.dv8tion.jda.api.interactions.DiscordLocale discordLocale, @NotNull String key, @Nullable Object... parameters)
    Called to get a specific String from the Language file.
    static @NotNull String
    getDefault(@NotNull String key, @Nullable Object... parameter)
    Called to get a specific String from the default Language file.
    static Set<net.dv8tion.jda.api.interactions.DiscordLocale>
    Called to retrieve all supported Locals.
    static void
    Called to load every Language file into memory.
    static @Nullable Language
    loadLanguageFromFile(@NotNull net.dv8tion.jda.api.interactions.DiscordLocale discordLocale)
    Called to load a Language from a YamlConfiguration.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • languageResources

      public static final HashMap<net.dv8tion.jda.api.interactions.DiscordLocale,Language> languageResources
      A Hashmap containing the locale as key and the YamlConfiguration as value.
  • Constructor Details

    • LanguageService

      public LanguageService()
  • Method Details

    • initializeLanguages

      public static void initializeLanguages()
      Called to load every Language file into memory.
    • downloadLanguages

      public static void downloadLanguages()
      Called to download every Language file from the GitHub Repository.
    • loadLanguageFromFile

      @Nullable public static @Nullable Language loadLanguageFromFile(@NotNull @NotNull net.dv8tion.jda.api.interactions.DiscordLocale discordLocale)
      Called to load a Language from a YamlConfiguration.
      Parameters:
      discordLocale - The DiscordLocale of the Language.
      Returns:
      The Language.
    • getByEvent

      @NotNull public static @NotNull String getByEvent(@NotNull @NotNull CommandEvent commandEvent, @NotNull @NotNull String key, @Nullable @Nullable Object... parameter)
      Called to get a specific String from the Guild specific Language file.
      Parameters:
      commandEvent - the CommandEvent.
      key - the key of the String.
      parameter - the parameter to replace.
      Returns:
      the String.
    • getByEvent

      @NotNull public static @NotNull String getByEvent(@NotNull @NotNull net.dv8tion.jda.api.events.guild.GenericGuildEvent commandEvent, @NotNull @NotNull String key, @Nullable @Nullable Object... parameter)
      Called to get a specific String from the Guild specific Language file.
      Parameters:
      commandEvent - the GuildEvent.
      key - the key of the String.
      parameter - the parameter to replace.
      Returns:
      the String.
    • getByGuildOrInteraction

      @NotNull public static @NotNull String getByGuildOrInteraction(net.dv8tion.jda.api.entities.Guild guild, net.dv8tion.jda.api.interactions.Interaction interaction, @NotNull @NotNull String key, @Nullable @Nullable Object... parameter)
      Called to get a specific String from the Language file.
      Parameters:
      guild - The Guild to receive the locale from.
      interaction - The Interaction to receive the locale from.
      key - The key of the String.
      parameter - The Parameters to replace placeholders in the String.
      Returns:
      The String.
    • getByGuild

      @NotNull public static @NotNull String getByGuild(net.dv8tion.jda.api.entities.Guild guild, @NotNull @NotNull String key, @Nullable @Nullable Object... parameter)
      Called to get a specific String from the Language file.
      Parameters:
      guild - The Guild to receive the locale from.
      key - The key of the String.
      parameter - The Parameters to replace placeholders in the String.
      Returns:
      The String.
    • getByGuild

      @NotNull public static @NotNull String getByGuild(long guildId, @NotNull @NotNull String key, @Nullable @Nullable Object... parameter)
      Called to get a specific String from the Language file.
      Parameters:
      guildId - The Guild ID to receive the locale from.
      key - The key of the String.
      parameter - The Parameters to replace placeholders in the String.
      Returns:
      The String.
    • getByInteraction

      @NotNull public static @NotNull String getByInteraction(net.dv8tion.jda.api.interactions.Interaction interaction, @NotNull @NotNull String key, @Nullable @Nullable Object... parameter)
      Called to get a specific String from the Language file.
      Parameters:
      interaction - The Interaction to receive the locale from.
      key - The key of the String.
      parameter - The Parameters to replace placeholders in the String.
      Returns:
      The String.
    • getDefault

      @NotNull public static @NotNull String getDefault(@NotNull @NotNull String key, @Nullable @Nullable Object... parameter)
      Called to get a specific String from the default Language file.
      Parameters:
      key - The key of the String.
      parameter - The Parameters to replace placeholders in the String.
      Returns:
      The String.
    • getByLocale

      @NotNull public static @NotNull String getByLocale(@NotNull @NotNull String locale, @NotNull @NotNull String key, @Nullable @Nullable Object... parameters)
      Called to get a specific String from the Language file.
      Parameters:
      locale - The locale of the Language file.
      key - The key of the String.
      parameters - The Parameters to replace placeholders in the String.
      Returns:
      The String.
    • getByLocale

      @NotNull public static @NotNull String getByLocale(@NotNull @NotNull net.dv8tion.jda.api.interactions.DiscordLocale discordLocale, @NotNull @NotNull String key, @Nullable @Nullable Object... parameters)
      Called to get a specific String from the Language file.
      Parameters:
      discordLocale - The locale of the Language file.
      key - The key of the String.
      parameters - The Parameters to replace placeholders in the String.
      Returns:
      The String.
    • getSupported

      public static Set<net.dv8tion.jda.api.interactions.DiscordLocale> getSupported()
      Called to retrieve all supported Locals.
      Returns:
      The supported Locals.