Skip to content
This repository has been archived by the owner on Oct 29, 2019. It is now read-only.

Commit

Permalink
Merge pull request #326 from aldryn/issue/fix-lazy-translations-for-s…
Browse files Browse the repository at this point in the history
…tr-method

Fix issue with __str__ mentod and lazy translations.
  • Loading branch information
Kirill Kniazev committed Nov 20, 2015
2 parents de5a6dc + 7fde13a commit 6eca2a4
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions aldryn_newsblog/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

from django.utils.encoding import python_2_unicode_compatible
from django.utils.timezone import now
from django.utils.translation import ugettext_lazy as _, override
from django.utils.translation import ugettext_lazy as _, override, ugettext

from aldryn_apphooks_config.fields import AppHookConfigField
from aldryn_categories.fields import CategoryManyToManyField
Expand Down Expand Up @@ -263,7 +263,7 @@ class NewsBlogArchivePlugin(PluginEditModeMixin, NewsBlogCMSPlugin):
# NOTE: the PluginEditModeMixin is eventually used in the cmsplugin, not
# here in the model.
def __str__(self):
return _('%s archive') % (self.app_config.get_app_title(), )
return ugettext('%s archive') % (self.app_config.get_app_title(), )


class NewsBlogArticleSearchPlugin(NewsBlogCMSPlugin):
Expand All @@ -274,7 +274,7 @@ class NewsBlogArticleSearchPlugin(NewsBlogCMSPlugin):
)

def __str__(self):
return _('%s archive') % (self.app_config.get_app_title(), )
return ugettext('%s archive') % (self.app_config.get_app_title(), )


@python_2_unicode_compatible
Expand Down Expand Up @@ -315,13 +315,13 @@ def get_authors(self, request):
return sorted(authors, key=lambda x: x.article_count, reverse=True)

def __str__(self):
return _('%s authors') % (self.app_config.get_app_title(), )
return ugettext('%s authors') % (self.app_config.get_app_title(), )


@python_2_unicode_compatible
class NewsBlogCategoriesPlugin(PluginEditModeMixin, NewsBlogCMSPlugin):
def __str__(self):
return _('%s categories') % (self.app_config.get_app_title(), )
return ugettext('%s categories') % (self.app_config.get_app_title(), )

def get_categories(self, request):
"""
Expand Down Expand Up @@ -385,9 +385,9 @@ def __str__(self):
return 'featured articles'
prefix = self.app_config.get_app_title()
if self.article_count == 1:
title = _('featured article')
title = ugettext('featured article')
else:
title = _('featured articles: %(count)s') % {
title = ugettext('featured articles: %(count)s') % {
'count': self.article_count,
}
return '{0} {1}'.format(prefix, title)
Expand All @@ -414,7 +414,7 @@ def get_articles(self, request):
return queryset[:self.latest_articles]

def __str__(self):
return _('%s latest articles: %s') % (
return ugettext('%s latest articles: %s') % (
self.app_config.get_app_title(), self.latest_articles, )


Expand All @@ -435,7 +435,7 @@ def get_articles(self, article, request):
return qs

def __str__(self):
return _('Related articles')
return ugettext('Related articles')


@python_2_unicode_compatible
Expand Down Expand Up @@ -477,7 +477,7 @@ def get_tags(self, request):
return sorted(tags, key=lambda x: x.article_count, reverse=True)

def __str__(self):
return _('%s tags') % (self.app_config.get_app_title(), )
return ugettext('%s tags') % (self.app_config.get_app_title(), )


@receiver(post_save, dispatch_uid='article_update_search_data')
Expand Down

0 comments on commit 6eca2a4

Please sign in to comment.