Use external locale resource funcs
This commit is contained in:
@@ -8,53 +8,32 @@
|
||||
// ===========================================================================
|
||||
|
||||
function getLocaleString(stringName, ...args) {
|
||||
if(typeof getServerData().localeStrings[localLocaleId][stringName] == undefined) {
|
||||
return "";
|
||||
}
|
||||
return findResourceByName("agrp_locale").exports.getLocaleString(localLocaleId, stringName, args);
|
||||
}
|
||||
|
||||
let tempString = getServerData().localeStrings[localLocaleId][stringName];
|
||||
// ===========================================================================
|
||||
|
||||
if(tempString == "" || tempString == null || tempString == undefined) {
|
||||
return "";
|
||||
}
|
||||
|
||||
for(let i = 1; i <= args.length; i++) {
|
||||
tempString = tempString.replace(`{${i}}`, args[i-1]);
|
||||
}
|
||||
|
||||
return tempString;
|
||||
function getGroupedLocaleString(stringName, index, ...args) {
|
||||
return findResourceByName("agrp_locale").exports.getGroupedLocaleString(localLocaleId, stringName, index, args);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function getAvailableLocaleOptions() {
|
||||
return getServerData().localeOptions.filter(localeOption => localeOption.requiresUnicode == false);
|
||||
return findResourceByName("agrp_locale").exports.getAvailableLocaleOptions();
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function loadLocaleConfig() {
|
||||
let configFile = loadTextFile("config/client/locale.json");
|
||||
getServerData().localeOptions = JSON.parse(configFile);
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function loadAllLocaleStrings() {
|
||||
let localeOptions = getServerData().localeOptions;
|
||||
for(let i in localeOptions) {
|
||||
logToConsole(LOG_INFO, `[VRR.Locale] Loading locale strings for ${localeOptions[i].englishName} (${i})`);
|
||||
let localeFile = loadTextFile(`locale/${localeOptions[i].stringsFile}`);
|
||||
let localeData = JSON.parse(localeFile);
|
||||
|
||||
getServerData().localeStrings[i] = localeData;
|
||||
}
|
||||
function getLocales() {
|
||||
return findResourceByName("agrp_locale").exports.getLocales();
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function setLocale(tempLocaleId) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.Locale] Setting locale to ${tempLocaleId} (${getServerData().localeOptions[tempLocaleId].englishName})`);
|
||||
let locales = getLocales();
|
||||
logToConsole(LOG_DEBUG, `[VRR.Locale] Setting locale to ${tempLocaleId} (${locales[tempLocaleId].englishName})`);
|
||||
localLocaleId = tempLocaleId;
|
||||
resetGUIStrings();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user