carlxaeron / django-rosetta

Automatically exported from code.google.com/p/django-rosetta
MIT License
0 stars 0 forks source link

Cannot detect project locale directory if the settings is a directory (as opposed to single file alongside manage.py) #109

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
In our project we have our .po/.mo files in the locale directory of our project 
root. Our settings module is not a file ('settings.py') in the project root, 
but is a directory called 'settings'.

With this set up, rosetta does not find the .po/.mo files in the locale 
directory.

The faulty code which tried to deduce the project directory is this: (from 
poutil.py)

    parts = settings.SETTINGS_MODULE.split('.')
    project = __import__(parts[0], {}, {}, [])
    abs_project_path = os.path.normpath(os.path.abspath(os.path.dirname(project.__file__)))
    if project_apps:
    paths.append(os.path.abspath(os.path.join(os.path.dirname(project.__file__), 'locale')))

The rest of django is able to support this 'settings as a directory' paradyme, 
(e.g.: http://code.djangoproject.com/ticket/9751 ).

Original issue reported on code.google.com by ebelu...@gmail.com on 13 Apr 2011 at 9:26

GoogleCodeExporter commented 8 years ago
Here's a patch, inspired by http://code.djangoproject.com/changeset/10751 which 
should make rosetta work for 'settings as directory' and 'settings as file'.

Original comment by ebelu...@gmail.com on 13 Apr 2011 at 9:55

Attachments:

GoogleCodeExporter commented 8 years ago
Hi. 

I see the purpose of this ticket, and the patch seems perfectly valid (in that 
it doesn't break any test cases) but I'm having a hard time trying to reproduce 
the issue, maybe you could help?

So all I did was create a settings directory, and renamed my settings.py file 
to settings/__init__.py but this doesn't really change Rosetta behavior. What 
am I missing?

Thanks.

Original comment by mbonetti on 13 Apr 2011 at 11:21

GoogleCodeExporter commented 8 years ago
When you have a "settings" directory and a "locale" directory, go to rosetta 
and try to look for just the 'project' files, it will tell you you have no 
translations. if you apply this patch and it will detect the project 
translations.

Original comment by ebelu...@gmail.com on 13 Apr 2011 at 12:14

GoogleCodeExporter commented 8 years ago
That's exactly what I have, still I see the translations, hence my comment.
Are you running Django 1.3?

Original comment by mbonetti on 13 Apr 2011 at 12:55

GoogleCodeExporter commented 8 years ago
I am running django 1.1 and python 2.5. I can see all the project translations 
when I click on 'All', but when I click on 'Project', there were no 
translations, just a message saying i had no translations set up.

Original comment by ebelu...@gmail.com on 13 Apr 2011 at 2:10

GoogleCodeExporter commented 8 years ago
Thanks, this is likely related to the Django version. I'll get hold of a copy 
of 1.1 and run the tests again.

Original comment by mbonetti on 13 Apr 2011 at 2:24

GoogleCodeExporter commented 8 years ago
My Django installation serves 2 different domains, they share more then 80% of 
the codebase,  settings, and translations. For this reason i have the following 
layout:

* A settings package, this contains the global settings, and URL-conf
* A sub-package for each subdomain that imports and expends the global 
settings, and URL-conf.

So i'm starting my dev-server with ./manage.py runserver 
settings=settings.site_a

With this configuration rosetta could not find any "Project Translations", but 
it shows me the 3rd Party Translations. The Patch above fixes this issue for me.

I'm using Django 1.3 and Rosetta 0.6.0

Original comment by xeniac...@gmail.com on 5 Jun 2011 at 1:25

GoogleCodeExporter commented 8 years ago
The patch works for me too (settings directory).
Django 1.3 and Rosetta 0.6.2

Original comment by martin.b...@gmail.com on 6 Aug 2011 at 11:53