in translation function calls • django-admin.py makemessages • Deliver po file to translation service • Receive file back • django-admin.py compilemessages Tuesday, September 4, 12
in translation function calls • django-admin.py makemessages • Deliver po file to translation service • Receive file back • django-admin.py compilemessages • Fin Tuesday, September 4, 12
you see a <django.utils.functional...> in HTML or debug code, You’re trying to use a gettext_lazy proxy string too soon. • Import gettext or gettext_lazy as _ • If you need both in the same file, use _ and _lazy Tuesday, September 4, 12
told by an non-English speaker that certain words aren’t translated • Wrap missing text in translation function calls • django-admin.py makemessages Tuesday, September 4, 12
told by an non-English speaker that certain words aren’t translated • Wrap missing text in translation function calls • django-admin.py makemessages • Dig through translation to find the new ones Tuesday, September 4, 12
told by an non-English speaker that certain words aren’t translated • Wrap missing text in translation function calls • django-admin.py makemessages • Dig through translation to find the new ones • Deliver po file to translation service Tuesday, September 4, 12
told by an non-English speaker that certain words aren’t translated • Wrap missing text in translation function calls • django-admin.py makemessages • Dig through translation to find the new ones • Deliver po file to translation service • Receive file back, re-compile Tuesday, September 4, 12
told by an non-English speaker that certain words aren’t translated • Wrap missing text in translation function calls • django-admin.py makemessages • Dig through translation to find the new ones • Deliver po file to translation service • Receive file back, re-compile • Have marketing ask you to change “just two words” in old translation Tuesday, September 4, 12
told by an non-English speaker that certain words aren’t translated • Wrap missing text in translation function calls • django-admin.py makemessages • Dig through translation to find the new ones • Deliver po file to translation service • Receive file back, re-compile • Have marketing ask you to change “just two words” in old translation • Find out those words are located in the database Tuesday, September 4, 12
told by an non-English speaker that certain words aren’t translated • Wrap missing text in translation function calls • django-admin.py makemessages • Dig through translation to find the new ones • Deliver po file to translation service • Receive file back, re-compile • Have marketing ask you to change “just two words” in old translation • Find out those words are located in the database • With great sadness, manually add those two words into the django.po file Tuesday, September 4, 12
told by an non-English speaker that certain words aren’t translated • Wrap missing text in translation function calls • django-admin.py makemessages • Dig through translation to find the new ones • Deliver po file to translation service • Receive file back, re-compile • Have marketing ask you to change “just two words” in old translation • Find out those words are located in the database • With great sadness, manually add those two words into the django.po file • Get told by an non-English speaker that certain words aren’t translated Tuesday, September 4, 12
told by an non-English speaker that certain words aren’t translated • Wrap missing text in translation function calls • django-admin.py makemessages • Dig through translation to find the new ones • Deliver po file to translation service • Receive file back, re-compile • Have marketing ask you to change “just two words” in old translation • Find out those words are located in the database • With great sadness, manually add those two words into the django.po file • Get told by an non-English speaker that certain words aren’t translated Tuesday, September 4, 12
told by an non-English speaker that certain words aren’t translated • Wrap missing text in translation function calls • django-admin.py makemessages • Dig through translation to find the new ones • Deliver po file to translation service • Receive file back, re-compile • Have marketing ask you to change “just two words” in old translation • Find out those words are located in the database • With great sadness, manually add those two words into the django.po file • Get told by an non-English speaker that certain words aren’t translated Tuesday, September 4, 12
Munges all translations not found in canon.po • poxx.py location/of/locale/django.po -c location/of/locale/canon.po --diff • Creates location/of/locale/django_diff.po file, containing all translations not found in canon.po Tuesday, September 4, 12
in 1.4) , then • Session code, then • User’s cookie, then • Accept-Language header, then finally • Your project’s LANGUAGE_CODE setting django.utils.translation.trans_real.get_language_from_request Tuesday, September 4, 12
i18n infrastructure if our site is in settings.TRANSLATED_SITES request.site.url is set in an earlier middleware """ def process_request(self, request): site_url = request.site.url if site_url in settings.TRANSLATED_SITES: super(SiteSpecificLocaleMiddleware, self).process_request(request) else: request.LANGUAGE_CODE = settings.LANGUAGE_CODE Tuesday, September 4, 12
use i18n infrastructure if our site is in settings.TRANSLATED_SITES request.site.url is set in an earlier middleware """ def process_request(self, request): site_url = request.site.url site_locale = os.path.join(SOME_PO_FILE_PATH, site_url) if os.path.isdir(site_specific_locale): site_specific_trans = _translation( site_specific_locale, request.LANGUAGE_CODE) if brand_specific_trans: curr_trans = getattr(_active, 'value', None) if curr_trans: curr_trans.merge(site_specific_trans) else: curr_trans = site_specific_trans _active.value = curr_trans Tuesday, September 4, 12