From f3a579f3da26f70239a2e3f2675d12c11ecc2ab4 Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Thu, 28 Oct 2010 15:18:06 +0200 Subject: [PATCH] Add the '' feature to nItems, and changed ChannelStats localization in order to use it as bug fixer --- plugins/ChannelStats/locale/fr.po | 4 ++-- src/utils/str.py | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/plugins/ChannelStats/locale/fr.po b/plugins/ChannelStats/locale/fr.po index df1bd11ad..9ed8d6201 100644 --- a/plugins/ChannelStats/locale/fr.po +++ b/plugins/ChannelStats/locale/fr.po @@ -45,7 +45,7 @@ msgstr "Je ne peux vous trouver dans ma base de données." #: plugin.py:272 msgid "%s has sent %n; a total of %n, %n, %n, and %n; %s of those messages %s. %s has joined %n, parted %n, quit %n, kicked someone %n, been kicked %n, changed the topic %n, and changed the mode %n." -msgstr "%s a envoyé %n ; un total de %n, %n, %n, et %n ; %s de ces messages %s. %s est arrivé %nfois, est parti %nfois, a quitté %nfois, a kické %nfois, a été kické %nfois, a changé le topic %nfois, et a changé les modes %nfois." +msgstr "%s a envoyé %n ; un total de %n, %n, %n, et %n ; %s de ces messages %s. %s est arrivé %n fois, est parti %n fois, a quitté %n fois, a kické %n fois, a été kické %n fois, a changé le topic %n fois, et a changé les modes %n fois." #: plugin.py:279 msgid "character" @@ -84,7 +84,7 @@ msgstr "étaient des ACTIONs" #: plugin.py:292 #: plugin.py:293 msgid "time" -msgstr " fois" +msgstr "" #: plugin.py:296 msgid "I have no stats for that %s in %s." diff --git a/src/utils/str.py b/src/utils/str.py index 93f541d2f..2c6fef345 100644 --- a/src/utils/str.py +++ b/src/utils/str.py @@ -294,17 +294,28 @@ def depluralize(s): def nItems(n, item, between=None): """Works like this: + >>> nItems(4, '') + '4' + >>> nItems(1, 'clock') '1 clock' >>> nItems(10, 'clock') '10 clocks' + >>> nItems(4, '', between='grandfather') + '4 grandfather' + >>> nItems(10, 'clock', between='grandfather') '10 grandfather clocks' """ assert isinstance(n, int) or isinstance(n, long), \ 'The order of the arguments to nItems changed again, sorry.' + if item == '': + if between is None: + return format('%s', n) + else: + return format('%s %s', n, item) if between is None: if n != 1: return format('%s %p', n, item)