Skip to content

Commit eb58799

Browse files
red-001nerzhul
authored andcommittedApr 10, 2017
[CSM] Use more gettext (#5553)
1 parent e8d8723 commit eb58799

File tree

2 files changed

+21
-10
lines changed

2 files changed

+21
-10
lines changed
 

‎builtin/client/chatcommands.lua

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
core.register_on_sending_chat_messages(function(message)
55
local first_char = message:sub(1,1)
66
if first_char == "/" or first_char == "." then
7-
core.display_chat_message("issued command: " .. message)
7+
core.display_chat_message(core.gettext("issued command: ") .. message)
88
end
99

1010
if first_char ~= "." then
@@ -17,7 +17,7 @@ core.register_on_sending_chat_messages(function(message)
1717
end
1818

1919
if not cmd then
20-
core.display_chat_message("-!- Empty command")
20+
core.display_chat_message(core.gettext("-!- Empty command"))
2121
return true
2222
end
2323

@@ -29,7 +29,7 @@ core.register_on_sending_chat_messages(function(message)
2929
core.display_chat_message(message)
3030
end
3131
else
32-
core.display_chat_message("-!- Invalid command: " .. cmd)
32+
core.display_chat_message(core.gettext("-!- Invalid command: ") .. cmd)
3333
end
3434

3535
return true

‎builtin/common/chatcommands.lua

+18-7
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,19 @@ end
3131

3232
local cmd_marker = "/"
3333

34+
local function gettext(...)
35+
return ...
36+
end
37+
38+
local function gettext_replace(text, replace)
39+
return text:gsub("$1", replace)
40+
end
41+
42+
3443
if INIT == "client" then
3544
cmd_marker = "."
45+
gettext = core.gettext
46+
gettext_replace = fgettext_ne
3647
end
3748

3849
local function do_help_cmd(name, param)
@@ -54,9 +65,9 @@ local function do_help_cmd(name, param)
5465
end
5566
end
5667
table.sort(cmds)
57-
return true, "Available commands: " .. table.concat(cmds, " ") .. "\n"
58-
.. "Use '"..cmd_marker.."help <cmd>' to get more information,"
59-
.. " or '"..cmd_marker.."help all' to list everything."
68+
return true, gettext("Available commands: ") .. table.concat(cmds, " ") .. "\n"
69+
.. gettext_replace("Use '$1help <cmd>' to get more information,"
70+
.. " or '$1help all' to list everything.", cmd_marker)
6071
elseif param == "all" then
6172
local cmds = {}
6273
for cmd, def in pairs(core.registered_chatcommands) do
@@ -65,7 +76,7 @@ local function do_help_cmd(name, param)
6576
end
6677
end
6778
table.sort(cmds)
68-
return true, "Available commands:\n"..table.concat(cmds, "\n")
79+
return true, gettext("Available commands:").."\n"..table.concat(cmds, "\n")
6980
elseif INIT == "game" and param == "privs" then
7081
local privs = {}
7182
for priv, def in pairs(core.registered_privileges) do
@@ -77,7 +88,7 @@ local function do_help_cmd(name, param)
7788
local cmd = param
7889
local def = core.registered_chatcommands[cmd]
7990
if not def then
80-
return false, "Command not available: "..cmd
91+
return false, gettext("Command not available: ")..cmd
8192
else
8293
return true, format_help_line(cmd, def)
8394
end
@@ -86,8 +97,8 @@ end
8697

8798
if INIT == "client" then
8899
core.register_chatcommand("help", {
89-
params = "[all/<cmd>]",
90-
description = "Get help for commands",
100+
params = gettext("[all/<cmd>]"),
101+
description = gettext("Get help for commands"),
91102
func = function(param)
92103
return do_help_cmd(nil, param)
93104
end,

0 commit comments

Comments
 (0)
Please sign in to comment.