Module: check_mk
Branch: master
Commit: dc975ebc3101c47c71885d6abc35a9e03641faf4
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=dc975ebc3101c4…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Jan 13 12:05:00 2012 +0100
WATO: Supporting localized tag titles
---
ChangeLog | 1 +
modules/localize.py | 9 ++++-----
web/htdocs/wato.py | 10 ++++++----
3 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 7825b85..7b9b9a2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -47,6 +47,7 @@
WATO:
* Removed IP-Address attribute from folders
+ * Supporting localized tag titles
* FIX: Fixed missing folders in "move to" dropdown fields
* FIX: Fixed "move to target folders" after CSV import
diff --git a/modules/localize.py b/modules/localize.py
index 85e1650..669b41f 100755
--- a/modules/localize.py
+++ b/modules/localize.py
@@ -163,15 +163,14 @@ def localize_init_po(lang):
def localize_sniff():
sys.stdout.write('Sniffing source code...\n')
+ paths = [ default_config_dir, web_dir ]
if local_web_dir and os.path.exists(local_web_dir):
- paths = web_dir + ' ' + local_web_dir
- else:
- paths = web_dir
+ paths.append(local_web_dir)
if verbose_system('xgettext --no-wrap --sort-output --force-po '
'-L Python --from-code=utf-8 --omit-header '
- '-o %s $(find %s -type f -name \*.py | xargs) >/dev/null' %
\
- (pot_file, paths)) != 0:
+ '-o %s $(find %s -type f -name \*.py -o -name \*.mk | xargs)
>/dev/null' % \
+ (pot_file, ' '.join(paths))) != 0:
sys.stderr.write('Failed!\n')
else:
header = '''#
+------------------------------------------------------------------+
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index a8f5d08..e062abb 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -3528,15 +3528,17 @@ class HostTagAttribute(Attribute):
Attribute.__init__(self, name, title, "", def_value)
def paint(self, value, hostname):
+ # Localize the titles. To make the strings available in the scanned localization
+ # files the _() function must also be placed in the configuration files
if len(self._taglist) == 1:
title = self._taglist[0][1]
if value:
- return "", title
+ return "", _(title)
else:
- return "", "%s %s" % (_("not"), title)
+ return "", "%s %s" % (_("not"), _(title))
for entry in self._taglist:
if value == entry[0]:
- return "", entry[1]
+ return "", _(entry[1])
return "", "" # Should never happen, at least one entry
should match
# But case could occur if tags definitions have been changed.
@@ -3556,7 +3558,7 @@ class HostTagAttribute(Attribute):
secondary_tags = e[2]
else:
secondary_tags = []
- choices.append(("|".join([ tagvalue ] + secondary_tags), e[1]))
+ choices.append(("|".join([ tagvalue ] + secondary_tags), _(e[1])))
if value != "" and value == tagvalue and secondary_tags:
value = value + "|" + "|".join(secondary_tags)