diff -r fe615a234837 django/trunk/django/core/context_processors.py
a
|
b
|
|
70 | 70 | |
71 | 71 | def i18n(request): |
72 | 72 | from django.utils import translation |
| 73 | global _languages_cache |
73 | 74 | |
74 | 75 | context_extras = {} |
75 | | context_extras['LANGUAGES'] = settings.LANGUAGES |
76 | 76 | context_extras['LANGUAGE_CODE'] = translation.get_language() |
77 | 77 | context_extras['LANGUAGE_BIDI'] = translation.get_language_bidi() |
| 78 | # translate all the language names so natives can read them |
| 79 | try: |
| 80 | languages = _available_languages_cache |
| 81 | except NameError: |
| 82 | languages = [] |
| 83 | for lang, english_name in settings.LANGUAGES: |
| 84 | translation.activate(lang) |
| 85 | languages.append((lang, translation.ugettext(english_name))) |
| 86 | translation.deactivate() |
| 87 | _languages_cache = languages |
78 | 88 | |
| 89 | context_extras['LANGUAGES'] = languages |
79 | 90 | return context_extras |
80 | 91 | |
81 | 92 | def media(request): |
diff -r fe615a234837 django/trunk/examples/hello/urls.py
a
|
b
|
|
8 | 8 | (r'^getdata/$', 'get_data'), |
9 | 9 | (r'^postdata/$', 'post_data'), |
10 | 10 | ) |
| 11 | urlpatterns += patterns('examples.hello.i18n_views', |
| 12 | url(r'^i18n/$', 'hello_i18n', name='hello_i18n'), |
| 13 | ) |
diff -r fe615a234837 django/trunk/examples/locale/es/LC_MESSAGES/django.po
-
|
+
|
|
| 1 | # SOME DESCRIPTIVE TITLE. |
| 2 | # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER |
| 3 | # This file is distributed under the same license as the PACKAGE package. |
| 4 | # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. |
| 5 | # |
| 6 | #, fuzzy |
| 7 | msgid "" |
| 8 | msgstr "" |
| 9 | "Project-Id-Version: PACKAGE VERSION\n" |
| 10 | "Report-Msgid-Bugs-To: \n" |
| 11 | "POT-Creation-Date: 2010-02-11 17:51-0600\n" |
| 12 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" |
| 13 | "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" |
| 14 | "Language-Team: LANGUAGE <LL@li.org>\n" |
| 15 | "MIME-Version: 1.0\n" |
| 16 | "Content-Type: text/plain; charset=UTF-8\n" |
| 17 | "Content-Transfer-Encoding: 8bit\n" |
| 18 | |
| 19 | #: settings.py:10 |
| 20 | msgid "English" |
| 21 | msgstr "" |
| 22 | |
| 23 | #: settings.py:11 |
| 24 | msgid "French" |
| 25 | msgstr "" |
| 26 | |
| 27 | #: settings.py:12 |
| 28 | msgid "Spanish" |
| 29 | msgstr "Español" |
| 30 | |
| 31 | #: settings.py:13 |
| 32 | msgid "Russian" |
| 33 | msgstr "" |
diff -r fe615a234837 django/trunk/examples/locale/fr/LC_MESSAGES/django.po
-
|
+
|
|
| 1 | # SOME DESCRIPTIVE TITLE. |
| 2 | # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER |
| 3 | # This file is distributed under the same license as the PACKAGE package. |
| 4 | # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. |
| 5 | # |
| 6 | #, fuzzy |
| 7 | msgid "" |
| 8 | msgstr "" |
| 9 | "Project-Id-Version: PACKAGE VERSION\n" |
| 10 | "Report-Msgid-Bugs-To: \n" |
| 11 | "POT-Creation-Date: 2010-02-11 17:51-0600\n" |
| 12 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" |
| 13 | "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" |
| 14 | "Language-Team: LANGUAGE <LL@li.org>\n" |
| 15 | "MIME-Version: 1.0\n" |
| 16 | "Content-Type: text/plain; charset=UTF-8\n" |
| 17 | "Content-Transfer-Encoding: 8bit\n" |
| 18 | |
| 19 | #: settings.py:10 |
| 20 | msgid "English" |
| 21 | msgstr "" |
| 22 | |
| 23 | #: settings.py:11 |
| 24 | msgid "French" |
| 25 | msgstr "français" |
| 26 | |
| 27 | #: settings.py:12 |
| 28 | msgid "Spanish" |
| 29 | msgstr "" |
| 30 | |
| 31 | #: settings.py:13 |
| 32 | msgid "Russian" |
| 33 | msgstr "" |
diff -r fe615a234837 django/trunk/examples/locale/ru/LC_MESSAGES/django.po
-
|
+
|
|
| 1 | # SOME DESCRIPTIVE TITLE. |
| 2 | # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER |
| 3 | # This file is distributed under the same license as the PACKAGE package. |
| 4 | # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. |
| 5 | # |
| 6 | #, fuzzy |
| 7 | msgid "" |
| 8 | msgstr "" |
| 9 | "Project-Id-Version: PACKAGE VERSION\n" |
| 10 | "Report-Msgid-Bugs-To: \n" |
| 11 | "POT-Creation-Date: 2010-02-11 17:51-0600\n" |
| 12 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" |
| 13 | "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" |
| 14 | "Language-Team: LANGUAGE <LL@li.org>\n" |
| 15 | "MIME-Version: 1.0\n" |
| 16 | "Content-Type: text/plain; charset=UTF-8\n" |
| 17 | "Content-Transfer-Encoding: 8bit\n" |
| 18 | |
| 19 | #: settings.py:10 |
| 20 | msgid "English" |
| 21 | msgstr "" |
| 22 | |
| 23 | #: settings.py:11 |
| 24 | msgid "French" |
| 25 | msgstr "" |
| 26 | |
| 27 | #: settings.py:12 |
| 28 | msgid "Spanish" |
| 29 | msgstr "" |
| 30 | |
| 31 | #: settings.py:13 |
| 32 | msgid "Russian" |
| 33 | msgstr "Русский" |
diff -r fe615a234837 django/trunk/examples/settings.py
a
|
b
|
|
3 | 3 | DEBUG = True |
4 | 4 | TEMPLATE_DEBUG = DEBUG |
5 | 5 | ROOT_URLCONF = 'examples.urls' |
| 6 | USE_I18N = True |
| 7 | gettext = lambda s: s |
| 8 | |
| 9 | LANGUAGES = ( |
| 10 | ('en', gettext('English')), |
| 11 | ('fr', gettext('French')), |
| 12 | ('es', gettext('Spanish')), |
| 13 | ('ru', gettext('Russian')), |
| 14 | ) |
diff -r fe615a234837 django/trunk/examples/urls.py
a
|
b
|
|
3 | 3 | urlpatterns = patterns('', |
4 | 4 | (r'^$', 'examples.views.index'), |
5 | 5 | (r'^hello/', include('examples.hello.urls')), |
| 6 | (r'^i18n/', include('django.conf.urls.i18n')), |
6 | 7 | ) |
diff -r fe615a234837 django/trunk/examples/views.py
a
|
b
|
|
1 | 1 | from django import http |
| 2 | from django.core.urlresolvers import reverse |
2 | 3 | |
3 | 4 | def index(request): |
4 | 5 | r = http.HttpResponse('<h1>Django examples</h1><ul>') |
… |
… |
|
8 | 9 | r.write('<li><a href="hello/metadata/">Displaying request metadata</a></li>') |
9 | 10 | r.write('<li><a href="hello/getdata/">Displaying GET data</a></li>') |
10 | 11 | r.write('<li><a href="hello/postdata/">Displaying POST data</a></li>') |
| 12 | r.write('<li><a href="hello/i18n/">Internationalized Hello world</a></li>') |
11 | 13 | r.write('</ul>') |
12 | 14 | return r |