Hi michael,

the language code should always be in the form xx or xx-xx and the
locale folders should be in the form xx or xx_XX. If you look through
the translation code you can see that what django does is given a
language xx-xx, it will check for xx_XX locale then xx. given xx (en
for example), it'll just look for locale xx, it won't search for more
specific dialects.

One flaw is that if django doesn't find the specified language in the
conf/locale folder of the django directory, it returns the default
language code in the settings, so you must have en_US in the django
locale directory if you want specific languages.




On Sep 26, 4:31 pm, Michael Scheper <dja...@michaelscheper.com> wrote:
> Hello again,
>
> I poked at this a bit more yesterday and traced this problem to core
> Python behaviour. The critical line of Django code is in the
> django.utils.translation.trans_real.translation(language) function, in
> _translation() under _fetch():
>
> t = gettext_module.translation('django', path, [loc], klass)
>
> When the value of loc doesn't include a territory (i.e. when it's
> 'en', and not something like 'en_AU' or 'en_US'), you really don't
> know which locale you're going to get. I've experimented with it and
> it seems to depend on what order the file system returns the locale
> directories. I've written in the Django i18n forums about this 
> (seehttp://www.nabble.com/Strange-gettext.find-results-td25621560.html)
> but I would call this a bug, either in Django or Python.
>
> As a result of this bug, users in Portugal might see the Brazilian
> content, and users in Spain might see Argentine content. Luckily,
> Django has separate locales for zh_CH and zh_TW, not just zh;
> otherwise, things could have gotten /really/ nasty!
>
> In any case, to solve my own problem, I'm working on a hack for
> LocaleMiddleware so it looks at request.META.HTTP_ACCEPT_LANGUAGE if
> request.LANGUAGE_CODE is 'en', and chooses the right locale,
> regardless of whether Django supports it yet.
>
> Cheers,
> MS.
>
> On Sep 21, 1:43 pm, Michael Scheper <dja...@michaelscheper.com> wrote:
>
> > G'day everyone,
>
> > What I want to do: To keep my American users happy, I want to localise
> > my site for en-us locale users. That way, they'll see all the dropped
> > 'u's and past participles and other things that don't exist in 'U.S.
> > English' (and that U.S. date format and all the other spelling
> > variations), but my site will still be correct for users in en-au, en-
> > nz, en-gb, en-za, en-ca, etc.
>
> > Unfortunately, it's not working. Even when I have my browser set to
> > U.S. English, the version of my site I see is in international
> > English.
>
> > Details: I'm using Python 2.5.2, and 'Django version 1.0-final-SVN-
> > unknown'.
>
> > What I've tried:
>
> > 1. I've made sure that i18n/l10n is working in general by translating
> > a few things to Dutch (nl) and setting my browser to that locale. It
> > works. (This article helped a 
> > lot:http://devdoodles.wordpress.com/2009/02/14/multi-language-support-in-...)
>
> > 2. According tohttp://docs.djangoproject.com/en/dev/topics/i18n/,
> > 'Django does not support localizing your application into a locale for
> > which Django itself has not been translated. [...] If you want to
> > support a locale for your application that is not already part of
> > Django, you'll need to make at least a minimal translation of the
> > Django core.' I've done this by copying the 'en' directory to 'en_US'
> > in /var/lib/python-support/python2.5/django/conf/locale and /usr/share/
> > python-support/python-django/django/conf/locale.* I also set LANGUAGES
> > to include only 'en' and 'en-us' (and 'nl') in settings.py. Since I
> > did these two things, putting {{ request.LANGUAGE_CODE }} in a
> > template yields 'en-us' when I set my browser to U.S. English, and
> > just 'en' when I use other English locales. (Before doing these
> > things, it returned 'en' regardless of which English locale I had my
> > browser set to.)
>
> > 3. I used django-admin makemessages -l en and django-admin
> > makemessages -l en-us to create language files, created the American
> > translations, and ran django-admin compilemessages. (I also tried
> > using en_US instead of en-us, since that's the standard used in the
> > two system directories I noted above. No difference.)
>
> > What's not working: The U.S. English text isn't showing up when I set
> > my browser to U.S. English, even though {{ request.LANGUAGE_CODE }}
> > does display 'en-us'.
>
> > * I have root on my own development server, so I was able to copy
> > these locale directories. My web host probably won't let me do this,
> > however, so I need to find another way that works.
>
> > Any advice?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to