Add translation domain to cache key

Applies to
1.9.0, possibly other versions.
Purpose

Fix the need of dummy languages when instantiating a custom Translation.

Description

This patch adds the translation domain to the cache key of Translation. Currently you have to use dummy languages as workaround, otherwise your custom Translation object will overwrite Moin translation for that language completely. See also FeatureRequests/CheckTranslationBasedOnWikiPos and MoinMoinPatch/LoadAllTtranslationDomains.

Patch

   1 --- MoinMoin/i18n/__init__.py   2009-12-03 22:26:52 +0000
   2 +++ MoinMoin/i18n/__init__.py   2009-12-03 22:21:50 +0000
   3 @@ -222,7 +222,7 @@
   4      def loadLanguage(self, request, trans_dir="i18n"):
   5          request.clock.start('loadLanguage')
   6          # see comment about per-wiki scope above
   7 -        cache = caching.CacheEntry(request, arena='i18n', key=self.language, scope='wiki', use_pickle=True)
   8 +        cache = caching.CacheEntry(request, arena='i18n', key=('%s_%s' % (self.language, self.domain)), scope='wiki', use_pickle=True)
   9          langfilename = po_filename(request, self.language, self.domain, i18n_dir=trans_dir)
  10          needsupdate = cache.needsUpdate(langfilename)
  11          if not needsupdate:

Discussion

Plan


CategoryMoinMoinPatch

MoinMoin: MoinMoinPatch/AddTranslationDomainToCacheKey (last edited 2010-09-21 12:41:10 by ThomasWaldmann)