Skip to content

Commit

Permalink
minor update on locale code
Browse files Browse the repository at this point in the history
  • Loading branch information
fiorix committed Feb 24, 2011
1 parent 21991d2 commit e4eb964
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ Following is a step-by-step guide to implement localization in any Cyclone appli
you'll need an extra script to pre-process the files.

Here's what you can use as ``fix.py``::

#!/usr/bin/env python
# coding: utf-8
# fix.py
Expand All @@ -219,7 +219,7 @@ Following is a step-by-step guide to implement localization in any Cyclone appli
Then, call ``xgettext`` to generate the PO translatable file::

cat foobar.tac template/index.html | python fix.py | \
xgettext --language=Python --keyword=_:1,2 -d foobar
xgettext --language=Python --from-code=utf-8 --keyword=_:1,2 -d foobar

This will create a file named ``foobar.po``, which needs to be
translated, then compiled into an MO file::
Expand Down
11 changes: 4 additions & 7 deletions cyclone/locale.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def __init__(self, code, translator):
_ = self.translate
self._months = [
_("January"), _("February"), _("March"), _("April"),
_("May"), _("June"), _("July"), _("August"),
_("May"), _("June"), _("July"), _("August"),
_("September"), _("October"), _("November"), _("December")]
self._weekdays = [
_("Monday"), _("Tuesday"), _("Wednesday"), _("Thursday"),
Expand All @@ -182,13 +182,10 @@ def translate(self, message, plural_message=None, count=None):
plural_message when count != 1, and we return the singular form
for the given message when count == 1.
"""
if plural_message is not None:
if count is not None:
return self.translator.ngettext(message, plural_message, count)
else:
return self.translator.gettext(message)
else:
if plural_message is None or count is None:
return self.translator.gettext(message)
else:
return self.translator.ngettext(message, plural_message, count)

def format_date(self, date, gmt_offset=0, relative=True, shorter=False,
full_format=False):
Expand Down

0 comments on commit e4eb964

Please sign in to comment.