Repository navigation
Translations API
ControlCore shows text in each player's game language and reads it again every time, so a player who changes language sees the change. Your setting, key and HUD names can be translated the same way.
Text.key(key, englishFallback) names a translation and gives the English text used when a language lacks it:
api.settings().setModName("homes", Text.key("homes.mod_name", "Home Teleports"));
SettingDefinition.server("homes", "max-homes", SettingType.integer(1, 50), 3)
.named(Text.key("homes.settings.max_homes", "Max homes"))
.describedAs(Text.key("homes.settings.max_homes.desc", "How many homes each player may set"))
.inCategory(Text.key("homes.settings.limits", "Limits"));
SettingDefinition.player("homes", "sort", SettingType.choice("Name", "Distance"), "Name")
.optionsKey("homes.sort"); // option "Distance" -> key homes.sort.distance
KeyAction.of("homes", "go-home").displayName(Text.key("homes.keys.go_home", "Go home"));
HudElement.of("homes", "compass").displayName(Text.key("homes.hud.compass", "Home compass"));Plain strings keep working and are shown as they are.
One file per language in your mod's resources. The file name is the first part of every key, and the keys inside the file leave it out:
src/main/resources/Server/Languages/en-US/homes.lang
src/main/resources/Server/Languages/pt-BR/homes.lang
src/main/resources/Server/Languages/es-ES/homes.lang
pt-BR/homes.lang:
mod_name = Teleportes de Casa
settings.max_homes = Máximo de casas
settings.max_homes.desc = Quantas casas cada jogador pode definir
settings.limits = Limites
sort.distance = Distância
keys.go_home = Ir para casa
hud.compass = Bússola de casa
Hytale merges every mod's language files. A key missing in a language falls back to a nearby language, then to English, then to the fallback text in your code.
Write {name} in the text and fill it in with .with(…):
Text.key("homes.errors.unknown", "There is no home {name}.").with("name", homeName)Error takes a Text too, so failures your mod returns are shown translated:
return Result.failure(Error.notFound("Homes.Unknown",
Text.key("homes.errors.unknown", "There is no home {name}.").with("name", homeName)));- Only shown text is translated. Ids, stored values and choice values stay the same in every language
(
/cc-set homes:sort Distanceworks for everyone). - Search matches both the translated and the English names.
-
Keys used inside
.uifiles (%homes.title;) may only contain letters, digits and dots: an underscore there makes the client fail to load, and players can't join. Keys used from Java, like the ones above, may use_and-.
ControlCore · GitHub · CurseForge · MIT license · This wiki is generated from the repository's wiki/ folder: edit it there, not here.
Server owners
- Installing
- Control panel
- Commands
- Permissions
- Key binds
- HUD
- Mods tab
- Files and settings
- Troubleshooting
Players
Mod authors