Mercurial > p > roundup > code
comparison roundup/cgi/TranslationService.py @ 3775:beaf7ea86e5e
handle 8-bit untranslateable messages in tracker templates
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Sat, 02 Dec 2006 23:41:28 +0000 |
| parents | aa0316a1b2aa |
| children | a16239e37598 |
comparison
equal
deleted
inserted
replaced
| 3774:46e3d5d0901d | 3775:beaf7ea86e5e |
|---|---|
| 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.2 $"[11:-2] | 16 __version__ = "$Revision: 1.3 $"[11:-2] |
| 17 __date__ = "$Date: 2004-10-23 14:04:23 $"[7:-2] | 17 __date__ = "$Date: 2006-12-02 23:41:28 $"[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 |
| 43 | 43 |
| 44 class TranslationService(TranslationServiceMixin, i18n.RoundupTranslations): | 44 class TranslationService(TranslationServiceMixin, i18n.RoundupTranslations): |
| 45 pass | 45 pass |
| 46 | 46 |
| 47 class NullTranslationService(TranslationServiceMixin, | 47 class NullTranslationService(TranslationServiceMixin, |
| 48 i18n.RoundupNullTranslations | 48 i18n.RoundupNullTranslations): |
| 49 ): | 49 def ugettext(self, message): |
| 50 pass | 50 if self._fallback: |
| 51 return self._fallback.ugettext(message) | |
| 52 # Sometimes the untranslatable message is a UTF-8 encoded string | |
| 53 # (thanks to PageTemplate's internals). | |
| 54 if not isinstance(message, unicode): | |
| 55 return unicode(message, 'utf8') | |
| 56 return message | |
| 51 | 57 |
| 52 ### TAL patching | 58 ### TAL patching |
| 53 # | 59 # |
| 54 # Template Attribute Language (TAL) uses only global translation service, | 60 # Template Attribute Language (TAL) uses only global translation service, |
| 55 # which is not thread-safe. We will use context variable 'i18n' | 61 # which is not thread-safe. We will use context variable 'i18n' |
