Fix a lot of client locale stuff
This commit is contained in:
@@ -8,11 +8,15 @@
|
|||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
function getLocaleString(stringName, ...args) {
|
function getLocaleString(stringName, ...args) {
|
||||||
if(typeof getServerData().localeStrings[stringName] == undefined) {
|
if(typeof getServerData().localeStrings[localLocaleId][stringName] == undefined) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
let tempString = getServerData().localeStrings[stringName];
|
let tempString = getServerData().localeStrings[localLocaleId][stringName];
|
||||||
|
|
||||||
|
if(tempString == "" || tempString == null || tempString == undefined) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
for(let i = 1; i <= args.length; i++) {
|
for(let i = 1; i <= args.length; i++) {
|
||||||
tempString = tempString.replace(`{${i}}`, args[i-1]);
|
tempString = tempString.replace(`{${i}}`, args[i-1]);
|
||||||
@@ -23,18 +27,36 @@ function getLocaleString(stringName, ...args) {
|
|||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
function receiveLocaleStringFromServer(stringName, stringValue) {
|
function getAvailableLocaleOptions() {
|
||||||
logToConsole(LOG_INFO, `[VRR.Locale]: Received locale string "${stringName}" from server (${stringValue})`);
|
return getServerData().localeOptions.filter(localeOption => localeOption.requiresUnicode == false);
|
||||||
getServerData().localeStrings[stringName] = stringValue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
function receiveLocaleStringsFromServer(strings) {
|
function loadLocaleConfig() {
|
||||||
for(let i in strings) {
|
let configFile = loadTextFile("config/client/locale.json");
|
||||||
let stringName = strings[i][0];
|
getServerData().localeOptions = JSON.parse(configFile);
|
||||||
getServerData().localeStrings[stringName] = strings[i][1];
|
}
|
||||||
|
|
||||||
|
// ===========================================================================
|
||||||
|
|
||||||
|
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 setLocale(tempLocaleId) {
|
||||||
|
logToConsole(LOG_DEBUG, `[VRR.Locale] Setting locale to ${tempLocaleId} (${getServerData().localeOptions[tempLocaleId].englishName})`);
|
||||||
|
localLocaleId = tempLocaleId;
|
||||||
|
resetGUIStrings();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===========================================================================
|
||||||
Reference in New Issue
Block a user