Problems creating a new locale

2009-09-21 Thread Michael Scheper

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-a-django-project/)

2. According to http://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
-~--~~~~--~~--~--~---



en vs. en_US (was 'Problems creating a new locale')

2009-09-26 Thread Michael Scheper

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 (see
http://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  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
-~--~~~~--~~--~--~---



django shell not respecting vi editing-mode in .inputrc

2014-12-04 Thread Michael Scheper

G'day peeps,

I somehow missed the Django shell (python manage.py shell) until 
somebody quite new to Django showed it to me. It's pretty and seems to 
have some nice tricks, but the vi editing commands I expect aren't 
working when I run it in my own environment.


The normal Python interpreter uses readline 
<https://docs.python.org/2/library/readline.html>, and thus respects 
'set editing-mode vi' (and other settings) in my ~/.inputrc file. Can I 
get the Django shell to do the same, or do I just need to type 
django.setup() in the normal interpreter?


Thanks,
Michael Scheper.

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/54811A8D.4070202%40michaelscheper.com.
For more options, visit https://groups.google.com/d/optout.