diff --git a/src/common/i18n.py b/src/common/i18n.py index dc2e17c8c..7bf09275e 100644 --- a/src/common/i18n.py +++ b/src/common/i18n.py @@ -60,8 +60,8 @@ def ngettext(s_sing, s_plural, n, replace_sing = None, replace_plural = None): in other words this is a hack to ngettext() to support %s %d etc.. ''' text = _translation.ngettext(s_sing, s_plural, n) - if n == 1: + if n == 1 and replace_sing is not None: text = text % replace_sing - else: + elif n > 1 and replace_plural is not None: text = text % replace_plural return text diff --git a/src/systraywin32.py b/src/systraywin32.py index b0f438fff..c07f019c2 100644 --- a/src/systraywin32.py +++ b/src/systraywin32.py @@ -263,11 +263,11 @@ class SystrayWin32(systray.Systray): if jid != 'tabbed': nb += jids[jid].nb_unread[jid] - #FIXME: prepare me for transltaion (ngeetext() and all) for 0.9 - if nb > 1: - text = 'Gajim - %s unread messages' % nb - else: - text = 'Gajim - 1 unread message' + text = i18n.ngettext( + 'Gajim - one unread message', + 'Gajim - %d unread messages', + nb, None, nb) + self.systray_winapi.notify_icon.set_tooltip(text) def remove_jid(self, jid, account): diff --git a/src/tooltips.py b/src/tooltips.py index 8aa5d3a60..c66b5ed77 100644 --- a/src/tooltips.py +++ b/src/tooltips.py @@ -207,10 +207,12 @@ class NotificationAreaTooltip(BaseTooltip, StatusTable): accounts.append({'name': account, 'status_line': single_line, 'show': status, 'message': message}) unread_messages_no = self.plugin.roster.nb_unread - if unread_messages_no > 1: - text = _('Gajim - %s unread messages') % unread_messages_no - elif unread_messages_no == 1: - text = _('Gajim - 1 unread message') + + if unread_messages_no > 0: + text = i18n.ngettext( + 'Gajim - one unread message', + 'Gajim - %d unread messages', + unread_messages_no, None, unread_messages_no) elif len(accounts) > 1: text = _('Gajim') self.current_row = 1