Languages
Registering languages
First, create a folder in resources to store languages. Then, add the language named using the Minecraft "In-game Locale Code" in TOML format and a 'list' file with all available languages:
- resources
- test
- en_us.toml
- list[server]
addon.test.pepega = "Pepega"
[client]
addon.test.pepega = "Pepega"en_usAfter creating all the necessary files, register the languages using the API:
PlasmoVoiceServer voiceServer = /**/;
File addonFolder = new File(voiceServer.getMinecraftServer().getConfigsFolder(), "pv-addon-test");
voiceServer.getLanguages().register(
this::getLanguageResource,
new File(addonFolder, "languages") // folder where to store languages
);
// create this method somewhere in your class or use the ResourceLoader interface, implementing it with the same logic
private InputStream getLanguageResource(String resourcePath) throws IOException {
return getClass().getClassLoader().getResourceAsStream(String.format("test/%s", resourcePath));
}Server languages
Server-side languages are automatically translating translatable component on server based on player language.
It also supports Adventure GlobalTranslator, so if you platform supports Adventure, translations will be added to GlobalTranslator.
To add translations, insert your translation into language_code.toml within the [server] block:
[server]
addon.test.pepega = "Pepega"Sending
You don't need to add the server prefix when sending the text component.
If your platform supports Adventure, you can simply use Component.translatable to create a translatable component and send it to the audience:
Audience audience = /**/;
Component component = Component.translatable("addon.test.pepega");
audience.sendMessage(component);Otherwise, you need to use a universal player to send the translatable:
VoiceServerPlayer voicePlayer = /**/;
McServerPlayer serverPlayer = voiceServerPlayer.getInstance();
McTextComponent component = McTextComponent.translatable("addon.test.pepega");
serverPlayer.sendMessage(component);Client languages
Client languages will be sent to the Plasmo Voice client with a config packet and on a client language change.
These client languages are used exclusively inside Plasmo Voice for Activations and Source Lines.
To add translations, insert your translation into language_code.toml within the [client] block:
[client]
addon.test.pepega = "Pepega"