feat(NightJson): add arbitrary key-val pairs via map

This commit is contained in:
Martin Prokoph
2025-08-02 11:38:03 +02:00
parent dfba8b397e
commit e4c7896a15
2 changed files with 25 additions and 20 deletions

View File

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