feat: add translation support

This commit is contained in:
Martin Prokoph
2025-08-02 11:15:53 +02:00
parent ec1841a592
commit dfba8b397e
14 changed files with 173 additions and 43 deletions

View File

@@ -0,0 +1,19 @@
package eu.midnightdust.yaytris;
import eu.midnightdust.yaytris.util.NightJson;
import java.util.HashMap;
import java.util.Map;
public class Translation {
public static Map<String, String> translationMap = new HashMap<>();
public static void load(String locale) {
NightJson json = new NightJson(translationMap, String.format("translation/%s.json5", locale));
json.readJson();
}
public static String t(String key, Object... args) {
return String.format(translationMap.getOrDefault(key, key), args);
}
}