Skip to content
Permalink
Browse files

Add the possibility to use plural forms in cmk.gui.i18n

CMK-3283

Change-Id: I400652f7685cf3aa57a5afa274b68963ec696f0d
  • Loading branch information
7omb committed Nov 20, 2019
1 parent fdc5f9a commit 9aaf07203db15a079efe1577fec4da0245db99d0
Showing with 1,002 additions and 163 deletions.
  1. +12 −3 cmk/gui/i18n.py
  2. +8 −9 cmk/gui/plugins/sidebar/tactical_overview.py
  3. +982 −151 locale/de/LC_MESSAGES/multisite.po
@@ -57,9 +57,18 @@

def _(message):
# type: (str) -> Text
if not _translation:
return six.text_type(message)
return _translation.translation.ugettext(message)
if _translation:
return _translation.translation.ugettext(message)
return six.text_type(message)


def ungettext(singular, plural, n):
# type: (str, str, int) -> Text
if _translation:
return _translation.translation.ungettext(singular, plural, n)
if n == 1:
return six.text_type(singular)
return six.text_type(plural)


def get_current_language():
@@ -32,7 +32,7 @@
import cmk.gui.sites as sites
import cmk.gui.visuals as visuals
import cmk.gui.notifications as notifications
from cmk.gui.i18n import _
from cmk.gui.i18n import _, ungettext
from cmk.gui.globals import html
from cmk.gui.valuespec import Checkbox, ListOf, CascadingDropdown, Dictionary, TextUnicode
# Things imported here are used by pre legacy (pre 1.6) cron plugins)
@@ -439,14 +439,13 @@ def _show_site_status(self):
html.open_div(class_="spacertop")
html.open_div(class_="tacticalalert")

if len(sites_not_connected) == 1:
message_template = _("%d site is not connected")
tooltip_template = _("Associated hosts, services and events are not included "
"in the Tactical Overview. The disconnected site is %s.")
else:
message_template = _("%d sites are not connected")
tooltip_template = _("Associated hosts, services and events are not included "
"in the Tactical Overview. The disconnected sites are %s.")
message_template = ungettext("%d site is not connected", "%d sites are not connected",
len(sites_not_connected))
tooltip_template = ungettext(
"Associated hosts, services and events are not included "
"in the Tactical Overview. The disconnected site is %s.",
"Associated hosts, services and events are not included "
"in the Tactical Overview. The disconnected sites are %s.", len(sites_not_connected))
message = message_template % len(sites_not_connected)
tooltip = tooltip_template % ', '.join(sites_not_connected)

0 comments on commit 9aaf072

Please sign in to comment.
You can’t perform that action at this time.