summaryrefslogtreecommitdiff
path: root/builtin/profiler
diff options
context:
space:
mode:
Diffstat (limited to 'builtin/profiler')
-rw-r--r--builtin/profiler/init.lua18
-rw-r--r--builtin/profiler/reporter.lua19
2 files changed, 20 insertions, 17 deletions
diff --git a/builtin/profiler/init.lua b/builtin/profiler/init.lua
index a0033d752..7f63dfaea 100644
--- a/builtin/profiler/init.lua
+++ b/builtin/profiler/init.lua
@@ -15,6 +15,8 @@
--with this program; if not, write to the Free Software Foundation, Inc.,
--51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+local S = core.get_translator("__builtin")
+
local function get_bool_default(name, default)
local val = core.settings:get_bool(name)
if val == nil then
@@ -40,9 +42,9 @@ function profiler.init_chatcommand()
instrumentation.init_chatcommand()
end
- local param_usage = "print [filter] | dump [filter] | save [format [filter]] | reset"
+ local param_usage = S("print [<filter>] | dump [<filter>] | save [<format> [<filter>]] | reset")
core.register_chatcommand("profiler", {
- description = "handle the profiler and profiling data",
+ description = S("Handle the profiler and profiling data"),
params = param_usage,
privs = { server=true },
func = function(name, param)
@@ -51,21 +53,19 @@ function profiler.init_chatcommand()
if command == "dump" then
core.log("action", reporter.print(sampler.profile, arg0))
- return true, "Statistics written to action log"
+ return true, S("Statistics written to action log.")
elseif command == "print" then
return true, reporter.print(sampler.profile, arg0)
elseif command == "save" then
return reporter.save(sampler.profile, args[1] or "txt", args[2])
elseif command == "reset" then
sampler.reset()
- return true, "Statistics were reset"
+ return true, S("Statistics were reset.")
end
- return false, string.format(
- "Usage: %s\n" ..
- "Format can be one of txt, csv, lua, json, json_pretty (structures may be subject to change).",
- param_usage
- )
+ return false,
+ S("Usage: @1", param_usage) .. "\n" ..
+ S("Format can be one of txt, csv, lua, json, json_pretty (structures may be subject to change).")
end
})
diff --git a/builtin/profiler/reporter.lua b/builtin/profiler/reporter.lua
index fed47a36b..5928a3718 100644
--- a/builtin/profiler/reporter.lua
+++ b/builtin/profiler/reporter.lua
@@ -15,6 +15,10 @@
--with this program; if not, write to the Free Software Foundation, Inc.,
--51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+local S = core.get_translator("__builtin")
+-- Note: In this file, only messages are translated
+-- but not the table itself, to keep it simple.
+
local DIR_DELIM, LINE_DELIM = DIR_DELIM, "\n"
local table, unpack, string, pairs, io, os = table, unpack, string, pairs, io, os
local rep, sprintf, tonumber = string.rep, string.format, tonumber
@@ -104,11 +108,11 @@ local TxtFormatter = Formatter:new {
end,
format = function(self, filter)
local profile = self.profile
- self:print("Values below show absolute/relative times spend per server step by the instrumented function.")
- self:print("A total of %d samples were taken", profile.stats_total.samples)
+ self:print(S("Values below show absolute/relative times spend per server step by the instrumented function."))
+ self:print(S("A total of @1 sample(s) were taken.", profile.stats_total.samples))
if filter then
- self:print("The output is limited to '%s'", filter)
+ self:print(S("The output is limited to '@1'.", filter))
end
self:print()
@@ -259,19 +263,18 @@ function reporter.save(profile, format, filter)
local output, io_err = io.open(path, "w")
if not output then
- return false, "Saving of profile failed with: " .. io_err
+ return false, S("Saving of profile failed: @1", io_err)
end
local content, err = serialize_profile(profile, format, filter)
if not content then
output:close()
- return false, "Saving of profile failed with: " .. err
+ return false, S("Saving of profile failed: @1", err)
end
output:write(content)
output:close()
- local logmessage = "Profile saved to " .. path
- core.log("action", logmessage)
- return true, logmessage
+ core.log("action", "Profile saved to " .. path)
+ return true, S("Profile saved to @1", path)
end
return reporter