Code

Opened 8 years ago

Closed 8 years ago

Last modified 7 years ago

#1233 closed defect (invalid)

i18n does not work for win32

Reported by: Jaroslaw Zabiello Owned by: adrian
Component: Core (Other) Version:
Severity: critical Keywords: i18n win32
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

I try to test http://www.djangoproject.com/documentation/i18n/ but it does not work for win32. If I add. I created all correct .po & .mo files . Django always displays the content of msgid instead of msgstr. I tried (according to mentioned manual) the following code to settings.py file:

LANGUAGES = (
  ('de', _('German')),
  ('en', _('English')),
)

But... after that I have problems with starting the server:

D:\i18n-test\myproject>python manage.py runserver
Traceback (most recent call last):
  File "manage.py", line 4, in ?
    import settings # Assumed to be in the same directory.
  File "D:\i18n-test\myproject\settings.py", line 72, in ?
    LANGUAGES = (
NameError: name '_' is not defined

Hmmn, if I have changed it to the following:

from django.utils.translation import gettext as _
LANGUAGES = (
  ('de', _('German')),
  ('en', _('English')),
)

...another exception raises:

D:\i18n-test\myproject>manage.py server
Traceback (most recent call last):
  File "D:\i18n-test\myproject\manage.py", line 4, in ?
    import settings # Assumed to be in the same directory.
  File "D:\i18n-test\myproject\settings.py", line 72, in ?
    LANGUAGES = (
  File "c:\opt\python24\lib\site-packages\Django-0.91-py2.4.egg\django\utils\translation.py", line 242, in gettext
    from django.conf import settings
  File "c:\opt\python24\lib\site-packages\Django-0.91-py2.4.egg\django\conf\settings.py", line 34, in ?
    raise EnvironmentError, "Could not import %s '%s' (is it on sys.path?): %s" % (ENVIRONMENT_VARIABLE, me.SETTINGS_MODULE, e)
EnvironmentError: Could not import DJANGO_SETTINGS_MODULE 'myproject.settings' (is it on sys.path?): cannot import name settings

Attachments (0)

Change History (2)

comment:1 Changed 8 years ago by marcink@…

  • Resolution set to invalid
  • Status changed from new to closed

I18n does work. The problem you see is caused by an import loop:
you should not import any django modules in your settings file
since many of them depend on your project settings in some way.

The LANGUAGES tuple is created in django's global_settings.py file
and that that seems to be the only place you can add more languages.
For 'de' and any languages from this list
you do not need to change a thing, just set LANGUAGE_CODE to 'de' or
add LocaleMiddleware to your MIDDLEWARE_CLASSES and use it to set the
preferred language.

comment:2 Changed 7 years ago by adrian

  • milestone Version 0.91 deleted

Milestone Version 0.91 deleted

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.