Module: check_mk
Branch: master
Commit: e869f75d12c1e8d0b51c3fe992244a5771a4da96
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e869f75d12c1e8…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Fri May 13 17:30:36 2011 +0200
Prepared for i18n, still most _(...) are missing
---
web/htdocs/index.py | 14 ++++++----
web/htdocs/sidebar.py | 54 ++++++++++++++++++++++++++----------------
web/plugins/sidebar/wato.py | 6 +---
3 files changed, 43 insertions(+), 31 deletions(-)
diff --git a/web/htdocs/index.py b/web/htdocs/index.py
index 3398958..fba1c4d 100644
--- a/web/htdocs/index.py
+++ b/web/htdocs/index.py
@@ -25,7 +25,7 @@
# Boston, MA 02110-1301 USA.
import __builtin__
-__builtin__._ = lambda x: "HIRNI: " + x
+__builtin__._ = lambda x: x
__builtin__.current_language = None
from mod_python import apache, util
@@ -158,7 +158,7 @@ def handler(req, profiling = True):
config.debug = True
# Initialize the multiste i18n
- lang = config.default_language
+ lang = html.var("lang", config.default_language)
# Make current language globally known to all of our modules
__builtin__.current_language = lang
@@ -175,12 +175,14 @@ def handler(req, profiling = True):
except IOError, e:
raise MKUserError('lang', 'No translation file found for the
given language.')
else:
- __builtin__._ = lambda x: "PASST: " + x
+ __builtin__._ = lambda x: x
# All plugins might have to be reloaded due to a language change
- __all_our_fucking_moudles = [ views ]
- for module in __all_our_fucking_moudles:
- module.load_plugins()
+ for module in [ views, sidebar, wato, bi]:
+ try:
+ module.load_plugins()
+ except:
+ pass
# profiling can be enabled in multisite.mk
diff --git a/web/htdocs/sidebar.py b/web/htdocs/sidebar.py
index 465ee5c..45e1f16 100644
--- a/web/htdocs/sidebar.py
+++ b/web/htdocs/sidebar.py
@@ -27,30 +27,40 @@
import config, defaults, livestatus, htmllib, views, pprint, os, copy
from lib import *
-sidebar_snapins = {}
-
# Constants to be used in snapins
snapin_width = 230
-# Load all snapins
-snapins_dir = defaults.web_dir + "/plugins/sidebar"
-for fn in os.listdir(snapins_dir):
- if fn.endswith(".py"):
- execfile(snapins_dir + "/" + fn)
-if defaults.omd_root:
- local_snapins_dir = defaults.omd_root +
"/local/share/check_mk/web/plugins/sidebar"
- if os.path.exists(local_snapins_dir):
- for fn in os.listdir(local_snapins_dir):
- if fn.endswith(".py"):
- execfile(local_snapins_dir + "/" + fn)
-
-# Declare permissions: each snapin creates one permission
-config.declare_permission_section("sidesnap", "Sidebar snapins")
-for name, snapin in sidebar_snapins.items():
- config.declare_permission("sidesnap.%s" % name,
- snapin["title"],
- "",
- snapin["allowed"])
+
+# Datastructures and functions needed before plugins can be loaded
+loaded_with_language = False
+sidebar_snapins = {}
+
+def load_plugins():
+ if loaded_with_language == current_language:
+ return
+
+ global loaded_with_language
+ loaded_with_language = current_language
+
+ # Load all snapins
+ snapins_dir = defaults.web_dir + "/plugins/sidebar"
+ for fn in os.listdir(snapins_dir):
+ if fn.endswith(".py"):
+ execfile(snapins_dir + "/" + fn, globals())
+ if defaults.omd_root:
+ local_snapins_dir = defaults.omd_root +
"/local/share/check_mk/web/plugins/sidebar"
+ if os.path.exists(local_snapins_dir):
+ for fn in os.listdir(local_snapins_dir):
+ if fn.endswith(".py"):
+ execfile(local_snapins_dir + "/" + fn, globals())
+
+ # Declare permissions: each snapin creates one permission
+ config.declare_permission_section("sidesnap", "Sidebar snapins")
+ for name, snapin in sidebar_snapins.items():
+ config.declare_permission("sidesnap.%s" % name,
+ snapin["title"],
+ "",
+ snapin["allowed"])
# Helper functions to be used by snapins
def link(text, target):
@@ -330,3 +340,5 @@ def page_add_snapin(h):
html.write("</tr></table>\n")
html.footer()
+
+load_plugins()
diff --git a/web/plugins/sidebar/wato.py b/web/plugins/sidebar/wato.py
index ddc95f1..3f27056 100644
--- a/web/plugins/sidebar/wato.py
+++ b/web/plugins/sidebar/wato.py
@@ -24,8 +24,6 @@
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
-#!/usr/bin/python
-
import config, wato
def render_wato_files():
@@ -55,8 +53,8 @@ def ajax_wato_files(h):
sidebar_snapins["wato"] = {
- "title" : "Check_MK Web Administration Tool",
- "description" : "WATO - the Web Administration Tool of Check_MK -
manage hosts to be monitored without access to the command line",
+ "title" : _("Check_MK Web Administration Tool"),
+ "description" : _("WATO - the Web Administration Tool of Check_MK -
manage hosts to be monitored without access to the command line"),
"author" : "Mathias Kettner",
"render" : render_wato_files,
"allowed" : [ "admin", "user" ],