python - How to use translations in Django? -


i'm following django tutorials translation, cannot make work. i'm missing simple didn't bother write, can't see what.

my settings.py has following declarations :

language_code = 'en-us' use_i18n = true _ = lambda s: s languages = (   ('en', 'english'),   ('fr', 'french'), ) locale_paths= (                 os.path.join( site_root, 'locale').replace('\\','/'),                ) 

my view looks :

from django.utils.translation import ugettext_lazy _ django.utils.translation import ugettext __ #...  def translation_test(request):         output = __("yes")         return httpresponse(output) 

and projectroot/locale/fr/lc_messages/django.po file has :

msgid "yes" msgstr "oui" 

so expect view generate "oui", however, generates "yes". missing here?

p.s. tried template file, because need work too:

my_template.html :

{% extends "base_site.html" %} {% load i18n %} <a>{% trans "yes" %}</a> 

again, no translation. should make work?

thanks in advance.

french should active language see translated value.

check https://docs.djangoproject.com/en/1.8/topics/i18n/translation/#how-django-discovers-language-preference see how django determines active language.

you can test translation see if there's wrong translation config settings language_code = 'fr'


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

order - Notification for user in user account opencart -