Ticket #9089 (closed Bug: wontfix)
Errors when negotiating languages when locales directory is used in Products namespaced packages
|Reported by:||erral||Owned by:|
|Keywords:||PTS||Cc:||dukebody, libargutxi@…, dimo|
(sigh, after 15 minutes writing the bug, I've lost everything because when I hit preview I hadn't writtn the summary :'()
Steps to reproduce:
- Create a Plone 3.2.2 buildout
- Add Products.LinguaPlone and Products.RedirectionTool as eggs and zcml lines
- Execute the buildout
- Add a Plone site
- Go to Site Setup -> Additional Products, and install LinguaPlone.
- Add Basque and Spanish as supported languages, and Basque as default language.
- Go to the Plone Site and change language to have the interface in Basque (Euskara).
- Add a Folder (Elementua gehitu -> Karpeta), and inside it some News Items (Albistea). Set Folder's view to be folder_summary_view (Bistarate Unitatea -> Mosaiko ikuspena).
- You will see dates correctly localized (something like admin-(e)k eginda — 2009/04/02 16:17 ).
- Go to Site Setup (Atariaren Konfigurazioa) -> Additional Products (Produktu gehigarriak) and install RedirectionTool.
- Go back to the folder created beforehand. You will see a new tab added by RedirectionTool (Alias) and the dates localized in English (something like admin-(e)k eginda — Apr 02, 2009 04:17 PM ).
Tracking the call stack behind the scenes, I've found that Products.PlacelessTranslationService patches zope.i18n's language negotiator to memoize it (using Products.PlacelessTranslationService.memoize.memoize_second). The first time the negotiator is called is when Plone tries to translate "Alias" into basque. RedirectionTool doesn't have basque translation, so the negotiator decides to return the translation in English, and returns 'en'. So far so good. PTS memoizes this result, and when toLocalizedTime tries to get the translated date (in the plonelocales domain), PTS returns the memoized result and thus the date is shown in English although a basque translation exists for the datetime format used there.
As a temporary solution, I have patched PTS not to memoize the negotiator, and everything works OK in the Plone site.
Products.RedirectionTool uses a locales folder layout to provide its translations, so I have commented the i18n:registerTranslations directive in its configure.zcml file, and moved the PO files to a i18n folder layout. With this configuration, the translations for RedirectionTool are taken correctly and the dates are also shown correctly.
It seems that Plone (or Zope behin the scenes) doesn't handle in the same way the language negotiation thing when using locales folder layout for PO files in Products namespaced packages.
You can contact me for more info, I've spent more than 3 days tracking down this bug.