diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2008-05-28 22:34:26 +0000 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2008-05-28 22:34:26 +0000 |
commit | b06638df6e776fc380687b06924a77b03055c00e (patch) | |
tree | 9474d20d6ea68d2bf3911e60b865c306462eac97 /applications/luci-statistics/luasrc/statistics/rrdtool.lua | |
parent | aafa5b786d4692fe65bdc2ac8552976d0a3a3a51 (diff) |
* luci/statistics: implement initial i18n support, added first translations, removed hardcoded strings from models
Diffstat (limited to 'applications/luci-statistics/luasrc/statistics/rrdtool.lua')
-rw-r--r-- | applications/luci-statistics/luasrc/statistics/rrdtool.lua | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/applications/luci-statistics/luasrc/statistics/rrdtool.lua b/applications/luci-statistics/luasrc/statistics/rrdtool.lua index 17ac48a5a7..1fe57a2257 100644 --- a/applications/luci-statistics/luasrc/statistics/rrdtool.lua +++ b/applications/luci-statistics/luasrc/statistics/rrdtool.lua @@ -3,7 +3,7 @@ module("luci.statistics.rrdtool", package.seeall) require("luci.statistics.datatree") require("luci.statistics.rrdtool.colors") require("luci.statistics.rrdtool.definitions") -require("luci.i18n") +require("luci.statistics.i18n") require("luci.util") require("luci.fs") @@ -17,7 +17,7 @@ function Graph.__init__( self, timespan, opts ) self.colors = luci.statistics.rrdtool.colors.Instance() self.defs = luci.statistics.rrdtool.definitions.Instance() self.tree = luci.statistics.datatree.Instance() - self.i18n = luci.i18n + self.i18n = luci.statistics.i18n.Instance( self ) -- options opts.rrasingle = opts.rrasingle or true -- XXX: fixme (uci) @@ -34,12 +34,9 @@ function Graph.__init__( self, timespan, opts ) -- store options self.opts = opts - - -- load language file - self.i18n.loadc("statistics") end -function Graph.mktitle( self, plugin, plugin_instance, dtype, dtype_instance ) +function Graph._mkpath( self, plugin, plugin_instance, dtype, dtype_instance ) local t = self.opts.host .. "/" .. plugin if type(plugin_instance) == "string" and plugin_instance:len() > 0 then t = t .. "-" .. plugin_instance @@ -52,11 +49,17 @@ function Graph.mktitle( self, plugin, plugin_instance, dtype, dtype_instance ) end function Graph.mkrrdpath( self, ... ) - return string.format( "/tmp/%s.rrd", self:mktitle( ... ) ) + return string.format( "/tmp/%s.rrd", self:_mkpath( ... ) ) end function Graph.mkpngpath( self, ... ) - return string.format( "/tmp/rrdimg/%s.png", self:mktitle( ... ) ) + return string.format( "/tmp/rrdimg/%s.png", self:_mkpath( ... ) ) +end + +function Graph.mktitle( self, plugin, plugin_instance, dtype, dtype_instance ) + + -- try various strings to retrieve a diagram title from the langfile + return "XXX" end function Graph._forcelol( self, list ) @@ -366,7 +369,6 @@ function Graph._generic( self, opts, plugin, plugin_instance, dtype, index ) -- store values _ti( _sources, { - title = dsname, -- XXX: fixme i18n (dopts.title || i18n || dname) rrd = dopts.rrd or self:mkrrdpath( plugin, plugin_instance, dtype, dinst ), color = dopts.color or self.colors:to_string( self.colors:random() ), flip = dopts.flip or false, @@ -381,6 +383,10 @@ function Graph._generic( self, opts, plugin, plugin_instance, dtype, index ) } ) + -- generate datasource title + _sources[#_sources].title = self.i18n:ds( _sources[#_sources] ) + + -- find longest name ... if _sources[#_sources].title:len() > _longest_name then _longest_name = _sources[#_sources].title:len() @@ -415,9 +421,9 @@ function Graph._generic( self, opts, plugin, plugin_instance, dtype, index ) -- store title and vlabel -- XXX: i18n _ti( _args, "-t" ) - _ti( _args, opts.title ) + _ti( _args, opts.title or self.i18n:title( plugin, plugin_instance, _sources[1].type, instance ) ) _ti( _args, "-v" ) - _ti( _args, opts.vlabel ) + _ti( _args, opts.vlabel or self.i18n:label( plugin, plugin_instance, _sources[1].type, instance ) ) -- store additional rrd options if opts.rrdopts then |