mirror of
https://github.com/minetest/minetest.git
synced 2024-11-27 10:03:45 +01:00
[CSM] Use more gettext (#5553)
This commit is contained in:
parent
e8d8723320
commit
eb587996e4
@ -4,7 +4,7 @@
|
|||||||
core.register_on_sending_chat_messages(function(message)
|
core.register_on_sending_chat_messages(function(message)
|
||||||
local first_char = message:sub(1,1)
|
local first_char = message:sub(1,1)
|
||||||
if first_char == "/" or first_char == "." then
|
if first_char == "/" or first_char == "." then
|
||||||
core.display_chat_message("issued command: " .. message)
|
core.display_chat_message(core.gettext("issued command: ") .. message)
|
||||||
end
|
end
|
||||||
|
|
||||||
if first_char ~= "." then
|
if first_char ~= "." then
|
||||||
@ -17,7 +17,7 @@ core.register_on_sending_chat_messages(function(message)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if not cmd then
|
if not cmd then
|
||||||
core.display_chat_message("-!- Empty command")
|
core.display_chat_message(core.gettext("-!- Empty command"))
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -29,7 +29,7 @@ core.register_on_sending_chat_messages(function(message)
|
|||||||
core.display_chat_message(message)
|
core.display_chat_message(message)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
core.display_chat_message("-!- Invalid command: " .. cmd)
|
core.display_chat_message(core.gettext("-!- Invalid command: ") .. cmd)
|
||||||
end
|
end
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
@ -31,8 +31,19 @@ end
|
|||||||
|
|
||||||
local cmd_marker = "/"
|
local cmd_marker = "/"
|
||||||
|
|
||||||
|
local function gettext(...)
|
||||||
|
return ...
|
||||||
|
end
|
||||||
|
|
||||||
|
local function gettext_replace(text, replace)
|
||||||
|
return text:gsub("$1", replace)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
if INIT == "client" then
|
if INIT == "client" then
|
||||||
cmd_marker = "."
|
cmd_marker = "."
|
||||||
|
gettext = core.gettext
|
||||||
|
gettext_replace = fgettext_ne
|
||||||
end
|
end
|
||||||
|
|
||||||
local function do_help_cmd(name, param)
|
local function do_help_cmd(name, param)
|
||||||
@ -54,9 +65,9 @@ local function do_help_cmd(name, param)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
table.sort(cmds)
|
table.sort(cmds)
|
||||||
return true, "Available commands: " .. table.concat(cmds, " ") .. "\n"
|
return true, gettext("Available commands: ") .. table.concat(cmds, " ") .. "\n"
|
||||||
.. "Use '"..cmd_marker.."help <cmd>' to get more information,"
|
.. gettext_replace("Use '$1help <cmd>' to get more information,"
|
||||||
.. " or '"..cmd_marker.."help all' to list everything."
|
.. " or '$1help all' to list everything.", cmd_marker)
|
||||||
elseif param == "all" then
|
elseif param == "all" then
|
||||||
local cmds = {}
|
local cmds = {}
|
||||||
for cmd, def in pairs(core.registered_chatcommands) do
|
for cmd, def in pairs(core.registered_chatcommands) do
|
||||||
@ -65,7 +76,7 @@ local function do_help_cmd(name, param)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
table.sort(cmds)
|
table.sort(cmds)
|
||||||
return true, "Available commands:\n"..table.concat(cmds, "\n")
|
return true, gettext("Available commands:").."\n"..table.concat(cmds, "\n")
|
||||||
elseif INIT == "game" and param == "privs" then
|
elseif INIT == "game" and param == "privs" then
|
||||||
local privs = {}
|
local privs = {}
|
||||||
for priv, def in pairs(core.registered_privileges) do
|
for priv, def in pairs(core.registered_privileges) do
|
||||||
@ -77,7 +88,7 @@ local function do_help_cmd(name, param)
|
|||||||
local cmd = param
|
local cmd = param
|
||||||
local def = core.registered_chatcommands[cmd]
|
local def = core.registered_chatcommands[cmd]
|
||||||
if not def then
|
if not def then
|
||||||
return false, "Command not available: "..cmd
|
return false, gettext("Command not available: ")..cmd
|
||||||
else
|
else
|
||||||
return true, format_help_line(cmd, def)
|
return true, format_help_line(cmd, def)
|
||||||
end
|
end
|
||||||
@ -86,8 +97,8 @@ end
|
|||||||
|
|
||||||
if INIT == "client" then
|
if INIT == "client" then
|
||||||
core.register_chatcommand("help", {
|
core.register_chatcommand("help", {
|
||||||
params = "[all/<cmd>]",
|
params = gettext("[all/<cmd>]"),
|
||||||
description = "Get help for commands",
|
description = gettext("Get help for commands"),
|
||||||
func = function(param)
|
func = function(param)
|
||||||
return do_help_cmd(nil, param)
|
return do_help_cmd(nil, param)
|
||||||
end,
|
end,
|
||||||
|
Loading…
Reference in New Issue
Block a user