2023-02-14 02:48:33 +01:00
|
|
|
#region locale
|
|
|
|
globalvar LOCALE;
|
|
|
|
LOCALE = {}
|
|
|
|
|
|
|
|
function __initLocale() {
|
2023-06-04 18:28:29 +02:00
|
|
|
var lfile = $"data/locale/en.json";
|
|
|
|
var root = $"{DIRECTORY}Locale";
|
|
|
|
var path = $"{root}/en.json";
|
2023-02-14 02:48:33 +01:00
|
|
|
|
|
|
|
if(!directory_exists(root))
|
|
|
|
directory_create(root);
|
2023-06-04 18:28:29 +02:00
|
|
|
if(file_exists(path))
|
|
|
|
file_delete(path);
|
|
|
|
file_copy(lfile, path);
|
2023-02-14 02:48:33 +01:00
|
|
|
|
2023-06-04 18:28:29 +02:00
|
|
|
loadLocale();
|
|
|
|
}
|
|
|
|
|
|
|
|
function loadLocale() {
|
|
|
|
var path = $"{DIRECTORY}Locale/{PREF_MAP[? "local"]}.json";
|
|
|
|
if(!file_exists(path))
|
|
|
|
path = $"{DIRECTORY}Locale/en.json";
|
2023-05-07 20:55:13 +02:00
|
|
|
|
2023-02-14 02:48:33 +01:00
|
|
|
LOCALE = json_load_struct(path);
|
2023-06-04 18:28:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function __txtx(key, def = "") {
|
|
|
|
if(!struct_has(LOCALE, key)) {
|
|
|
|
print($"LOCAL \"{key}\": \"{def}\",");
|
|
|
|
return def;
|
|
|
|
}
|
2023-05-07 20:55:13 +02:00
|
|
|
|
2023-06-04 18:28:29 +02:00
|
|
|
return ""//LOCALE[$ key];
|
2023-02-14 02:48:33 +01:00
|
|
|
}
|
|
|
|
|
2023-06-04 18:28:29 +02:00
|
|
|
function __txt(txt, prefix = "") {
|
|
|
|
var key = string_lower(txt);
|
|
|
|
key = string_replace_all(key, " ", "_");
|
|
|
|
|
|
|
|
return __txtx(prefix + key, txt);
|
2023-02-14 02:48:33 +01:00
|
|
|
}
|
|
|
|
#endregion
|