Skip to content

Instantly share code, notes, and snippets.

@nqthqn
Last active August 29, 2015 14:06
Show Gist options
  • Save nqthqn/c81d8e3cc1f871fe9ae9 to your computer and use it in GitHub Desktop.
Save nqthqn/c81d8e3cc1f871fe9ae9 to your computer and use it in GitHub Desktop.
Language translation

Steps

  • pip install django-rosetta and add to apps in settings
  • Add the url:
    if 'rosetta' in settings.INSTALLED_APPS:
        urlpatterns += patterns('',
            url(r'^rosetta/', include('rosetta.urls')),
        )

In views:

  • from django.utils.translation import ugettext_lazy as _
  • greet = [_("Welcome"), _("Hello"), _("Hi")]
  • django-admin.py makemessages --locale=es
  • django-admin.py makemessages --locale=es && ./manage.py compilemessages
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment