Internationalization in Django 1.4 doesn't seem to work

168 views
Skip to first unread message

Houmie

unread,
Jun 1, 2012, 1:58:15 PM6/1/12
to Django users
Hey everyone,

I would really appreciate it if somebody could help me with this.
Working on this since this morning and am totally stuck..

I have posted it with proper formatting on stack overflow.

http://stackoverflow.com/questions/10854330/internationalization-in-django-doesnt-get-activated

Thank you very much,
Houman

Iván Raskovsky

unread,
Jun 1, 2012, 3:49:19 PM6/1/12
to django...@googlegroups.com
Besides changing the language per request as you've been indicated in
SO you might want to look at lazy translations:
https://docs.djangoproject.com/en/dev/topics/i18n/translation/#lazy-translation

Regards,
Iván
> --
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To post to this group, send email to django...@googlegroups.com.
> To unsubscribe from this group, send email to django-users...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
>

Houmie

unread,
Jun 1, 2012, 5:12:59 PM6/1/12
to Django users
Hi Ivan,

Thank you for your help.

I have already lazy translation implemented for the forms like this:

from django.utils.translation import ugettext_lazy as _

class FriendInviteForm(forms.Form):
name = forms.CharField(label=_("Friend's Name"))
email = forms.EmailField(label= _("Friend's Email"))


Surely at least the form should then change the words according to the
drop down settings. But still no luck. Its really hard to get this
working. Do you have any simple working example for me by any chance?
So I could compare line by line? :)


On Jun 1, 8:49 pm, Iván Raskovsky <raskov...@gmail.com> wrote:
> Besides changing the language per request as you've been indicated in
> SO you might want to look at lazy translations:https://docs.djangoproject.com/en/dev/topics/i18n/translation/#lazy-t...
>
> Regards,
>     Iván
>
>
>
>
>
>
>
> On Fri, Jun 1, 2012 at 2:58 PM, Houmie <hou...@gmail.com> wrote:
> > Hey everyone,
>
> > I would really appreciate it if somebody could help me with this.
> > Working on this since this morning and am totally stuck..
>
> > I have posted it with proper formatting on stack overflow.
>
> >http://stackoverflow.com/questions/10854330/internationalization-in-d...

Houmie

unread,
Jun 1, 2012, 7:21:53 PM6/1/12
to django...@googlegroups.com
Guys,


I have created a new simple test project to demonstrate the problem.  

It is a very simple project and you can switch between German & English at main page.  You see the selected Language code actually changes, which is a good sign but the translation simply doesn't happen. I wonder if this is a bug that needs reported. Your cooperation is highly appreciated.

Please download from here:

Please let me know if you can reproduce it.

Many Thanks,
Houman

kenneth gonsalves

unread,
Jun 2, 2012, 2:36:40 AM6/2/12
to django...@googlegroups.com
On Fri, 2012-06-01 at 10:58 -0700, Houmie wrote:
> I would really appreciate it if somebody could help me with this.
> Working on this since this morning and am totally stuck..
>
>

could you try with revision 17860 and see if it works. I have the same
problem, and am stuck with 17860 - unfortunately I have been unable to
replicate the problem with a simple example.
--
regards
Kenneth Gonsalves


Houmie

unread,
Jun 2, 2012, 5:58:43 AM6/2/12
to django...@googlegroups.com
Hi Kenneth,

The good news is the problem is solved. A friendly chap in stackoverflow actually bothered to look into it.

The problem is as simple as the translation files couldn't be found.  For some odd reason the important information about how Django locates them is at the very last section of the documentation. It is really easy to miss.

All you have to do is to move the locale directory with the translation files into your Application directory. Thats it !!!

If you need to recreate the translation files you need top use the terminal, browse to the Application directory and run your command 'django-admin.py makemessages -l de' from there.  

You can't do this from Aptana Studio 3.0, since it requires you to run any Django command from the root rather than from application directory.  Hence you need to do it in the terminal.

Just download my test app and try what I just said here, as I intend to remove the test project within the next few days.

Regards,
Houman

kenneth gonsalves

unread,
Jun 2, 2012, 6:44:52 AM6/2/12
to django...@googlegroups.com
On Sat, 2012-06-02 at 02:58 -0700, Houmie wrote:
> The good news is the problem is solved. A friendly chap in
> stackoverflow
> actually bothered to look into it.
>
> The problem is as simple as the translation files couldn't be found.
> For
> some odd reason the important information about how Django locates
> them is
> at the very last section of the documentation. It is really easy to
> miss.
>
> All you have to do is to move the locale directory with the
> translation
> files into your Application directory. Thats it !!!

it may have solved your problem. But actually nowadays django looks into
settings.LOCALE_PATHS - could you check whether the svn revision number
you are using is less than 17860 or greater.
--
regards
Kenneth Gonsalves

Reply all
Reply to author
Forward
0 new messages