Add locales/translations (unfinished)

This commit is contained in:
Vortrex
2021-11-16 02:02:18 -06:00
parent 7cf858801b
commit df920ef046
5 changed files with 70 additions and 12 deletions

View File

@@ -45,14 +45,15 @@ function setAccentCommand(command, params, client) {
let accentId = getAccentFromParams(params); let accentId = getAccentFromParams(params);
if(!accentId) { if(!accentId) {
messagePlayerError(client, "Accent not found!"); messagePlayerError(client, getLocaleString("AccentNotFound"));
return false; return false;
} }
let accentString = getGlobalConfig().accents[accentId]; let accentString = getGlobalConfig().accents[accentId];
getPlayerCurrentSubAccount(client).accent = accentString; getPlayerCurrentSubAccount(client).accent = accentString;
messagePlayerSuccess(client, `You set your accent to ${getInlineChatColourByName("lightGrey")}${accentString}`);
messagePlayerSuccess(client, getLocaleString(client, "AccentSet", accentString));
} }
// =========================================================================== // ===========================================================================

View File

@@ -25,13 +25,13 @@ function playPlayerAnimationCommand(command, params, client) {
let animationPositionOffset = getAnimationFromParams(splitParams[1]) || 1; let animationPositionOffset = getAnimationFromParams(splitParams[1]) || 1;
if(!animationSlot) { if(!animationSlot) {
messagePlayerError(client, "That animation doesn't exist!"); messagePlayerError(client, getLocaleString("AnimationNotFound"));
messagePlayerInfo(client, "Use /animlist to see a list of valid animations"); messagePlayerInfo(client, getLocaleString("AnimationHelpTip"));
return false; return false;
} }
if(toInteger(animationPositionOffset) < 0 || toInteger(animationPositionOffset) > 3) { if(toInteger(animationPositionOffset) < 0 || toInteger(animationPositionOffset) > 3) {
messagePlayerError(client, "The offset must be between 0 and 3!") messagePlayerError(client, getLocaleString("AnimationInvalidDistance"));
return false; return false;
} }
@@ -40,11 +40,11 @@ function playPlayerAnimationCommand(command, params, client) {
getPlayerData(client).currentAnimationPositionReturnTo = getPlayerPosition(client); getPlayerData(client).currentAnimationPositionReturnTo = getPlayerPosition(client);
getPlayerData(client).animationStart = getCurrentUnixTimestamp(); getPlayerData(client).animationStart = getCurrentUnixTimestamp();
//setEntityData(getPlayerData(client).ped, "vrr.animation", animationSlot, true); //setEntityData(getPlayerData(client).ped, "vrr.animation", animationSlot, true);
messagePlayerTip(client, `${getInlineChatColourByName("white")}Use ${getInlineChatColourByName("lightGrey")}/stopanim ${getInlineChatColourByName("white")}to stop your animation`); messagePlayerTip(client, ``);
makePedPlayAnimation(getPlayerData(client).ped, animationSlot, animationPositionOffset); makePedPlayAnimation(getPlayerData(client).ped, animationSlot, animationPositionOffset);
if(getAnimationData(animationSlot)[9] != VRR_ANIMMOVE_NONE) { if(getAnimationData(animationSlot)[9] != VRR_ANIMMOVE_NONE) {
if(getGame() < GAME_GTA_SA) { if(getGame() < VRR_GAME_GTA_SA) {
setPlayerMouseCameraState(client, true); setPlayerMouseCameraState(client, true);
} }
} }

View File

@@ -24,7 +24,7 @@ function accountBanCommand(command, params, client) {
// Prevent banning admins with really high permissions // Prevent banning admins with really high permissions
if(doesPlayerHaveStaffPermission(targetClient, "ManageServer") || doesPlayerHaveStaffPermission(targetClient, "Developer")) { if(doesPlayerHaveStaffPermission(targetClient, "ManageServer") || doesPlayerHaveStaffPermission(targetClient, "Developer")) {
messagePlayerError(client, "You cannot ban this person!"); messagePlayerError(client, getLocaleString(client, "CantBanPlayer"));
return false; return false;
} }
@@ -49,7 +49,7 @@ function subAccountBanCommand(command, params, client, fromDiscord) {
// Prevent banning admins with really high permissions // Prevent banning admins with really high permissions
if(doesPlayerHaveStaffPermission(targetClient, "ManageServer") || doesPlayerHaveStaffPermission(targetClient, "Developer")) { if(doesPlayerHaveStaffPermission(targetClient, "ManageServer") || doesPlayerHaveStaffPermission(targetClient, "Developer")) {
messagePlayerError(client, "You cannot ban this person!"); messagePlayerError(client, getLocaleString(client, "CantBanPlayer"));
return false; return false;
} }
@@ -74,7 +74,7 @@ function ipBanCommand(command, params, client, fromDiscord) {
// Prevent banning admins with really high permissions // Prevent banning admins with really high permissions
if(doesPlayerHaveStaffPermission(targetClient, "ManageServer") || doesPlayerHaveStaffPermission(targetClient, "Developer")) { if(doesPlayerHaveStaffPermission(targetClient, "ManageServer") || doesPlayerHaveStaffPermission(targetClient, "Developer")) {
messagePlayerError(client, "You cannot ban this person!"); messagePlayerError(client, getLocaleString(client, "CantBanPlayer"));
return false; return false;
} }
@@ -98,7 +98,7 @@ function subNetBanCommand(command, params, client, fromDiscord) {
// Prevent banning admins with really high permissions // Prevent banning admins with really high permissions
if(doesPlayerHaveStaffPermission(targetClient, "ManageServer") || doesPlayerHaveStaffPermission(targetClient, "Developer")) { if(doesPlayerHaveStaffPermission(targetClient, "ManageServer") || doesPlayerHaveStaffPermission(targetClient, "Developer")) {
messagePlayerError(client, "You cannot ban this person!"); messagePlayerError(client, getLocaleString(client, "CantBanPlayer"));
return false; return false;
} }

View File

@@ -7,4 +7,51 @@
// TYPE: Server (JavaScript) // TYPE: Server (JavaScript)
// =========================================================================== // ===========================================================================
// (V) This may be obsolete with the new translation tool! let localeStrings = {};
// ===========================================================================
function initLocaleScript() {
localeStrings = loadAllLocaleStrings();
}
// ===========================================================================
function getLocaleString(client, stringName, ...args) {
let tempString = getRawLocaleString(stringName, getPlayerLocaleName(client));
tempString = replaceColoursInLocaleString(tempString);
for(let i in args) {
tempString = tempString.replace(`{${i}}`, args[i]);
}
}
// ===========================================================================
function getRawLocaleString(stringName, localeName) {
return localeStrings[localeName][stringName];
}
// ===========================================================================
function getPlayerLocaleName(client) {
if(client == null) {
return getLocaleNameFromParams(`English`);
}
return getPlayerData(client).accountData.locale;
}
// ===========================================================================
function loadAllLocaleStrings() {
let locales = getGlobalConfig().locales;
for(let i in locales) {
let localeData = locales[i];
let localeFile = JSON.parse(loadTextFile(`locale/${localeData[1]}.json`));
localeStrings[localeData[1]] = localeFile;
}
}
// ===========================================================================

View File

@@ -0,0 +1,10 @@
{
"AccentNotFound": "Accent not found!",
"AccentSet": "You set your accent to {ALTCOLOUR}{%1}",
"AnimationNotFound": "That animation doesn't exist!",
"AnimationCommandTip": "Use /animlist to see a list of valid animations",
"AnimationInvalidDistance": "The distance must be between 0 and 3!",
"AnimationStopCommandTip": "Use {ALTCOLOUR}/stopanim {RESETCOLOUR}to stop your animation",
"CantBanClient": "You cannot ban this person!",
"PlayerAccountBanned": "{1} has been account banned"
}