2023-02-14 02:48:33 +01:00
|
|
|
#region locale
|
|
|
|
globalvar LOCALE;
|
|
|
|
LOCALE = {}
|
|
|
|
|
|
|
|
function __initLocale() {
|
2023-03-08 12:14:01 +01:00
|
|
|
var lfile = "data/locale/en.json";
|
2023-02-14 02:48:33 +01:00
|
|
|
var root = DIRECTORY + "Locale";
|
2023-03-08 12:14:01 +01:00
|
|
|
var path = root + "/en.json";
|
2023-02-14 02:48:33 +01:00
|
|
|
|
|
|
|
if(!directory_exists(root))
|
|
|
|
directory_create(root);
|
|
|
|
|
2023-05-07 20:55:13 +02:00
|
|
|
var _l = root + "/version";
|
|
|
|
if(file_exists(_l)) {
|
|
|
|
var res = json_load_struct(_l);
|
|
|
|
if(!is_struct(res) || !struct_has(res, "version") || res.version != BUILD_NUMBER)
|
|
|
|
file_copy(lfile, path);
|
|
|
|
} else
|
|
|
|
file_copy(lfile, path);
|
|
|
|
|
2023-02-14 02:48:33 +01:00
|
|
|
LOCALE = json_load_struct(path);
|
2023-05-07 20:55:13 +02:00
|
|
|
|
|
|
|
json_save_struct(_l, { version: BUILD_NUMBER });
|
2023-02-14 02:48:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function get_text(key, def = "") {
|
|
|
|
if(!struct_has(LOCALE, key)) return def;
|
|
|
|
return LOCALE[$ key];
|
|
|
|
}
|
|
|
|
#endregion
|