Class TranslationLoader
java.lang.Object
com.palmergames.bukkit.towny.object.TranslationLoader
-
Constructor Summary
ConstructorDescriptionTranslationLoader
(Path langFolderPath, org.bukkit.plugin.Plugin plugin, Class<?> clazz) An object which allows a plugin to load language files into Towny's translations hashmap.TranslationLoader
(org.bukkit.plugin.Plugin plugin) An object which allows a plugin to load language files into Towny's translations hashmap. -
Method Summary
Modifier and TypeMethodDescriptionvoid
load()
Load the translations from inside the plugin into memory, create reference folder, create and load override folder, create and load global.yml file.void
updateReferenceFiles
(boolean update)
-
Constructor Details
-
TranslationLoader
An object which allows a plugin to load language files into Towny's translations hashmap. Enabling the given plugin to use Towny's built-in messaging and translating so that messages will display in the player's own Locale (determined by the client's locale setting.)
Language files should be saved in your plugin's resources\lang\ folder, using valid Locale file names ie: en-US.yml, de-DE.yml. Locales which do not appear in Minecraft will not be used.
You may opt to provide a global.yml file in your plugin's resources folder, which will allow an admin to globally override language strings for all locales.
Example:
Plugin plugin = Towny.getPlugin();
Path langFolderPath = Paths.get(plugin.getDataFolder().getPath()).resolve("lang");
TranslationLoader loader = new TranslationLoader(langFolderPath, plugin, Towny.class);
loader.load();
TownyAPI.addTranslations(plugin, loader.getTranslations());- Parameters:
langFolderPath
- Path to where the plugin stores their language files on the server.plugin
- Plugin, your plugin.clazz
- Class file of your plugin, ie: Towny.class.- Throws:
TownyInitException
- When files cannot be saved, loaded or something else goes wrong.
-
TranslationLoader
public TranslationLoader(org.bukkit.plugin.Plugin plugin) An object which allows a plugin to load language files into Towny's translations hashmap. Enabling the given plugin to use Towny's built-in messaging and translating so that messages will display in the player's own Locale (determined by the client's locale setting.)
This constructor requires that your Language files be saved in your plugin's resources\lang\ folder, using valid Locale file names ie: en-US.yml, de-DE.yml. Locales which do not appear in Minecraft will not be used.
You may opt to provide a global.yml file in your plugin's resources folder, which will allow an admin to globally override language strings for all locales.
Example:
Plugin plugin = Towny.getPlugin();
TranslationLoader loader = new TranslationLoader(plugin);
loader.load();
TownyAPI.addTranslations(plugin, loader.getTranslations());- Parameters:
plugin
- Plugin, your plugin.- Throws:
TownyInitException
- When files cannot be saved, loaded or something else goes wrong.
-
-
Method Details
-
load
public void load()Load the translations from inside the plugin into memory, create reference folder, create and load override folder, create and load global.yml file. -
getTranslations
- Returns:
- translations Map<String, Map<String, String>> A hashmap keyed by the locale name, with a value of secondary hashmap of the locale's language string keys and their corresponding values.
-
updateReferenceFiles
public void updateReferenceFiles(boolean update) - Parameters:
update
- Whether to create and update reference files.
-