Skip to content

Commit 11e0b6b

Browse files
committed
refactor(GM): Update localization with replacement pattern
1 parent 10c38ad commit 11e0b6b

4 files changed

Lines changed: 46 additions & 41 deletions

File tree

Commands/Commands_Generics.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ function genericBagCommand(caller)
2727
if (caller == "GM") then
2828
param = ma_gmParametersInput:GetText()
2929
end
30+
param = (param == nil or param == "" and "0" or param)
3031
MangAdmin:ChatMsg(".character check bag " .. param)
31-
MangAdmin:LogAction(Locale["log_bag"] .. player .. " " .. param)
32+
MangAdmin:LogAction(genericLogGenerator("log_bag", {['value'] = param, ['target'] = player}))
3233
end
3334

3435
function genericCaller(dictionaryID, callID, value)

Commands/Commands_Main.lua

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ function GM_createAccountCommand()
237237
return
238238
end
239239
MangAdmin:ChatMsg(".account create " .. params[1] .. " " .. params[2])
240-
MangAdmin:LogAction(Locale["logGM_createAccountCompleted"] .. params[1] .. " " .. params[2])
240+
MangAdmin:LogAction(genericLogGenerator("logGM_createAccountCompleted", {["value"] = input}))
241241
print(Locale["operationCompleted"])
242242
end
243243

@@ -258,7 +258,7 @@ function GM_deleteAccountCommand()
258258
return
259259
end
260260
MangAdmin:ChatMsg(".account delete " .. params[1])
261-
MangAdmin:LogAction(Locale["logGM_deleteAccountCompleted"] .. params[1])
261+
MangAdmin:LogAction(genericLogGenerator("logGM_deleteAccountCompleted", {["value"] = input}))
262262
print(Locale["operationCompleted"])
263263
end
264264

@@ -286,7 +286,7 @@ function GM_setAccountGMLevelCommand()
286286
return
287287
end
288288
MangAdmin:ChatMsg(".account set gmlevel " .. params[1] .. " " .. params[2] .. " -1")
289-
MangAdmin:LogAction(params[1] .. Locale["logGM_setAccountGMLevelCompleted"] .. params[2])
289+
MangAdmin:LogAction(genericLogGenerator("logGM_setAccountGMLevelCompleted", {["value"] = input}))
290290
print(Locale["operationCompleted"])
291291
end
292292

@@ -318,7 +318,7 @@ function GM_setAccountPasswordCommand()
318318
return
319319
end
320320
MangAdmin:ChatMsg(".account set password " .. params[1] .. " " .. params[2] .. " " .. params[3])
321-
MangAdmin:LogAction(params[1] .. Locale["logGM_setAccountPasswordCompleted"] .. params[2])
321+
MangAdmin:LogAction(genericLogGenerator("logGM_setAccountPasswordCompleted", {["value"] = params[1] .. " " .. params[2]}))
322322
print(Locale["operationCompleted"])
323323
end
324324

@@ -346,7 +346,7 @@ function GM_setAccountAddonCommand()
346346
return
347347
end
348348
MangAdmin:ChatMsg(".account set addon " .. params[1] .. " " .. params[2])
349-
MangAdmin:LogAction(params[1] .. Locale["logGM_setAccountAddonCompleted"] .. params[2])
349+
MangAdmin:LogAction(genericLogGenerator("logGM_setAccountAddonCompleted", {["value"] = input}))
350350
print(Locale["operationCompleted"])
351351
end
352352

@@ -439,7 +439,7 @@ function GridNavigate(x, y)
439439
newx = x
440440
end
441441
MangAdmin:ChatMsg(".go xy " .. newx .. " " .. newy)
442-
MangAdmin:LogAction(Locale["logGM_gridNavigator"] .. newx .. " " .. newy)
442+
MangAdmin:LogAction(genericLogGenerator("logGM_gridNavigator", {["value"] = newx .. " " .. newy}))
443443
else
444444
MangAdmin:Print(Locale["mustBeANumber"])
445445
end

Locales/enUS.lua

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ function Return_enUS()
8989
["operationCompleted"] = "|cff00FF00Operation completed successfully|r",
9090
["mustBeANumber"] = "Value must be a number!",
9191
["log_resetSlider"] = "Reset slider to 1.0",
92-
["log_bag"] = "Opened #User bag #slot: ",
92+
["log_bag"] = "Opened _T_'s bag on slot _V1_ ",
9393
--[[GM-Name]]
9494
["tabname_GM"] = "GM",
9595
--[[GM-Tooltips]]
@@ -230,47 +230,47 @@ function Return_enUS()
230230
["logGM_visibility"] = "Turned your visibility to _V1_",
231231
["logGM_cheatTaxi"] = "Taxi cheat for _T_ has been set to _V1_",
232232
["logGM_cheatExploreMaps"] = "Explore maps cheat for _T_ has been set to _V1_",
233-
["logGM_cheatWaterWalk"] = " waterwalk cheat to",
234-
["logGM_cheatNoCastTime"] = "Turned NoCastTime to ",
235-
["logGM_cheatNoCooldown"] = "Turned NoCooldown to ",
236-
["logGM_accountIPLock"] = "Turned GM account lock to ",
237-
["logGM_createAccountCompleted"] = "Created the following account: ",
238-
["logGM_deleteAccountCompleted"] = "Deleted the following account: ",
239-
["logGM_setAccountGMLevelCompleted"] = " has been set to GM Level ",
240-
["logGM_setAccountPasswordCompleted"] = "'s password has been set to ",
241-
["logGM_setAccountAddonCompleted"] = "'s addon level has been set to ",
233+
["logGM_cheatWaterWalk"] = "WaterWalk cheat for _T_ has been set to _V1_",
234+
["logGM_cheatNoCastTime"] = "Turned NoCastTime to _V1_",
235+
["logGM_cheatNoCooldown"] = "Turned NoCooldown to _V1_",
236+
["logGM_accountIPLock"] = "Turned GM account lock to _V1_",
237+
["logGM_createAccountCompleted"] = "Created the following account: _V1_ with password: _V2_",
238+
["logGM_deleteAccountCompleted"] = "Deleted the following account: _V1_",
239+
["logGM_setAccountGMLevelCompleted"] = "_V1_'s GM level has been set to _V2_",
240+
["logGM_setAccountPasswordCompleted"] = "_V1_'s password has been set to _V2_",
241+
["logGM_setAccountAddonCompleted"] = "_V1_'s addon level has been set to _V2_",
242242
["logGM_GMList"] = "Listed GM accounts",
243243
["logGM_GMInGame"] = "Listed currently online GMs",
244-
["logGM_GMNotify"] = "Sent GM Notify: ",
245-
["logGM_GMMessage"] = "Sent GM Message: ",
246-
["logGM_cast"] = "Cast spell with ID: ",
247-
["logGM_castBack"] = "Cast back spell with ID: ",
248-
["logGM_castDist"] = "Cast spell with ID/distance: ",
249-
["logGM_castSelf"] = "Cast self spell with ID: ",
250-
["logGM_castTarget"] = "Cast target spell with ID: ",
251-
["logGM_teleportAdd"] = " has been added as teleport location",
252-
["logGM_teleportDel"] = " has been deleted as teleport location",
253-
["logGM_listItem"] = "Listed Item with ID: ",
254-
["logGM_lookupTaxi"] = "Looked up Taxinode with ID: ",
255-
["logGM_lookupZone"] = "Looked up Zone with ID: ",
256-
["logGM_goTaxi"] = "Teleported to TaxiNode with ID: ",
257-
["logGM_goTrigger"] = "Teleported to Trigger with ID: ",
258-
["logGM_goXY"] = "Teleported to the following coordinates #X #Y: ",
259-
["logGM_goXYZ"] = "Teleported to the following coordinates #X #Y #Z: ",
260-
["logGM_goZoneXY"] = "Teleported to #ZoneID #X #Y: ",
244+
["logGM_GMNotify"] = "Sent GM Notify: _V1_",
245+
["logGM_GMMessage"] = "Sent GM Message: _V1_",
246+
["logGM_cast"] = "Cast spell with ID: _V1_",
247+
["logGM_castBack"] = "Cast back spell with ID: _V1_",
248+
["logGM_castDist"] = "Cast spell with ID: _V1_ and distance: _V2_",
249+
["logGM_castSelf"] = "Cast self spell with ID: _V1_",
250+
["logGM_castTarget"] = "Cast target spell with ID: _V1_",
251+
["logGM_teleportAdd"] = "_V1_ has been added as teleport location",
252+
["logGM_teleportDel"] = "_V1_ has been deleted as teleport location",
253+
["logGM_listItem"] = "Listed Item with ID: _V1_",
254+
["logGM_lookupTaxi"] = "Looked up Taxinode with ID: _V1_",
255+
["logGM_lookupZone"] = "Looked up Zone with ID: _V1_",
256+
["logGM_goTaxi"] = "Teleported to TaxiNode with ID: _V1_",
257+
["logGM_goTrigger"] = "Teleported to Trigger with ID: _V1_",
258+
["logGM_goXY"] = "Teleported to the X: _V1_ and Y: _V2_",
259+
["logGM_goXYZ"] = "Teleported to the X: _V1_ Y: _V2_ Z: _V3_",
260+
["logGM_goZoneXY"] = "Teleported to ZoneID _V1_ on X: _V2_ and Y: _V3_",
261261
["logGM_setJailAlliance"] = "Set location of Alliance Jail",
262262
["logGM_setJailHorde"] = "Set location of Horde Jail",
263263
["logGM_petCreate"] = "Created a pet",
264-
["logGM_petLearn"] = "Taught pet spell with ID: ",
265-
["logGM_petUnLearn"] = "Un-taught pet spell with ID: ",
264+
["logGM_petLearn"] = "Taught pet spell with ID: _V1_",
265+
["logGM_petUnLearn"] = "Un-taught pet spell with ID: _V1_",
266266
["logGM_petTalentsLearn"] = "Your pet is a genius (learnt all talents)",
267267
["logGM_bank"] = "Opened your bank",
268268
["logGM_screen"] = "Took a screenshot",
269269
["logGM_dismountPlayer"] = "Dismounted from mount",
270270
["logGM_instantKillMode"] = " insta-kill",
271-
["logGM_setSpeed"] = "'s speed has been set to",
272-
["logGM_setScale"] = "'s scale has been set to'",
273-
["logGM_gridNavigator"] = "Teleported to the following grid-coordinates #X #Y: ",
271+
["logGM_setSpeed"] = "'s speed has been set to ",
272+
["logGM_setScale"] = "'s scale has been set to ",
273+
["logGM_gridNavigator"] = "Teleported to the following grid-coordinates X: _V1_ and Y: _V2_",
274274
--[[Char Tab]]
275275
--[[Name]]
276276
["tabmenu_Char"] = "CHAR",

Utils/Utils.lua

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,12 @@ end
2626
function genericLogGenerator(textID, data)
2727
local log = Locale[textID]
2828
local params = {}
29-
for w in data['value']:gmatch("%w+") do
30-
table.insert(params, w)
29+
if(textID ~= "logGM_GMNotify" and textID ~= "logGM_GMMessage") then
30+
for w in data['value']:gmatch("%w+") do
31+
table.insert(params, w)
32+
end
33+
else
34+
params[1] = data['value']
3135
end
3236
for i = #params, 1, -1 do
3337
local pattern = "_V" .. i .. "_"

0 commit comments

Comments
 (0)