Sunday 15 February 2015

internationalization - django - how to make translation work? -


I am trying to present the template in a different language using i18n. Whatever I read, by setting the language code, including translation tags in the template, and creating and compiling translation files, and my template still translates into English through {{LANGUAGE_CODE}} variable digits (And different) code I intended to render. What am I missing?

Template:

  {% load "iGoogle"%} {% load i18n%} {% get_current_language as LANGUAGE_CODE%} {% get_available_languages ​​LANGUAGES%} {% LANGUAGE_BIDI%} {% of the block title%} {% trance "translation test"%} {% endblock%} {% block content%} as get_current_language_bidi & lt; Div id = "some-lesson" & gt; Li  This is something & lt; / li & gt; 
  • li & gt; / l & gt; & lt; / ol & gt; {% Endblocktrans%} & lt; ul & gt; & lt; / li & gt; & lt; li & gt;
  • The current language & lt; b & gt; {{LANGUAGE_CODE}} & lt; / b & gt; & lt; / li & gt; {% if LANGUAGE_BIDI%} & lt; li & gt; The current language is bidirectional & lt; / li & gt; {% Else%} & lt; li & gt; The current language & lt; b & gt; not & lt; / b & gt; bidirectional & lt; / li & gt; ; {% Endif%}
  • Available languages ​​are: & lt; li & gt; {{lang.1}} for Lang in {% LANGUAGES%} & lt; / Li> {% Endfor%} & lt; / ul & gt; & lt; / li & gt; & lt; / ul & gt; & Lt
    Debuger DEF check (request): return render_to_response ('index.html', context_instance = RequestContext (request)
  • Command line (I filled out the correct translation in .po files):

      $ django-admin.py makemessages -l he-il -e html $ django-admin.py compilemessages  

    settings.py.

    < Pre> # language code for this installation All options can be found here: # http://www.i18nguy.com/unicode/language-identifiers.html LANGUAGE_CODE = 'he-il' gettext = lambda s: s LANGUAGES = (('He-il', gettext ('Hebrew')), ('en-US', gettext ('English')), # If you do this set to false, Django will make some customizations to load it as not # Internationalization Machinery USE_I18N = True TEMPLATE_CONTEXT_PROCESSORS = ("django.core.context_processors.auth", "d jango.core.context_processors.i18n",) MIDDLEWARE_CLASSES = ('django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware .SessionMiddleware ',' django.middleware.locale.LocaleMiddleware ',' django.contrib. Auth.middleware.Aut Text "itemprop =" text ">

    after generating the path of the file to the File as configured.py

      LOCALE_PATHS = ("/ xxx / xxx / projects / xxx / sites / AVB / local /",)  

    No comments:

    Post a Comment