Note that there are some explanatory texts on larger screens.

plurals
  1. POdjango i18n doesn't work
    text
    copied!<p>I have problem in django internationalization (i18n). the translation doesn't work. my django version is : 1.5.4 This is my code:</p> <p>settings.py </p> <pre><code>ugettext = lambda s:s LANGUAGES = [ ('en','English'), ('fa','Farsi'), ] LANGUAGE_CODE = 'en_us' USE_I18N = True USE_L10N = True TEMPLATE_DIRS = ( os.path.join(PROJECT_PATH,'templates'), ) </code></pre> <p>urls.py</p> <pre><code>from django.conf.urls import patterns, include, url from main import * urlpatterns = patterns('', url(r'$^',index), ) </code></pre> <p>main.py</p> <pre><code>from django.shortcuts import render from django.utils.translation import ugettext_lazy as _ def index(request): alert = _('this is my page') return render(request,'index.html',{'alert':alert}) </code></pre> <p>index.html</p> <pre><code> {% load i18n %} {{alert}} </code></pre> <p>and then:</p> <pre><code>$mkdir conf/locale -p $django-admin.py makemessages -l fa processing language fa $django-admin.py compilemessages processing file django.po in /home/mori/Desktop/salam/salam/locale/fa/LC_MESSAGES </code></pre> <p>django.po</p> <pre><code># 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 &lt;EMAIL@ADDRESS&gt;, YEAR. # #, fuzzy msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2013-10-15 13:12+0330\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME &lt;EMAIL@ADDRESS&gt;\n" "Language-Team: LANGUAGE &lt;LL@li.org&gt;\n" "Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=1; plural=0;\n" #: main.py:4 msgid "this is my page" msgstr "in safeye mane" </code></pre> <p>I have 'django.middleware.locale.LocaleMiddleware' in middleware class and 'django.core.context_processors.i18n' in TEMPLATE_COTEXT_PROCESSORS.</p> <p>output</p> <pre><code>this is my page </code></pre> <p>How can I solve it?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload