Monday, 12 January 2015
Django - Translation check list
1. Mark your text for translation. ex:
a. In template: using {% load i18n %} (at the top but have to be after the 'extends' tag) and {% trans 'text to be translated' %}
b. in your code: from django.utils.translation import ugettext as _ ; _('Your text to be translated here')
2. Build the message file for language translations (creating .po files:
./manage makemessages -l vi (my django-admin.py doesn't work for me)
You can run this again to reexamine the other text
3. Compile messages files
./manage compilemessages (do this again after you make changes to your po file
4. settings file
LOCALE_PATHS = ( os.path.join(BASE_DIR, 'locale'), )
LANGUAGE_CODE = 'vi'
5. use URL international with i18n_patterns and set_length()
add django.middleware.locale.LocaleMiddleware to MIDDLEWARE_CLASSES
Use this form to set user's language preference
6.Others:
TEMPLATE_CONTEXT_PROCESSORS += ( 'django.core.context_processors.request', )
add this to use request.get_full_path in your template
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment