Class Localizer.Builder
java.lang.Object
de.chojo.jdautil.localization.Localizer.Builder
- Enclosing class:
Localizer
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddLanguage(DiscordLocale discordLocale) addLanguage(DiscordLocale... languages) build()Sets the embed code to the provided pattern.Sets the embed code to the provided pattern.withBundlePath(String bundlePath) withGuildLocaleCodeProvider(BiFunction<Guild, String, Optional<String>> guildLocaleCodeProvider) Returns an optional holding a locale code value when present.withLanguageProvider(Function<Guild, Optional<DiscordLocale>> languageProvider) Sets the language a guild chose.
-
Constructor Details
-
Builder
-
-
Method Details
-
withBundlePath
-
withLanguageProvider
public Localizer.Builder withLanguageProvider(Function<Guild, Optional<DiscordLocale>> languageProvider) Sets the language a guild chose. An empty optional falls back to the guild's Discord locale, which is also the default when no provider is set.- Parameters:
languageProvider- provider of the guild language- Returns:
- builder instance
-
withGuildLocaleCodeProvider
public Localizer.Builder withGuildLocaleCodeProvider(BiFunction<Guild, String, Optional<String>> guildLocaleCodeProvider) Returns an optional holding a locale code value when present. If an empty optional is returned the default value from the locale file is used.- Parameters:
guildLocaleCodeProvider- provider- Returns:
- optional that might contain a value
-
addLanguage
-
addLanguage
-
embedCode
Sets the embed code to the provided pattern. A locale code needs to be enclosed by those pattern. If regex pattern are used those need to be escaped.- Parameters:
code- code which is one char long- Returns:
- builder instance
-
embedCode
Sets the embed code to the provided pattern. A locale code needs to be enclosed by those pattern. If regex pattern are used those need to be escaped.- Parameters:
embedCodeStart- start codeembedCodeEnd- end code- Returns:
- builder instance
-
build
-