Module: check_mk
Branch: master
Commit: abb20a16e94602dfe6711ed83dafca75da3a50ae
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=abb20a16e94602…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Aug 29 14:36:29 2018 +0200
6511 FIX Global Settings: Custom localizations fixed possible exception when language
alias contains non-ascii characters
An exception could occur when using a localized GUI and a language which uses non-ascii
characters
in it's alias file (local/share/check_mk/locale/[lang]/alias).
Change-Id: Ic6254e85dbac48f7f1c2a62710196efc3a87c78c
---
.werks/6511 | 12 ++++++++++++
cmk/gui/i18n.py | 8 ++++----
2 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/.werks/6511 b/.werks/6511
new file mode 100644
index 0000000..4cc4cc6
--- /dev/null
+++ b/.werks/6511
@@ -0,0 +1,12 @@
+Title: Global Settings: Custom localizations fixed possible exception when language alias
contains non-ascii characters
+Level: 1
+Component: wato
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.6.0i1
+Date: 1535531405
+
+An exception could occur when using a localized GUI and a language which uses non-ascii
characters
+in it's alias file (local/share/check_mk/locale/[lang]/alias).
diff --git a/cmk/gui/i18n.py b/cmk/gui/i18n.py
index b0318d8..c5adef9 100644
--- a/cmk/gui/i18n.py
+++ b/cmk/gui/i18n.py
@@ -54,7 +54,7 @@ Translation = NamedTuple("Translation", [
_translation = None # type: Optional[Translation]
def _(message):
- # type: (str) -> unicode
+ # type: (str) -> Text
if not _translation:
return unicode(message)
else:
@@ -75,18 +75,18 @@ def _get_language_dirs():
def get_language_alias(lang):
- # type: (str) -> unicode
+ # type: (str) -> Text
alias = lang
for lang_dir in _get_language_dirs():
try:
alias = open('%s/%s/alias' % (lang_dir, lang),
'r').read().strip()
except (OSError, IOError):
pass
- return alias
+ return alias.decode("utf-8")
def get_languages():
- # type: () -> List[Tuple[str, unicode]]
+ # type: () -> List[Tuple[str, Text]]
# Add the hard coded english language to the language list
# It must be choosable even if the administrator changed the default
# language to a custom value