0
1

Hi there,

I think this should be pretty simple/straight forward, but it's not. I want to support many languages for my project. I followed a few tutorials and read the doc about it. I think I'm doing everything ok, but I'm still not able to get my text translated. I have two languages, "fr" and "en". "fr" in the default one and "en" requires a translation file.

My project filters contains these folders - templates - locale - vielfaltig (project name) - apps

In my template index.html:

{% load i18n %}
{% trans "Texte en français" %}

Generated my locale file at the root of my project

django-admin.py makemessages -l en

Translated text in generated django.po:

#: templates/base/index.html:2
msgid "Texte en français"
msgstr "Text in english"

In my settings.py:

LANGUAGE_CODE = 'en'
USE_I18N = True
LOCALE_PATHS = (
    '/Users/myuser/django-project/site/locale/' (which is good)
)
MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
#'django.middleware.locale.LocaleMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
)

Running:

django-admin.py compilemessages

Go to my site root on localhost:8000 and getting:

Texte en français

When I should get the translated text since I set the language code to "en" in the settings. I checked and the language code for the thread is really "en" but my template doesn't get translated.. qhand am I doing wrong ?

Thanks,

Info on my environment: - Using django-stack 1.5 by Bitnami - Python 2.7.3 - Django 1.5 - Mac osx 10.6 - Testing done with Chrome

asked 02 May '13, 14:36

Guli's gravatar image

Guli
53
accept rate: 0%

edited 02 May '13, 15:29


Got it working. Don't know how... I restarted my shell and tried a few times things I already tried. Maybe a cache problem somehow somewhere. I hate when this happens, but I'm glad I can continue to work now!

link

answered 02 May '13, 16:22

Guli's gravatar image

Guli
53
accept rate: 0%

Hello,

I am new to django, I am working multilingual website...I built sample website based on your steps/guidelines. I was not able to see the text in english even after restarting the shell. could you please provide me your code snippets. I am not sure where I am going wrong.

your help is appreciated

link

answered 03 May '13, 02:11

Kishore's gravatar image

Kishore
1
accept rate: 0%

it should be like all languages that you provide in your settings.py

LANGUAGES = (                                                                   
    ('tr', gettext('Turkish')),
    ('en', gettext('English')),
    ('pt-BR', gettext('Brazil')),
)

and based on your browser envr language settings django site will be shown in that langauge

link

answered 03 May '13, 03:01

DjangoForum's gravatar image

DjangoForum ♦♦
636
accept rate: 8%

Hello,

I have set language code still I am unable to see text in English, could you please provide me detail steps you followed or sample website code which will help me in setting up multilingual site.

your help is much appreciated.

link

answered 03 May '13, 03:42

Kishore's gravatar image

Kishore
1
accept rate: 0%

Hi Kishore,

I'd be glad to help, unfortunately I don't know what went wrong on my side as my code finally worked. Maybe if you post some code I can help you better. I started with this turorial which helped me a lot. After, I followed Django trunk documentation on Translations.

Know that the only thing I added to my setting.py is the LOCALE_PATHS. I tried to add LANGUAGES setting once but it didn't change anything to my problem and it didn't do any bad not to have it once I, so I removed it for now. Notice also that I put under comment the line for "LocaleMiddleware" in MIDDLE_WARE_CLASSES because if it is enabled, Django will ignore the LANGUAGE_CODE setting and will take the language set in browser all the time so you won't be able to switch easily between languages for testing.

Hope this helps,

link

answered 03 May '13, 10:05

Guli's gravatar image

Guli
53
accept rate: 0%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×1

Asked: 02 May '13, 14:36

Seen: 1,409 times

Last updated: 03 May '13, 10:05

Related questions

powered by OSQA