From 8cecd232a486e72f203b9d680442cce30bf0d80d Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Tue, 5 Apr 2022 23:59:06 -0500 Subject: [PATCH] Client-side locale stuff --- scripts/client/locale.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 scripts/client/locale.js diff --git a/scripts/client/locale.js b/scripts/client/locale.js new file mode 100644 index 00000000..1d806513 --- /dev/null +++ b/scripts/client/locale.js @@ -0,0 +1,26 @@ +// =========================================================================== +// Vortrex's Roleplay Resource +// https://github.com/VortrexFTW/gtac_roleplay +// =========================================================================== +// FILE: locale.js +// DESC: Provides locale functions and usage +// TYPE: Client (JavaScript) +// =========================================================================== + +function getLocaleString(stringName, ...args) { + let tempString = getServerData().localeStrings[stringName]; + + for(let i = 1; i <= args.length; i++) { + tempString = tempString.replace(`{${i}}`, args[i-1]); + } + + return tempString; +} + +// =========================================================================== + +function receiveLocaleStringFromServer(stringName, stringValue) { + getServerData().localeStrings[stringName] = stringValue; +} + +// =========================================================================== \ No newline at end of file