Use locale strings

This commit is contained in:
Vortrex
2022-04-12 09:00:29 -05:00
parent c91944e36a
commit dcc051b67e
8 changed files with 32 additions and 13 deletions

View File

@@ -2149,7 +2149,7 @@ function reloadAllBusinessesCommand(command, params, client) {
setAllBusinessIndexes();
cacheAllBusinessItems();
announceAdminAction(`All businesses have been reloaded by an admin!`);
announceAdminAction(`AllBusinessesReloaded`);
}
// ===========================================================================

View File

@@ -376,7 +376,7 @@ function setWeatherCommand(command, params, client) {
getServerConfig().needsSaved = true;
announceAdminAction("ServerTimeSet", getPlayerName(client), getGameConfig().weatherNames[getServerGame()][toInteger(weatherId)]);
announceAdminAction("ServerWeatherSet", getPlayerName(client), getGameConfig().weatherNames[getServerGame()][toInteger(weatherId)]);
updateServerRules();
return true;
}
@@ -467,7 +467,7 @@ function toggleServerLogoCommand(command, params, client) {
updatePlayerShowLogoState(null, getServerConfig().useLogo);
announceAdminAction(`${getPlayerName(client)}{MAINCOLOUR}${getBoolRedGreenInlineColour(doesServerHaveServerLogoEnabled())}${toUpperCase(getOnOffFromBool(getServerConfig().useLogo))}`);
//announceAdminAction(`${getPlayerName(client)}{MAINCOLOUR}${getBoolRedGreenInlineColour(doesServerHaveServerLogoEnabled())}${toUpperCase(getOnOffFromBool(getServerConfig().useLogo))}`);
updateServerRules();
return true;
}
@@ -629,7 +629,7 @@ function toggleServerUseRealWorldTimeCommand(command, params, client) {
getServerConfig().needsSaved = true;
announceAdminAction(`${getPlayerName(client)}{MAINCOLOUR} turned real-world time ${getServerConfig().useRealTime} for this server (GMT ${addPositiveNegativeSymbol(getServerConfig().realTimeZone)})`);
//announceAdminAction(`${getPlayerName(client)}{MAINCOLOUR} turned real-world time ${getServerConfig().useRealTime} for this server (GMT ${addPositiveNegativeSymbol(getServerConfig().realTimeZone)})`);
updateServerGameTime();
updateServerRules();
return true;
@@ -655,7 +655,7 @@ function setServerRealWorldTimeZoneCommand(command, params, client) {
getServerConfig().realTimeZone = toInteger(params);
getServerConfig().needsSaved = true;
announceAdminAction(`${getPlayerName(client)} {MAINCOLOUR}set the time zone for in-game's real-world time to GMT ${addPositiveNegativeSymbol(getServerConfig().realTimeZone)}`);
//announceAdminAction(`${getPlayerName(client)} {MAINCOLOUR}set the time zone for in-game's real-world time to GMT ${addPositiveNegativeSymbol(getServerConfig().realTimeZone)}`);
updateServerGameTime();
updateServerRules();
return true;

View File

@@ -132,7 +132,7 @@ function setPayDayBonusMultiplier(command, params, client) {
getGlobalConfig().economy.grossIncomeMultiplier = newMultiplier;
announceAdminAction(`${client.name} set payday bonus to ${newMultiplier*100}%`);
announceAdminAction(`PaydayBonusSet`, `{adminRed}${client.name}{MAINCOLOUR}`, `{ALTCOLOUR}${newMultiplier*100}%{MAINCOLOUR}`);
}
// ===========================================================================

View File

@@ -1297,7 +1297,7 @@ function reloadAllHousesCommand(command, params, client) {
createAllHousePickups();
createAllHouseBlips();
announceAdminAction(`All houses have been reloaded by an admin!`);
announceAdminAction(`HousesReloaded`);
}
// ===========================================================================

View File

@@ -43,6 +43,21 @@ function getLocaleString(client, stringName, ...args) {
// ===========================================================================
function getLanguageLocaleString(localeId, stringName, ...args) {
let tempString = getRawLocaleString(stringName, localeId);
if(tempString == "") {
submitBugReport(client, `(AUTOMATED REPORT) Locale string "${stringName}" is missing for "${getPlayerLocaleName(client)}"`);
}
for(let i = 1; i <= args.length; i++) {
tempString = tempString.replace(`{${i}}`, args[i-1]);
}
return tempString;
}
// ===========================================================================
function getGroupedLocaleString(client, stringName, index, ...args) {
let tempString = getRawGroupedLocaleString(stringName, getPlayerData(client).locale, index);

View File

@@ -14,11 +14,14 @@ function initMessagingScript() {
// ===========================================================================
function announceAdminAction(messageText) {
messagePlayerNormal(null, `⚠️ ${messageText}`, getColourByName("orange"));
if(getServerConfig().discordEnabled) {
messageDiscord(`:warning: ${messageText}`);
function announceAdminAction(localeString, ...args) {
let clients = getClients();
for(let i in clients) {
let messageText = getLocaleString.apply(null, [clients[i], localeString, args]);
messagePlayerNormal(clients[i], `⚠️ ${messageText}`, getColourByName("orange"));
}
messageDiscordEventChannel(getLanguageLocaleString.apply(null, [getGlobalConfig().locale.defaultLanguageId, localeString, args]));
}
// ===========================================================================

View File

@@ -258,7 +258,7 @@ function reloadAllRadioStationsCommand(command, params, client) {
getServerData().radioStations = loadRadioStationsFromDatabase();
setRadioStationIndexes();
announceAdminAction(`All radio stations have been reloaded by an admin!`);
announceAdminAction(`AllRadioStationsReloaded`);
}
// ===========================================================================

View File

@@ -43,7 +43,8 @@ function kickClientCommand(command, params, client) {
}
}
announceAdminAction(`${getPlayerName(targetClient)} has been kicked from the server.`);
//getPlayerData(targetClient).customDisconnectReason = reason;
announceAdminAction(`PlayerKicked`, getPlayerName(targetClient));
targetClient.disconnect();
}