Re: problems with i18n
django r5881 but on windows, i think now the problem is with gettext on windows because when i tried it on fedora it worked thank u all for help On 8/13/07, koenb <[EMAIL PROTECTED]> wrote: > > > Hi Heba, > > I just tried your project with django trunk r5881: I put everything in > a folder, modified the settings to use sqlite3, created a db, did > manage.py syncdb. > Then I started the development server, looked at 127.0.0.1:8000 and it > seems to work just fine. > > What django version are you using ? > > Koen > > > > > -- Yours Heba --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: problems with i18n
Hi Heba, I just tried your project with django trunk r5881: I put everything in a folder, modified the settings to use sqlite3, created a db, did manage.py syncdb. Then I started the development server, looked at 127.0.0.1:8000 and it seems to work just fine. What django version are you using ? Koen --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: problems with i18n
in the django.views.i18n.py file, i found that it gets the 'language' from request.Get.get('language'), but when i tried to access this variable from index.html, i found it 'None', does that explains why there is no translation ?? help me please, i'm stuck thanksk in advance On Aug 13, 9:18 am, "Heba Farouk" <[EMAIL PROTECTED]> wrote: > i'm attaching the whole project > > thanks in advance > > On 8/13/07, Heba <[EMAIL PROTECTED]> wrote: > > > > > > > here is my code again, i did all that (make-message.py -l ar, compile- > > messages.py), it seems that i have a problem with django somewhere > > > index.html > > > {%load i18n%} > > > > {{output}} > > > > {% trans 'Hello World'%} > > > > > > > > {% for lang in LANGUAGES %} > > {{ > > lang.1 }} > > {% endfor %} > > > > > > {% trans 'Welcome back' %} > > > > > > > > > views.py > > > from django.shortcuts import render_to_response > > from django.template import RequestContext > > from django.utils.translation import ugettext as _ > > > def my_view(request): > > output = _("Hello World Home") > > # All the extra information (such as {{ user }} or > > {{ LANGUAGES }}) is > > # passed to templates by a RequestContext that processes a number > > of > > # context processors defined in TEMPLATE_CONTEXT_PROCESSORS in > > settings. > > return render_to_response('index.html', > > {'output': output,'path':request.path}, > > > context_instance=RequestContext(request) ) > > > urls.py > > > from django.conf.urls.defaults import * > > > urlpatterns = patterns('', > > (r'^i18n/', include('django.conf.urls.i18n')), > > (r'^$', 'i18nPack.views.my_view'), > > > ) > > > settings.py > > > # Django settings for i18nTry project. > > > DEBUG = True > > TEMPLATE_DEBUG = DEBUG > > > ADMINS = ( > > # ('Your Name', '[EMAIL PROTECTED]'), > > ) > > > MANAGERS = ADMINS > > > DATABASE_ENGINE = 'postgresql_psycopg2' # > > 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. > > DATABASE_NAME = 'test' # Or path to database file if using > > sqlite3. > > DATABASE_USER = 'postgres' # Not used with sqlite3. > > DATABASE_PASSWORD = 'AdminPassword2007' # Not used with > > sqlite3. > > DATABASE_HOST = '' # Set to empty string for localhost. > > Not used with sqlite3. > > DATABASE_PORT = '' # Set to empty string for default. Not > > used with sqlite3. > > > # Local time zone for this installation. Choices can be found here: > > # > >http://www.postgresql.org/docs/8.1/static/datetime-keywords.html#DATE... > > # although not all variations may be possible on all operating > > systems. > > # If running in a Windows environment this must be set to the same as > > your > > # system time zone. > > TIME_ZONE = 'America/New_York' > > > # Language code for this installation. All choices can be found here: > > #http://www.w3.org/TR/REC-html40/struct/dirlang.html#langcodes > > #LANGUAGE_CODE = 'ar' > > > SITE_ID = 1 > > > # If you set this to False, Django will make some optimizations so as > > not > > # to load the internationalization machinery. > > USE_I18N = True > > > LANGUAGES = ( > > ('en', 'English'), > > ('ar', 'Arabic'), > > ) > > > # Absolute path to the directory that holds media. > > # Example: "/home/media/media.lawrence.com/" > > MEDIA_ROOT = '' > > > # URL that handles the media served from MEDIA_ROOT. Make sure to use > > a > > # trailing slash if there is a path component (optional in other > > cases). > > # Examples: "http://media.lawrence.com;, "http://example.com/media/; > > MEDIA_URL = '' > > > # URL prefix for admin media -- CSS, JavaScript and images. Make sure > > to use a > > # trailing slash. > > # Examples: "http://foo.com/media/;, "/media/". > > ADMIN_MEDIA_PREFIX = '/media/' > > > # Make this unique, and don't share it with anybody. > > SECRET_KEY = 'qx6%+dl+6k-g(fu*qr-37rmn0%oa2)sn)(v7=1i8e8%)[EMAIL PROTECTED]' > > > # List of callables that know how to import templates from various > > sources. > > TEMPLATE_LOADERS = ( > > 'django.template.loaders.filesystem.load_template_source', > > 'django.template.loaders.app_directories.load_template_source', > > # 'django.template.loaders.eggs.load_template_source', > > ) > > > MIDDLEWARE_CLASSES = ( > > 'django.contrib.sessions.middleware.SessionMiddleware', > > 'django.middleware.locale.LocaleMiddleware', > > 'django.middleware.common.CommonMiddleware', > > 'django.contrib.auth.middleware.AuthenticationMiddleware', > > 'django.middleware.doc.XViewMiddleware', > > ) > > > ROOT_URLCONF = 'i18nTry.urls' > > >
Re: problems with i18n
i'm attaching the whole project thanks in advance On 8/13/07, Heba <[EMAIL PROTECTED]> wrote: > > > here is my code again, i did all that (make-message.py -l ar, compile- > messages.py), it seems that i have a problem with django somewhere > > index.html > > {%load i18n%} > > {{output}} > > {% trans 'Hello World'%} > > > > {% for lang in LANGUAGES %} > {{ > lang.1 }} > {% endfor %} > > > {% trans 'Welcome back' %} > > > > > views.py > > from django.shortcuts import render_to_response > from django.template import RequestContext > from django.utils.translation import ugettext as _ > > def my_view(request): > output = _("Hello World Home") > # All the extra information (such as {{ user }} or > {{ LANGUAGES }}) is > # passed to templates by a RequestContext that processes a number > of > # context processors defined in TEMPLATE_CONTEXT_PROCESSORS in > settings. > return render_to_response('index.html', > {'output': output,'path':request.path}, > > context_instance=RequestContext(request) ) > > > urls.py > > from django.conf.urls.defaults import * > > urlpatterns = patterns('', > (r'^i18n/', include('django.conf.urls.i18n')), > (r'^$', 'i18nPack.views.my_view'), > > ) > > > settings.py > > > # Django settings for i18nTry project. > > DEBUG = True > TEMPLATE_DEBUG = DEBUG > > ADMINS = ( > # ('Your Name', '[EMAIL PROTECTED]'), > ) > > MANAGERS = ADMINS > > DATABASE_ENGINE = 'postgresql_psycopg2' # > 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. > DATABASE_NAME = 'test' # Or path to database file if using > sqlite3. > DATABASE_USER = 'postgres' # Not used with sqlite3. > DATABASE_PASSWORD = 'AdminPassword2007' # Not used with > sqlite3. > DATABASE_HOST = '' # Set to empty string for localhost. > Not used with sqlite3. > DATABASE_PORT = '' # Set to empty string for default. Not > used with sqlite3. > > # Local time zone for this installation. Choices can be found here: > # > http://www.postgresql.org/docs/8.1/static/datetime-keywords.html#DATETIME-TIMEZONE-SET-TABLE > # although not all variations may be possible on all operating > systems. > # If running in a Windows environment this must be set to the same as > your > # system time zone. > TIME_ZONE = 'America/New_York' > > # Language code for this installation. All choices can be found here: > # http://www.w3.org/TR/REC-html40/struct/dirlang.html#langcodes > #LANGUAGE_CODE = 'ar' > > > SITE_ID = 1 > > # If you set this to False, Django will make some optimizations so as > not > # to load the internationalization machinery. > USE_I18N = True > > > > LANGUAGES = ( > ('en', 'English'), > ('ar', 'Arabic'), > ) > > # Absolute path to the directory that holds media. > # Example: "/home/media/media.lawrence.com/" > MEDIA_ROOT = '' > > # URL that handles the media served from MEDIA_ROOT. Make sure to use > a > # trailing slash if there is a path component (optional in other > cases). > # Examples: "http://media.lawrence.com;, "http://example.com/media/; > MEDIA_URL = '' > > # URL prefix for admin media -- CSS, JavaScript and images. Make sure > to use a > # trailing slash. > # Examples: "http://foo.com/media/;, "/media/". > ADMIN_MEDIA_PREFIX = '/media/' > > # Make this unique, and don't share it with anybody. > SECRET_KEY = 'qx6%+dl+6k-g(fu*qr-37rmn0%oa2)sn)(v7=1i8e8%)[EMAIL PROTECTED]' > > # List of callables that know how to import templates from various > sources. > TEMPLATE_LOADERS = ( > 'django.template.loaders.filesystem.load_template_source', > 'django.template.loaders.app_directories.load_template_source', > # 'django.template.loaders.eggs.load_template_source', > ) > > MIDDLEWARE_CLASSES = ( > 'django.contrib.sessions.middleware.SessionMiddleware', > 'django.middleware.locale.LocaleMiddleware', > 'django.middleware.common.CommonMiddleware', > 'django.contrib.auth.middleware.AuthenticationMiddleware', > 'django.middleware.doc.XViewMiddleware', > ) > > ROOT_URLCONF = 'i18nTry.urls' > > TEMPLATE_DIRS = ( > # Put strings here, like "/home/html/django_templates" or "C:/www/ > django/templates". > # Always use forward slashes, even on Windows. > # Don't forget to use absolute paths, not relative paths. >'D:/eclipse-workspace/i18nTry/i18nPack/templates', > ) > > INSTALLED_APPS = ( > 'django.contrib.auth', > 'django.contrib.contenttypes', > 'django.contrib.sessions', > 'django.contrib.sites', > 'i18nPack', > ) > > > django.py > > > # SOME DESCRIPTIVE TITLE. > # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT
Re: problems with i18n
here is my code again, i did all that (make-message.py -l ar, compile- messages.py), it seems that i have a problem with django somewhere index.html {%load i18n%} {{output}} {% trans 'Hello World'%} {% for lang in LANGUAGES %} {{ lang.1 }} {% endfor %} {% trans 'Welcome back' %} views.py from django.shortcuts import render_to_response from django.template import RequestContext from django.utils.translation import ugettext as _ def my_view(request): output = _("Hello World Home") # All the extra information (such as {{ user }} or {{ LANGUAGES }}) is # passed to templates by a RequestContext that processes a number of # context processors defined in TEMPLATE_CONTEXT_PROCESSORS in settings. return render_to_response('index.html', {'output': output,'path':request.path}, context_instance=RequestContext(request) ) urls.py from django.conf.urls.defaults import * urlpatterns = patterns('', (r'^i18n/', include('django.conf.urls.i18n')), (r'^$', 'i18nPack.views.my_view'), ) settings.py # Django settings for i18nTry project. DEBUG = True TEMPLATE_DEBUG = DEBUG ADMINS = ( # ('Your Name', '[EMAIL PROTECTED]'), ) MANAGERS = ADMINS DATABASE_ENGINE = 'postgresql_psycopg2' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. DATABASE_NAME = 'test' # Or path to database file if using sqlite3. DATABASE_USER = 'postgres' # Not used with sqlite3. DATABASE_PASSWORD = 'AdminPassword2007' # Not used with sqlite3. DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3. DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3. # Local time zone for this installation. Choices can be found here: # http://www.postgresql.org/docs/8.1/static/datetime-keywords.html#DATETIME-TIMEZONE-SET-TABLE # although not all variations may be possible on all operating systems. # If running in a Windows environment this must be set to the same as your # system time zone. TIME_ZONE = 'America/New_York' # Language code for this installation. All choices can be found here: # http://www.w3.org/TR/REC-html40/struct/dirlang.html#langcodes #LANGUAGE_CODE = 'ar' SITE_ID = 1 # If you set this to False, Django will make some optimizations so as not # to load the internationalization machinery. USE_I18N = True LANGUAGES = ( ('en', 'English'), ('ar', 'Arabic'), ) # Absolute path to the directory that holds media. # Example: "/home/media/media.lawrence.com/" MEDIA_ROOT = '' # URL that handles the media served from MEDIA_ROOT. Make sure to use a # trailing slash if there is a path component (optional in other cases). # Examples: "http://media.lawrence.com;, "http://example.com/media/; MEDIA_URL = '' # URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a # trailing slash. # Examples: "http://foo.com/media/;, "/media/". ADMIN_MEDIA_PREFIX = '/media/' # Make this unique, and don't share it with anybody. SECRET_KEY = 'qx6%+dl+6k-g(fu*qr-37rmn0%oa2)sn)(v7=1i8e8%)[EMAIL PROTECTED]' # List of callables that know how to import templates from various sources. TEMPLATE_LOADERS = ( 'django.template.loaders.filesystem.load_template_source', 'django.template.loaders.app_directories.load_template_source', # 'django.template.loaders.eggs.load_template_source', ) MIDDLEWARE_CLASSES = ( 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.locale.LocaleMiddleware', 'django.middleware.common.CommonMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.middleware.doc.XViewMiddleware', ) ROOT_URLCONF = 'i18nTry.urls' TEMPLATE_DIRS = ( # Put strings here, like "/home/html/django_templates" or "C:/www/ django/templates". # Always use forward slashes, even on Windows. # Don't forget to use absolute paths, not relative paths. 'D:/eclipse-workspace/i18nTry/i18nPack/templates', ) INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'i18nPack', ) django.py # SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. # FIRST AUTHOR <[EMAIL PROTECTED]>, YEAR. # #, fuzzy msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2007-08-12 17:33+0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <[EMAIL PROTECTED]>\n" "Language-Team: LANGUAGE <[EMAIL
Re: problems with i18n
On Sun, Aug 12, 2007 at 07:07:54AM -0700, Heba wrote: > i add already to django.po and then i compiled > but when i re-run "make-messages.py" after adding trans to the > template, i got my parts in the django.py file hashed like that: > > #~ msgid "Hello World" > #~ msgstr "مرحبا العالم" > > #~ msgid "Welcome" > #~ msgstr "أهلا" > > #~ msgid "Hello World Home" > #~ msgstr "مرحبا العالم - الصفحة الرئيسية" Hmm, this is ok for messages that are not used any more. Are there any other msgids? Any entries marked for translation (with _() in .py files and with {% trans %} in templates) should still be there after re-running make-messages.py, like this: msgid "Hello World" msgstr "مرحبا العالم" msgid "Welcome" msgstr "أهلا" msgid "Hello World Home" msgstr "مرحبا العالم - الصفحة الرئيسية" If the .po file contains all messages you want, run compile-messages.py. With kind regards, -- Baurzhan Ismagulov http://www.kz-easy.com/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: problems with i18n
i add already to django.po and then i compiled but when i re-run "make-messages.py" after adding trans to the template, i got my parts in the django.py file hashed like that: #~ msgid "Hello World" #~ msgstr "مرحبا العالم" #~ msgid "Welcome" #~ msgstr "أهلا" #~ msgid "Hello World Home" #~ msgstr "مرحبا العالم - الصفحة الرئيسية" thanks On Aug 12, 4:42 pm, Baurzhan Ismagulov <[EMAIL PROTECTED]> wrote: > On Sun, Aug 12, 2007 at 06:13:59AM -0700, Heba wrote: > > i did so, sorry may be the template i sent was not updated but i > > really did > > Your code works for me with RequestContext and po changes. Have you > actually put any translations into your locale/ar/LC_MESSAGES/django.po > before running compile-messages.py? Note that you have to re-run > "make-messages.py -a" after modifying any strings (such as adding a > trans block to your template). And you do look at the browser window > title for {{ output }}, don't you? > > With kind regards, > -- > Baurzhan Ismagulovhttp://www.kz-easy.com/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: problems with i18n
On Sun, Aug 12, 2007 at 06:13:59AM -0700, Heba wrote: > i did so, sorry may be the template i sent was not updated but i > really did Your code works for me with RequestContext and po changes. Have you actually put any translations into your locale/ar/LC_MESSAGES/django.po before running compile-messages.py? Note that you have to re-run "make-messages.py -a" after modifying any strings (such as adding a trans block to your template). And you do look at the browser window title for {{ output }}, don't you? With kind regards, -- Baurzhan Ismagulov http://www.kz-easy.com/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: problems with i18n
i did so, sorry may be the template i sent was not updated but i really did {%load i18n%} {{output}} {%trans "Hello World!"%} {% for lang in LANGUAGES %} {{ lang.1 }} {% endfor %} i couldnot get any translation On Aug 12, 4:09 pm, Baurzhan Ismagulov <[EMAIL PROTECTED]> wrote: > On Sun, Aug 12, 2007 at 05:55:31AM -0700, Heba wrote: > > ok, thanks again for this help, i can now compile my .po files, but i > > still have nothing after pressing the go button > > Well, the template you've posted doesn't include any text. You probably > want to include "{{ output }}" somewhere in . FWIW, you can also > use "{% trans "some text" %}" directly in the template, so that you > don't have to include messages in views.py. > > With kind regards, > -- > Baurzhan Ismagulovhttp://www.kz-easy.com/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: problems with i18n
On Sun, Aug 12, 2007 at 05:55:31AM -0700, Heba wrote: > ok, thanks again for this help, i can now compile my .po files, but i > still have nothing after pressing the go button Well, the template you've posted doesn't include any text. You probably want to include "{{ output }}" somewhere in . FWIW, you can also use "{% trans "some text" %}" directly in the template, so that you don't have to include messages in views.py. With kind regards, -- Baurzhan Ismagulov http://www.kz-easy.com/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: problems with i18n
ok, thanks again for this help, i can now compile my .po files, but i still have nothing after pressing the go button On Aug 12, 2:42 pm, Baurzhan Ismagulov <[EMAIL PROTECTED]> wrote: > On Sun, Aug 12, 2007 at 04:21:50AM -0700, Heba wrote: > > it gives me this error when i use compile-messages.py > > > processing file django.po in D:\eclipse-workspace\i18nTry\i18nPack > > \locale\ar\LC_ > > MESSAGES 'msgfmt' is not recognized as an internal or external > > command, > > operable program or batch file. > > You should have a program named "msgfmt" in your %PATH% for this to > work. You can install it usinghttp://cygwin.com/setup.exe, or as > described athttp://code.djangoproject.net/ticket/1157#comment:5(but I > haven't tried this). > > With kind regards, > -- > Baurzhan Ismagulovhttp://www.kz-easy.com/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: problems with i18n
On Sun, Aug 12, 2007 at 04:21:50AM -0700, Heba wrote: > it gives me this error when i use compile-messages.py > > processing file django.po in D:\eclipse-workspace\i18nTry\i18nPack > \locale\ar\LC_ > MESSAGES 'msgfmt' is not recognized as an internal or external > command, > operable program or batch file. You should have a program named "msgfmt" in your %PATH% for this to work. You can install it using http://cygwin.com/setup.exe, or as described at http://code.djangoproject.net/ticket/1157#comment:5 (but I haven't tried this). With kind regards, -- Baurzhan Ismagulov http://www.kz-easy.com/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: problems with i18n
it gives me this error when i use compile-messages.py processing file django.po in D:\eclipse-workspace\i18nTry\i18nPack \locale\ar\LC_ MESSAGES 'msgfmt' is not recognized as an internal or external command, operable program or batch file. Thanks in advance On Aug 12, 2:05 pm, Baurzhan Ismagulov <[EMAIL PROTECTED]> wrote: > On Sun, Aug 12, 2007 at 03:00:23AM -0700, Heba wrote: > > thanks, i can see the options of the select now, but when i press the > > Go button, the page is not translated > > Have you created locale/ar/LC_MESSAGES/django.mo as described in the > "How to create language files" section > ofhttp://www.djangoproject.com/documentation/i18n/? > > With kind regards, > -- > Baurzhan Ismagulovhttp://www.kz-easy.com/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: problems with i18n
On Sun, Aug 12, 2007 at 03:00:23AM -0700, Heba wrote: > thanks, i can see the options of the select now, but when i press the > Go button, the page is not translated Have you created locale/ar/LC_MESSAGES/django.mo as described in the "How to create language files" section of http://www.djangoproject.com/documentation/i18n/ ? With kind regards, -- Baurzhan Ismagulov http://www.kz-easy.com/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: problems with i18n
On Sun, Aug 12, 2007 at 11:11:37AM +0300, Heba Farouk wrote: > {%load i18n%} ... > {% for lang in LANGUAGES %} > {{ lang.1 }}> ... > I didn't see any options in the select when I run it ... > LANGUAGES = ( > ('ar', 'Arabic'), > ('en', 'English'), > ) ... > def my_view(request): > output = _("Hello World Home") > return render_to_response('index.html', {'output': output}) http://groups.google.com/group/django-users/msg/e34ddaadd0223293 Hope this helps, -- Baurzhan Ismagulov http://www.kz-easy.com/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
problems with i18n
Hello, I'm a newbie to python and django and I hope that u can help me I'm just trying to use i18n, but I got no translation at all Here is the code I wrote in the template index.html {%load i18n%} {% for lang in LANGUAGES %} {{ lang.1}} {% endfor %} I didn't see any options in the select when I run it Here is my settings.py file # Django settings for i18nTry project. DEBUG = True TEMPLATE_DEBUG = DEBUG ADMINS = ( # ('Your Name', '[EMAIL PROTECTED]'), ) MANAGERS = ADMINS DATABASE_ENGINE = *'postgresql_psycopg2'* # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. DATABASE_NAME = *'test'* # Or path to database file if using sqlite3. DATABASE_USER = *'postgres'* # Not used with sqlite3. DATABASE_PASSWORD = *''* # Not used with sqlite3. DATABASE_HOST = *''* # Set to empty string for localhost. Not used with sqlite3. DATABASE_PORT = *''* # Set to empty string for default. Not used with sqlite3. # Local time zone for this installation. Choices can be found here: # http://www.postgresql.org/docs/8.1/static/datetime-keywords.html#DATETIME-TIMEZONE-SET-TABLE # although not all variations may be possible on all operating systems. # If running in a Windows environment this must be set to the same as your # system time zone. TIME_ZONE = *'America/New_York'* # Language code for this installation. All choices can be found here: # http://www.w3.org/TR/REC-html40/struct/dirlang.html#langcodes LANGUAGE_CODE = *'ar'* SITE_ID = 1 # If you set this to False, Django will make some optimizations so as not # to load the internationalization machinery. USE_I18N = True LANGUAGES = ( (*'ar'*, *'Arabic'*), (*'en'*, *'English'*), ) # Absolute path to the directory that holds media. # Example: "/home/media/media.lawrence.com/" MEDIA_ROOT = *''* # URL that handles the media served from MEDIA_ROOT. Make sure to use a # trailing slash if there is a path component (optional in other cases). # Examples: "http://media.lawrence.com;, "http://example.com/media/; MEDIA_URL = *''* # URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a # trailing slash. # Examples: "http://foo.com/media/;, "/media/". ADMIN_MEDIA_PREFIX = *'/media/'* # Make this unique, and don't share it with anybody. SECRET_KEY = *'qx6%+dl+6k-g(fu*qr-37rmn0%oa2)sn)(v7=1i8e8%)[EMAIL PROTECTED]'* # List of callables that know how to import templates from various sources. TEMPLATE_LOADERS = ( *'django.template.loaders.filesystem.load_template_source'*, *'django.template.loaders.app_directories.load_template_source'*, # 'django.template.loaders.eggs.load_template_source', ) MIDDLEWARE_CLASSES = ( *'django.contrib.sessions.middleware.SessionMiddleware'*, *'django.middleware.locale.LocaleMiddleware'*, *'django.middleware.common.CommonMiddleware'*, *'django.contrib.auth.middleware.AuthenticationMiddleware'*, *'django.middleware.doc.XViewMiddleware'*, ) ROOT_URLCONF = *'i18nTry.urls'* TEMPLATE_DIRS = ( # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". # Always use forward slashes, even on Windows. # Don't forget to use absolute paths, not relative paths. *'D:/eclipse-workspace/i18nTry/i18n/templates'*, ) INSTALLED_APPS = ( *'django.contrib.auth'*, *'django.contrib.contenttypes'*, *'django.contrib.sessions'*, *'django.contrib.sites'*, *'i18n'*, ) And urls.py file from django.conf.urls.defaults import * urlpatterns = patterns(*''*, (r*'^i18n/'*, include(*'django.conf.urls.i18n'*)), (r*'^$'*, *'i18n.views.my_view'*), ) And views.py from django.shortcuts import render_to_response from django.utils.translation import ugettext as _ def *my_view*(request): output = _(*"Hello World Home"*) return render_to_response(*'index.html'*, {*'output'*: output}) thanks in advance -- Yours Heba --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Problems with i18n of field labels (newforms)
On 7/25/07, Nathan Ostgard <[EMAIL PROTECTED]> wrote: > What import are you aliasing as _? Nothing, because I believed it is globally available and no import is neccessary. It was probably true before swap to UNICODE. And on the top of it, I got somehow deranged and assumed that _() function is always lazy -> this was a reason I was absolutely blind to this problem. Thanks for your help, Peter --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Problems with i18n of field labels (newforms)
What import are you aliasing as _? You have three options for gettext calls: - ugettext, which translates as soon as it's *called*. - ugettext_lazy, which does not translate until the attribute is *accessed*. - ugettext_noop, which translates at the last possible moment, such as when the value is *rendered*. For your case, you probably want to be using ugettext_lazy: from django.utils.translation import ugettext_lazy as _ If that doesn't fix the problem, try using ugettext_noop. On Jul 25, 2:54 am, "Peter Melvyn" <[EMAIL PROTECTED]> wrote: > Hi all, > > I'm trying to embed login form into each page. I implemented it using > new forms as inclusion tag. Form model looks like: > ... > sf_name = forms.CharField(required=True, label=_('Username:'), > max_length=30, widget=forms.TextInput(attrs={'class':'wsu-login-edit'})) > ... > > If I change language by setting session['django-language'], page is > re-rendered correctly using the new language, except labels defined in > form model (texts translated in underlying inclusion template are > OK). > When re-rendering page, form is instantiated again, but texts in > labels does not correspond to current > request.session['django-language'] value. I tried to trace Django-code > down, but I was lost somewhere in copy.py > > # > > Having this written, I got an idea to test another new form instances > and it seems that those instances do not work as well i.e. instance > does not translate labels if language is session changed is changed. > > # > > Please, could anybody advise me, what I'm missing? > > Thank, Peter --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Problems with i18n of field labels (newforms)
Hi all, I'm trying to embed login form into each page. I implemented it using new forms as inclusion tag. Form model looks like: ... sf_name = forms.CharField(required=True, label=_('Username:'), max_length=30, widget=forms.TextInput(attrs={'class':'wsu-login-edit'})) ... If I change language by setting session['django-language'], page is re-rendered correctly using the new language, except labels defined in form model (texts translated in underlying inclusion template are OK). When re-rendering page, form is instantiated again, but texts in labels does not correspond to current request.session['django-language'] value. I tried to trace Django-code down, but I was lost somewhere in copy.py # Having this written, I got an idea to test another new form instances and it seems that those instances do not work as well i.e. instance does not translate labels if language is session changed is changed. # Please, could anybody advise me, what I'm missing? Thank, Peter --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Problems with i18n support
On 12 Maj, 11:39, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Sat, 2007-05-12 at 02:25 -0700, Psamathos wrote: > > Hi, > > > I'm trying to get some basic i18n support going but I'm get some weird > > errors. > > > 1) I had to include the project in INSTALLED_APPS before anything > > would happend at all, but I've since removed that and I'm trying to > > translate a single app. > > 2) I've been digging around the django code to figure out which part > > wasn't working, and in django/template/__init__.py:727 I changed to > > return "%s" % bits, just to see what was in the list. Every > > translation comes back as a which might or > > might not be correct. I thought it was supposed to be a string though. > > > Currently I'm stuck with this error: > > > AssertionError at /users/signup > > should be a basestring > > Request Method:POST > > Request URL: http://naring.dev/users/signup > > Exception Type:AssertionError > > Exception Value:should be a basestring > > Exception Location:/usr/lib/python2.5/site-packages/django/newforms/ > > util.py in __init__, line 47 > > This does look unusual. Since I don't remember us completely breaking > the i18n support recently, I suspect there is something not quite right > in your code. You've given us a very clear indication of what the error > is that you're seeing. Now, it would be good to see what you are doing > to generate those pieces. > > Can you make a (preferably very small) example that demonstrates the > problem you are seeing? What is the smallest template you can make that > shows this issue? It will be easier to help work out what's going wrong > if we can replicate the problem. > > Regards, > Malcolm I made a new template: {% load i18n %} {% trans "login:" %} with which I get the error: TypeError at /users/signup sequence item 2: expected string, instance found Request Method: GET Request URL:http://naring.dev/users/signup Exception Type: TypeError Exception Value:sequence item 2: expected string, instance found Exception Location: /usr/lib/python2.5/site-packages/django/template/ __init__.py in render, line 726 I could start a new project and see if I messed something up in this one. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Problems with i18n support
On Sat, 2007-05-12 at 02:25 -0700, Psamathos wrote: > Hi, > > I'm trying to get some basic i18n support going but I'm get some weird > errors. > > 1) I had to include the project in INSTALLED_APPS before anything > would happend at all, but I've since removed that and I'm trying to > translate a single app. > 2) I've been digging around the django code to figure out which part > wasn't working, and in django/template/__init__.py:727 I changed to > return "%s" % bits, just to see what was in the list. Every > translation comes back as a which might or > might not be correct. I thought it was supposed to be a string though. > > Currently I'm stuck with this error: > > AssertionError at /users/signup > should be a basestring > Request Method: POST > Request URL: http://naring.dev/users/signup > Exception Type: AssertionError > Exception Value: should be a basestring > Exception Location: /usr/lib/python2.5/site-packages/django/newforms/ > util.py in __init__, line 47 This does look unusual. Since I don't remember us completely breaking the i18n support recently, I suspect there is something not quite right in your code. You've given us a very clear indication of what the error is that you're seeing. Now, it would be good to see what you are doing to generate those pieces. Can you make a (preferably very small) example that demonstrates the problem you are seeing? What is the smallest template you can make that shows this issue? It will be easier to help work out what's going wrong if we can replicate the problem. Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Problems with i18n support
On 12 Maj, 11:25, Psamathos <[EMAIL PROTECTED]> wrote: > Hi, > > I'm trying to get some basic i18n support going but I'm get some weird > errors. > > 1) I had to include the project in INSTALLED_APPS before anything > would happend at all, but I've since removed that and I'm trying to > translate a single app. > 2) I've been digging around the django code to figure out which part > wasn't working, and in django/template/__init__.py:727 I changed to > return "%s" % bits, just to see what was in the list. Every > translation comes back as a which might or > might not be correct. I thought it was supposed to be a string though. > > Currently I'm stuck with this error: > > AssertionError at /users/signup > should be a basestring > Request Method: POST > Request URL:http://naring.dev/users/signup > Exception Type: AssertionError > Exception Value: should be a basestring > Exception Location: /usr/lib/python2.5/site-packages/django/newforms/ > util.py in __init__, line 47 > > Anyone that could help me with this? Django is the best web framework > I've used so far and I'd like to use it. I've checked out the latest > version from subversion (5199). Django is running with mod_python in a > prefork apache2, I've set the max request limit to 1. > > regards, > Magnus Sjöstrand If I move the LocaleMiddleWare I can end up with the following error: TypeError at /users/signup sequence item 0: expected string, instance found Request Method: GET Request URL:http://naring.dev/users/signup Exception Type: TypeError Exception Value:sequence item 0: expected string, instance found Exception Location: /usr/lib/python2.5/site-packages/django/template/ __init__.py in render, line 726 Seems to me this is the same error just occuring at a different place though. //Magnus --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Problems with i18n support
Hi, I'm trying to get some basic i18n support going but I'm get some weird errors. 1) I had to include the project in INSTALLED_APPS before anything would happend at all, but I've since removed that and I'm trying to translate a single app. 2) I've been digging around the django code to figure out which part wasn't working, and in django/template/__init__.py:727 I changed to return "%s" % bits, just to see what was in the list. Every translation comes back as a which might or might not be correct. I thought it was supposed to be a string though. Currently I'm stuck with this error: AssertionError at /users/signup should be a basestring Request Method: POST Request URL:http://naring.dev/users/signup Exception Type: AssertionError Exception Value: should be a basestring Exception Location: /usr/lib/python2.5/site-packages/django/newforms/ util.py in __init__, line 47 Anyone that could help me with this? Django is the best web framework I've used so far and I'd like to use it. I've checked out the latest version from subversion (5199). Django is running with mod_python in a prefork apache2, I've set the max request limit to 1. regards, Magnus Sjöstrand --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---