-
Notifications
You must be signed in to change notification settings - Fork 12
Languages
WolfyScript edited this page Feb 20, 2022
·
4 revisions
Languages are used everywhere in the API, for chat messages, GUIs (including Buttons).
They are loaded from your YourPlugin/lang folder.
You can register as many Languages as you want.
But there can only be two languages active simultaneously.
There are two kinds of active Languages:
- Active Language: Used as the main language. All keys are looked up in it first.
- Fallback Language: Used as a fallback for when keys are not available in the Active Language.
Simply export the resource from the jar to the /lang folder.
Then you can create the Language object.
Example:
import me.wolfyscript.utilities.api.language.Language;
import me.wolfyscript.utilities.api.language.LanguageAPI;
public class YourPlugin extends JavaPlugin {
public void loadLang(){
//Save the language file resource to the plugin folder.
saveResource("lang/en_US.json", true);
//Get the LanguageAPI of the api
LanguageAPI languageAPI = this.api.getLanguageAPI();
//Create the language
Language fallBackLanguage = new Language(this, "en_US");
//Register the language. The first registered language will be automatically be used as the fallback and active language.
languageAPI.registerLanguage(fallBackLanguage);
//- Optionally load another active language. -
saveResource("lang/de_DE.json", true);
//Optionally you can register another active language.
Language language = new Language(this, "de_DE");
languageAPI.registerLanguage(language);
//Just requires to set the active language manually.
languageAPI.setActiveLanguage(language);
}
}| Home
| Registry
-
Introduction
- Structure
- InventoryAPI
- Register GuiCluster
- CustomCache
- GuiClusters
- GuiWindow
-
Buttons
- Dummy
- Action
- Toggle
- ChatInput
- MultipleChoice
-
ButtonStates
- ButtonFunctions
- ButtonAction
- ButtonPostAction
- ButtonPreRender
- ButtonRender
- ButtonFunctions