Mercurial > p > roundup > code
comparison roundup/cgi/TranslationService.py @ 3978:f11fe2a13234
Fix for translations (patch [SF#2032526])
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Thu, 07 Aug 2008 05:51:32 +0000 |
| parents | a16239e37598 |
| children | 0112e9e1d068 |
comparison
equal
deleted
inserted
replaced
| 3977:732a37da3a10 | 3978:f11fe2a13234 |
|---|---|
| 11 # method which is used by TAL engines: | 11 # method which is used by TAL engines: |
| 12 # | 12 # |
| 13 # translate(domain, msgid, mapping, context, target_language, default) | 13 # translate(domain, msgid, mapping, context, target_language, default) |
| 14 # | 14 # |
| 15 | 15 |
| 16 __version__ = "$Revision: 1.4 $"[11:-2] | 16 __version__ = "$Revision: 1.5 $"[11:-2] |
| 17 __date__ = "$Date: 2007-01-14 22:54:15 $"[7:-2] | 17 __date__ = "$Date: 2008-08-07 05:51:32 $"[7:-2] |
| 18 | 18 |
| 19 from roundup import i18n | 19 from roundup import i18n |
| 20 from roundup.cgi.PageTemplates import Expressions, PathIterator, TALES | 20 from roundup.cgi.PageTemplates import Expressions, PathIterator, TALES |
| 21 from roundup.cgi.TAL import TALInterpreter | 21 from roundup.cgi.TAL import TALInterpreter |
| 22 | 22 |
| 35 return _msg | 35 return _msg |
| 36 | 36 |
| 37 def gettext(self, msgid): | 37 def gettext(self, msgid): |
| 38 if not isinstance(msgid, unicode): | 38 if not isinstance(msgid, unicode): |
| 39 msgid = unicode(msgid, 'utf8') | 39 msgid = unicode(msgid, 'utf8') |
| 40 return self.ugettext(msgid).encode(self.OUTPUT_ENCODING) | 40 msgtrans=self.ugettext(msgid) |
| 41 if not isinstance(msgtrans,unicode): | |
| 42 msgtrans=unicode(msgtrans, 'utf8') | |
| 43 return msgtrans.encode(self.OUTPUT_ENCODING) | |
| 41 | 44 |
| 42 def ngettext(self, singular, plural, number): | 45 def ngettext(self, singular, plural, number): |
| 43 return self.ungettext(singular, plural, number).encode( | 46 if not isinstance(singular, unicode): |
| 44 self.OUTPUT_ENCODING) | 47 singular = unicode(singular, 'utf8') |
| 48 if not isinstance(plural, unicode): | |
| 49 plural = unicode(plural, 'utf8') | |
| 50 msgtrans=self.ungettext(singular, plural, number) | |
| 51 if not isinstance(msgtrans,unicode): | |
| 52 msgtrans=unicode(msgtrans, 'utf8') | |
| 53 return msgtrans.encode(self.OUTPUT_ENCODING) | |
| 45 | 54 |
| 46 class TranslationService(TranslationServiceMixin, i18n.RoundupTranslations): | 55 class TranslationService(TranslationServiceMixin, i18n.RoundupTranslations): |
| 47 pass | 56 pass |
| 48 | 57 |
| 49 class NullTranslationService(TranslationServiceMixin, | 58 class NullTranslationService(TranslationServiceMixin, |
