# Bukkit Example ## Maven Artifact ```xml de.themoep.utils lang-bukkit check-for-latest compile ``` ## Example ```java public class MyPlugin extends JavaPlugin { private LanguageManager lang; @Override public void onEnable() { # Load LanguageManager. Either call that in onEnable or your config loading method. # Will automatically save and load any lang..yml configs in the languages folder # Gets and saves language files to the folder "languages". # Default locale is "en" lang = new LanguageManager(this, "languages", "en"); # Set the provider for the language of a certain sender # If null is returned then it will use the default locale # (This provider is the same as which is used by default) lang.setProvider(sender -> { if (sender instanceof Player) { return ((Player) sender).getLocale(); } return null; }); } /** * Get a message from a language config for a certain sender * @param sender The sender to get the string for. (Language is based on this) * @param key The language key in the config * @param replacements An option array for replacements. * (2n)-th will be the placeholder, (2n+1)-th the value. * Placeholders have to be surrounded by percentage signs: %placeholder% * @return The string from the config which matches the sender's language (or the default one) with the replacements replaced (or an error message, never null) */ public String getMessage(CommandSender sender, String key, String... replacements) { return lang.getConfig(sender).get(key, replacements); } } ```