all: yet another round of translation fixes
[project/luci.git] / modules / admin-full / luasrc / model / cbi / admin_system / system.lua
1 --[[
2 LuCI - Lua Configuration Interface
3
4 Copyright 2008 Steven Barth <steven@midlink.org>
5
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
9
10         http://www.apache.org/licenses/LICENSE-2.0
11
12 $Id$
13 ]]--
14
15 require("luci.sys")
16 require("luci.sys.zoneinfo")
17 require("luci.tools.webadmin")
18
19 m = Map("system", translate("System"), translate("Here you can configure the basic aspects of your device like its hostname or the timezone."))
20
21 s = m:section(TypedSection, "system", "")
22 s.anonymous = true
23 s.addremove = false
24
25 local system, model, memtotal, memcached, membuffers, memfree = luci.sys.sysinfo()
26 local uptime = luci.sys.uptime()
27
28 s:option(DummyValue, "_system", translate("System")).value = system
29 s:option(DummyValue, "_cpu", translate("Processor")).value = model
30
31 local load1, load5, load15 = luci.sys.loadavg()
32 s:option(DummyValue, "_la", translate("Load")).value =
33  string.format("%.2f, %.2f, %.2f", load1, load5, load15)
34
35 s:option(DummyValue, "_memtotal", translate("Memory")).value =
36  string.format("%.2f MB (%.0f%% %s, %.0f%% %s, %.0f%% %s)",
37   tonumber(memtotal) / 1024,
38   100 * memcached / memtotal,
39   tostring(translate("cached")),
40   100 * membuffers / memtotal,
41   tostring(translate("buffered")),
42   100 * memfree / memtotal,
43   tostring(translate("free"))
44 )
45
46 s:option(DummyValue, "_systime", translate("Local Time")).value =
47  os.date("%c")
48
49 s:option(DummyValue, "_uptime", translate("Uptime")).value =
50  luci.tools.webadmin.date_format(tonumber(uptime))
51
52 hn = s:option(Value, "hostname", translate("Hostname"))
53
54 function hn.write(self, section, value)
55         Value.write(self, section, value)
56         luci.sys.hostname(value)
57 end
58
59
60 tz = s:option(ListValue, "zonename", translate("Timezone"))
61 tz:value("UTC")
62
63 for i, zone in ipairs(luci.sys.zoneinfo.TZ) do
64         tz:value(zone[1])
65 end
66
67 function tz.write(self, section, value)
68         local function lookup_zone(title)
69                 for _, zone in ipairs(luci.sys.zoneinfo.TZ) do
70                         if zone[1] == title then return zone[2] end
71                 end
72         end
73
74         AbstractValue.write(self, section, value)
75         self.map.uci:set("system", section, "timezone", lookup_zone(value) or "GMT0")
76 end
77
78 s:option(Value, "log_size", nil, "kiB").optional = true
79 s:option(Value, "log_ip").optional = true
80 s:option(Value, "conloglevel").optional = true
81 s:option(Value, "cronloglevel").optional = true
82 return m