Ticket #12848: native_languages_V1.diff

File native_languages_V1.diff, 6.0 KB (added by Benny Daon, 15 years ago)
  • django/trunk/django/core/context_processors.py

    diff -r fe615a234837 django/trunk/django/core/context_processors.py
    a b  
    7070
    7171def i18n(request):
    7272    from django.utils import translation
     73    global _languages_cache
    7374
    7475    context_extras = {}
    75     context_extras['LANGUAGES'] = settings.LANGUAGES
    7676    context_extras['LANGUAGE_CODE'] = translation.get_language()
    7777    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
    7888
     89    context_extras['LANGUAGES'] = languages
    7990    return context_extras
    8091
    8192def media(request):
  • django/trunk/examples/hello/urls.py

    diff -r fe615a234837 django/trunk/examples/hello/urls.py
    a b  
    88    (r'^getdata/$', 'get_data'),
    99    (r'^postdata/$', 'post_data'),
    1010)
     11urlpatterns += patterns('examples.hello.i18n_views',
     12    url(r'^i18n/$', 'hello_i18n', name='hello_i18n'),
     13)
  • new file django/trunk/examples/locale/es/LC_MESSAGES/django.po

    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
     7msgid ""
     8msgstr ""
     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
     20msgid "English"
     21msgstr ""
     22
     23#: settings.py:11
     24msgid "French"
     25msgstr ""
     26
     27#: settings.py:12
     28msgid "Spanish"
     29msgstr "Español"
     30
     31#: settings.py:13
     32msgid "Russian"
     33msgstr ""
  • new file django/trunk/examples/locale/fr/LC_MESSAGES/django.po

    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
     7msgid ""
     8msgstr ""
     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
     20msgid "English"
     21msgstr ""
     22
     23#: settings.py:11
     24msgid "French"
     25msgstr "français"
     26
     27#: settings.py:12
     28msgid "Spanish"
     29msgstr ""
     30
     31#: settings.py:13
     32msgid "Russian"
     33msgstr ""
  • new file django/trunk/examples/locale/ru/LC_MESSAGES/django.po

    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
     7msgid ""
     8msgstr ""
     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
     20msgid "English"
     21msgstr ""
     22
     23#: settings.py:11
     24msgid "French"
     25msgstr ""
     26
     27#: settings.py:12
     28msgid "Spanish"
     29msgstr ""
     30
     31#: settings.py:13
     32msgid "Russian"
     33msgstr "Русский"
  • django/trunk/examples/settings.py

    diff -r fe615a234837 django/trunk/examples/settings.py
    a b  
    33DEBUG = True
    44TEMPLATE_DEBUG = DEBUG
    55ROOT_URLCONF = 'examples.urls'
     6USE_I18N = True
     7gettext = lambda s: s
     8
     9LANGUAGES = (
     10    ('en', gettext('English')),
     11    ('fr', gettext('French')),
     12    ('es', gettext('Spanish')),
     13    ('ru', gettext('Russian')),
     14)
  • django/trunk/examples/urls.py

    diff -r fe615a234837 django/trunk/examples/urls.py
    a b  
    33urlpatterns = patterns('',
    44    (r'^$', 'examples.views.index'),
    55    (r'^hello/', include('examples.hello.urls')),
     6    (r'^i18n/', include('django.conf.urls.i18n')),
    67)
  • django/trunk/examples/views.py

    diff -r fe615a234837 django/trunk/examples/views.py
    a b  
    11from django import http
     2from django.core.urlresolvers import reverse
    23
    34def index(request):
    45    r = http.HttpResponse('<h1>Django examples</h1><ul>')
     
    89    r.write('<li><a href="hello/metadata/">Displaying request metadata</a></li>')
    910    r.write('<li><a href="hello/getdata/">Displaying GET data</a></li>')
    1011    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>')
    1113    r.write('</ul>')
    1214    return r
Back to Top