Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Becoming a MutltiLingual SuperHero in Django

Becoming a MutltiLingual SuperHero in Django

In this talk, we’ll see how we make a language agnostic backend, to serve our app in different languages, based on what language the client wants to communicate in.

We’ll see how to support translation for static data and dynamic data, using various third-party services.

Sanyam Khurana

August 24, 2018
Tweet

More Decks by Sanyam Khurana

Other Decks in Programming

Transcript

  1. def __who_am_i__(): • One of you! A part of the

    community • CPython contributor and bug triage access on bugs.python.org • Contributor to Gecko Engine, add-ons, Marionette, TaskCluster • GSoC 2018 Mentor for Debian • RGSoC 2016 Mentor
  2. Selecting Language in the order of preference • Language prefix

    in requested URL (Eg: /en/api/resource) • LANGUAGE_SESSION_KEY key in current user's session • django_language cookie determined by LANGUAGE_COOKIE_NAME • Accept-Language header • Fallback to LANGUAGE_CODE in settings
  3. • Language prefix in requested URL • LANGUAGE_SESSION_KEY key in

    current user's session • django_language cookie determined by LANGUAGE_COOKIE_NAME • Accept-Language header • LANGUAGE_CODE setting
  4. GOTCHA #2 i18n tag should be loaded in every file,

    even if it extends another file that already has it loaded.
  5. • Language prefix in requested URL • LANGUAGE_SESSION_KEY key in

    current user's session • django_language cookie determined by LANGUAGE_COOKIE_NAME • Accept-Language header • LANGUAGE_CODE setting
  6. • Language prefix in requested URL • LANGUAGE_SESSION_KEY key in

    current user's session • django_language cookie determined by LANGUAGE_COOKIE_NAME • Accept-Language header • LANGUAGE_CODE setting
  7. GOTCHA #8 Check in django shell if the translations are

    working with activate and ugettext