Use HOCON for translating Minecraft mods!
To make Hang work, you first have to make mixin into the class "ClientLanguageMap" (can be different in fabric and other
versions).
Then @ModifyArg into the func_239497_a
(the name can be different on fabric and other versions) at the invocation of
the ClientLanguageMap's constructor and change the map parameter as shown in the example down here.
// ClientLanguageMapMixin.java
@Mixin(ClientLanguageMap.class)
public class ClientLanguageMapMixin {
@ModifyArg(
method = "func_239497_a_",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/resources/ClientLanguageMap;<init>(Ljava/util/Map;Z)V"
),
index = 0
)
private static Map<String, String> updateMap(Map<String, String> map) {
return new Hang("YOUR_MOD_ID", YourModClass.class.getClassLoader()).init(map).preferJson(false).get();
}
}
Add our repository: https://dev.gloryx.net/main
Then add the dependency, and replace ${hangVersion}
with the suitable version of Hang:
implementation("net.gloryx:hang:${hangVersion}")
<dependency>
<groupId>net.gloryx</groupId>
<artifactId>hang</artifactId>
<version>${hangVersion}</version>
</dependency>
!!! YOU DON'T HAVE TO !!!
@Deprecated
!!! IMPORTANT !!!
You still need to create language .json-s (for cross-modloader compatibility),
and add the property hang with the language code of that language file (e.g. en_us)!
Otherwise this won't work.
Example en_us.json:
// {
// "hang": "en_us"
// }