we now use our own function with ngettext() which rocks

This commit is contained in:
Nikos Kouremenos 2005-08-24 11:54:47 +00:00
parent cb705493a4
commit d74f43144a
2 changed files with 16 additions and 13 deletions

View File

@ -52,3 +52,16 @@ def Q_(s):
if s[0] == '?': if s[0] == '?':
s = s[s.find(':')+1:] # remove ?abc: part s = s[s.find(':')+1:] # remove ?abc: part
return s return s
def ngettext(s_sing, s_plural, n, replace_sing = None, replace_plural = None):
'''use as:
i18n.ngettext('leave room %s', 'leave rooms %s', len(rooms), 'a', 'a, b, c')
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:
text = text % replace_sing
else:
text = text % replace_plural
return text

View File

@ -137,22 +137,12 @@ class GroupchatWindow(chat.Chat):
names.append(gajim.get_nick_from_jid(room_jid)) names.append(gajim.get_nick_from_jid(room_jid))
if len(names): # if one or more rooms connected if len(names): # if one or more rooms connected
#FIXME: wrap this function to OUR function called ngettext() pritext = i18n.ngettext(
#this hopefully will fool xgettext and we'll have a signature we like
#eg. ngettext('do %s' % 'one', 'do %s' % 'two', len(jobs))
#so we do not have to do this madness that follows allover we use
#ngettext()
pritext = i18n._translation.ngettext(
'Are you sure you want to leave room "%s"?', 'Are you sure you want to leave room "%s"?',
'Are you sure you want to leave rooms "%s"?', 'Are you sure you want to leave rooms "%s"?',
len(names)) len(names), names[0], ', '.join(names))
if len(names) == 1:
pritext = pritext % names[0]
else:
joined_names = ', '.join(names)
pritext = pritext % joined_names
sectext = i18n._translation.ngettext( sectext = i18n.ngettext(
'If you close this window, you will be disconnected from this room.', 'If you close this window, you will be disconnected from this room.',
'If you close this window, you will be disconnected from these rooms.', 'If you close this window, you will be disconnected from these rooms.',
len(names)) len(names))