Search code examples
djangopython-2.7django-i18n

How to view your translated site?


I am trying to view my site in japanese. I have create the translations and compiled them with compilemessages.

In my urls.py I have

urlpatterns = i18n_patterns('',
    #...
)

Settings.py

LANGUAGE_CODE = 'en-us'

#Used for translations
gettext = lambda s: s
LANGUAGES = (
    ('en', gettext('English')),
    ('jp', gettext('Japanese')),    
)

But when I try to access a url with /jp/ at the start I get that there is only /en/

Using the URLconf defined in PLP.urls, Django tried these URL patterns, in this order:

^en/

The current URL, jp/accounts/login, didn't match any of these.

I am using dbgettext so I also have my database content translated in my messages.

But how can I display it

   {% trans "Question:" %}{% trans {{question.question}} %}<br>

Could not parse the remainder: '{{question.question}}' from '{{question.question}}'

EDIT

Thanks Ngenator!

My other issue was that Japanese is 'ja' not 'jp'


Solution

  • Well the {% trans %} tag takes a variable directly, so you don't need those extra braces, just

    {% trans "Question:" %}{% trans question.question %}<br>
    

    or using the {% blocktrans %} tag

    {% blocktrans %}Question: {{ question.question }}{% endblocktrans %}
    

    should work. I'm not sure about the url issues though.