Skip to content

Commit

Permalink
Correct plural form translation for table caption
Browse files Browse the repository at this point in the history
See f51fa04#commitcomment-9330335

Thanks to @jerzyk for reporting
  • Loading branch information
mbertheau committed Jan 21, 2015
1 parent 1ce9f31 commit 5d90b43
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
5 changes: 2 additions & 3 deletions src/oscar/apps/dashboard/catalogue/tables.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy as _, ugettext_noop
from django.utils.translation import ugettext_lazy as _, ungettext_lazy

from django_tables2 import Column, LinkColumn, TemplateColumn, A

Expand Down Expand Up @@ -64,8 +64,7 @@ class CategoryTable(DashboardTable):
orderable=False)

icon = "sitemap"
caption_singular = ugettext_noop("{count} Category")
caption_plural = ugettext_noop("{count} Categories")
caption = ungettext_lazy("%s Category", "%s Categories")

class Meta(DashboardTable.Meta):
model = Category
Expand Down
15 changes: 7 additions & 8 deletions src/oscar/apps/dashboard/tables.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
from django.utils.translation import ungettext, ugettext_noop
from django.utils.translation import ungettext_lazy

from django_tables2 import Table


class DashboardTable(Table):
_caption = None
caption_singular = ugettext_noop('{count} Row')
caption_plural = ugettext_noop('{count} Rows')
caption = ungettext_lazy('{count} Row', '{count} Rows')

@property
def caption(self):
if self._caption:
# Allow overriding the caption with an arbitrary string that we cannot
# interpolate the number of rows in
try:
return self._caption % self.paginator.count
except TypeError:
return self._caption

return (ungettext(self.caption_singular, self.caption_plural,
self.paginator.count)
.format(count=self.paginator.count))

@caption.setter
def caption(self, caption):
self._caption = caption
Expand Down

0 comments on commit 5d90b43

Please sign in to comment.