Add the '<empty>' feature to nItems, and changed ChannelStats localization in order to use it as bug fixer

This commit is contained in:
Valentin Lorentz 2010-10-28 15:18:06 +02:00
parent 8864a7fc71
commit f3a579f3da
2 changed files with 13 additions and 2 deletions

View File

@ -84,7 +84,7 @@ msgstr "étaient des ACTIONs"
#: plugin.py:292 #: plugin.py:292
#: plugin.py:293 #: plugin.py:293
msgid "time" msgid "time"
msgstr " fois" msgstr "<empty>"
#: plugin.py:296 #: plugin.py:296
msgid "I have no stats for that %s in %s." msgid "I have no stats for that %s in %s."

View File

@ -294,17 +294,28 @@ def depluralize(s):
def nItems(n, item, between=None): def nItems(n, item, between=None):
"""Works like this: """Works like this:
>>> nItems(4, '<empty>')
'4'
>>> nItems(1, 'clock') >>> nItems(1, 'clock')
'1 clock' '1 clock'
>>> nItems(10, 'clock') >>> nItems(10, 'clock')
'10 clocks' '10 clocks'
>>> nItems(4, '<empty>', between='grandfather')
'4 grandfather'
>>> nItems(10, 'clock', between='grandfather') >>> nItems(10, 'clock', between='grandfather')
'10 grandfather clocks' '10 grandfather clocks'
""" """
assert isinstance(n, int) or isinstance(n, long), \ assert isinstance(n, int) or isinstance(n, long), \
'The order of the arguments to nItems changed again, sorry.' 'The order of the arguments to nItems changed again, sorry.'
if item == '<empty>':
if between is None:
return format('%s', n)
else:
return format('%s %s', n, item)
if between is None: if between is None:
if n != 1: if n != 1:
return format('%s %p', n, item) return format('%s %p', n, item)