I am currently upgrading a project from Django 1.3 to 1.5 and having 
trouble getting Django to recognise my compiled .mo translations.

My project is structured as follows:

/toplevelfolder
    /myproject
        /app1
        /app2
        /app3
        /templates
            /app1templates
            /app2templates
            /app3templates
    /locale

And I have the following in my settings.py file:

LOCALE_PATHS = (
'/path/to/toplevelfolder/locale'
)

When I run the 'makemessages -l de' command in /toplevelfolder, the 
django.po file is created correctly in 
the toplevelfolder/locale/de/LC_MESSAGES folder with no errors. I add a 
test string (in this case for a form label) such as: 

#: .\myproject\app1\usersignupform.py:56
msgid "I accept the terms and conditions."
msgstr "I accept the German terms and conditions"

Running 'compilemessages' creates the django.mo file with no errors, so I 
restart my test server as usual. 

However the test translation string above does not show on the form label - 
only the Django in-house translations (e.g. basic form validation strings) 
are being displayed (so the language is definitely set to German). 

Interestingly I tried using lower level /locale folders within the app1, 
app2 folders and the strings were successfully compiled and displayed. But 
obviously this only covers the strings in my app code - when I try doing 
the same within my separate template folder, the files are generated ok but 
just don't display on the page after compiling, like at the top level. In 
any case, there are a dozen apps in my project and many shared strings - it 
would obviously be ideal to get makemessages working at the top level and 
collate them into one django.po file for our translator.

I am using {% load i18n %} in all the relevant templates and the top level 
method above worked perfectly well with the same project in Django 1.3, so 
it is unlikely to be a typo in my template or app code. Should it matter 
where the template directory is, as long as it's within the scope of where 
I'm calling django-admin.py (i.e. /toplevelfolder)?

For completeness: I have installed gettext-tools-0.17 for Windows and added 
the /bin files to my PATH variable (i.e. running xgettext --version from 
the command line is fine).

I also tried refreshing my Middleware cache by commenting out 
'django.middleware.locale.LocaleMiddleware' in my settings and then putting 
it back in again (as I saw suggested elsewhere), with no luck.

I'd be grateful for any suggestions! Please ask if anything is unclear.



-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to