-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Add libs into your plugin.
Register your languages in your plugin.
HydraTranslation::getInstance()->register(plugin: $this, defaultLang: LangTypeEnum::EN, availlabledLangs: [LangTypeEnum::EN, LangTypeEnum::FR]);This automatically creates a
langfolder with .ini files for each language. The defaultLang is used if the player's language is not available (e.g., game in Chinese → displayed in English by default).
Add your translations into the folder lang in each files you need translations.
handle translation for player.
$player = HydraTranslation::getPlayerManager()->getOrCreate($sender->getName());
$player->sendTranslateMessage(key: "discord", params: ["{link}" => "discord.gg/exemple"]);Retrieves the player and sends a message translated according to their language. The params replace the placeholders in the translation (e.g., {link} → discord.gg/exemple)."
Change the player local according to your server settings.
$player = HydraTranslation::getPlayerManager()->getOrCreate($sender->getName());
$player->lang = LangTypeEnum::DE->value;Broadcast to all online players an translated message.
HydraTranslation::getPlayerManager()->broadcastTranslatedMessage("welcome", ["{player}" => $newPlayer->getName()]);For reload langs while not restarting server, you can add your personal command with this line:
HydraTranslation::getLangManager()->loadAllLangs($this, [LangTypeEnum::EN, LangTypeEnum::FR]);