#13514: Only last package javascript catalog is loaded in case of missing default translation. -------------------------------------------+-------------------------------- Reporter: jtiai | Owner: nobody Status: new | Milestone: Component: Internationalization | Version: SVN Resolution: | Keywords: i18n javascript Stage: Unreviewed | Has_patch: 0 Needs_docs: 0 | Needs_tests: 0 Needs_better_patch: 0 | -------------------------------------------+-------------------------------- Changes (by jtiai):
* summary: Only last package catalog is loaded in case of missing default translation. => Only last package javascript catalog is loaded in case of missing default translation. Comment: Replying to [comment:1 arkx]: > Hello, I'm the one who provided the patch to fix #3594. What I'd like to see is a failing test case where you demonstrate the problem you are facing. You can use the tests introduced in #3594 as an example: http://code.djangoproject.com/browser/django/trunk/tests/regressiontests/views/tests/i18n.py. If this seems daunting you could also upload a test project that demonstrates the issue so that we could take a look. > > Did I undestand correctly that you wanted a Finnish translation to appear and it did not, displaying the default (as specified by LANGUAGE_CODE setting) English instead? Which language(s) are you translating to and which from? Are you having trouble with normal translations or !JavaScript translations? Please note that both of the tickets you refer to are related to !JavaScript translations only. I'm using javascript translation (should have been more precise there). I was having incorrect default (en-us) translation and I tried to have Finnish translations appear. I've multiple catalogs (around 20 apps with their own catalogs, djangojs - to be precise). When browser requested Finnish translations only last application package listed in packages list was loaded for some reason. Excerpt of urls.py: {{{ js_info_dict = { 'packages': ('app1', 'app2', 'app3', 'app4',), } urlpatterns = patterns('', (r'^jsi18n/$', 'django.views.i18n.javascript_catalog', js_info_dict), ) }}} Now in my case I don't have english translations, I had default language defined as "en-us", and browser requested "fi" translation. I got only translations from last application package in example case app4. > For reference, some background: because English is often the language people translate from (for example in Django's official translations), there is often no reason to create English translation files (just as you note, you don't have them at all). In this case, when English is the selected language the system will try to look for English translation and when it doesn't find one, it will return the untranslated string, which happens to be in English. > > The problem was that !JavaScript translation catalog would include the LANGUAGE_CODE translation if it's something other than English. This would cause trouble in the scenario where you are translating from English to Finnish for example, and your LANGUAGE_CODE is set to Finnish. The translation catalog is set to Finnish because of LANGUAGE_CODE, but then when the system subsequently tries to find translation for the currently selected language (English), it will not find anything, because English is the language being translated from. And hence Finnish translation is served to a user who requested English translation despite the fact that English version exists. > > I fixed this by setting a flag if English translation files could not be found during the catalog's construction and checking for that flag when at the last step the system is looking for active language's translation files and the language happens to be English. Then and only then is the catalog that had been set to LANGUAGE_CODE in previous step discarded. Note that '''nothing is discarded unless the English translation files are missing and English is the currently activated language choice''', which should not happen if a browser requests the Finnish translation. In my case it exactly happened like that. I had Finnish as a active language (verified from a debugger) and all else but last catalog defined in my packages list was discarded. Last loaded catalog was in correct language though (Finnish). > Take a look at the function javascript_catalog at http://code.djangoproject.com/browser/django/trunk/django/views/i18n.py if you want to see exactly how the !JavaScript translation catalog is constructed. I did and it seems that last change made in that file seems to override everything with last catalog ever loaded from packages list. (previously there was t.update, now there is just assignment) Maybe this only happens when you have multiple catalogs that should be joined together instead of just loading one catalog? At least in test case provided I didn't found anything related to multiple catalogs. System also works in my case if rolling back views.i18n two changesets (before changes made). -- Ticket URL: <http://code.djangoproject.com/ticket/13514#comment:3> Django <http://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-upda...@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.