Django internationalisation

Preview:

DESCRIPTION

Speaking about how internationalisation affects web developers, how it works and what can be improved in Django. See http://reinout.vanrees.org/weblog/2014/11/14/4internationalisation.html for a write-up.

Citation preview

Internationalisation

56% of the Web is English

56% of the Web is English

5% native speaker

56% of the Web is English

5% native speaker

20% basic understanding

0.8% of the Web is Arabic

0.8% of the Web is Arabic

4% native speaker

0.1% of the Web is Hindi

0.1% of the Web is Hindi

5% native speaker

Next 4 billion

Multilingual multicultural

Long words and their abbreviations

Internationalisation (i18n)

Internationalisation (i18n)

{% blocktrans count message_count=messages.count %} {{ message_count }} message{% plural %} {{ message_count }} messages{% endblocktrans %}

Internationalisation (i18n)

from django.utils.translation import gettext

def home(request): context = { 'page_title': gettext('About Us'), } return render(request, 'home.html', context)

Translations (t9n)

Translations (t9n)

#: home.html:5#, python-formatmsgid "%(message_count)s message"msgid_plural "%(message_count)s messages"msgstr[0] "%(message_count)s Nachricht"msgstr[1] "%(message_count)s Nachrichten"

Translations (t9n)

class Revision(models.Model): # ... language = models.CharField(max_length=7, default=settings.LANGUAGE_CODE, choices=settings.LANGUAGES)

Localisation (l10n)

Localisation (l10n)

DATETIME_FORMAT = 'j. F Y H:i'FIRST_DAY_OF_WEEK = 1 # MondayDECIMAL_SEPARATOR = ','THOUSAND_SEPARATOR = '.'

Localisation (l10n)

USE_L10N = True

django.utils.translation

Language detection

— URL path

— Session data from a previous visit

— Cookie

— Accept-Language request header

— Django setting LANGUAGE_CODE

gettext

gettext string extraction workflow

1. add feature

2. run makemessages management command

3. send untranslated PO file to translators

4. receive translated PO file from translators

5. run compilemessages managment command

6. goto 1.

JavaScript

Timezones

Local formats

Unicode CLDR

The missing pieces

CLDR

— more formatting options

CLDR

— more formatting options

— ability to update locale data

Translation catalogs

— ability to merge catalogs

Translation catalogs

— ability to merge catalogs

— visualize which strings require translation

Translation catalogs

— ability to merge catalogs

— visualize which strings require translation

— show a dashboard for the progress

Translate content

— specialized model fields and managers for translated content

Translate content

— specialized model fields and managers for translated content

— add CompositeField for effective per language content

Translate content

— specialized model fields and managers for translated content

— add CompositeField for effective per language content

— provide form widgets to embedding in user code

Add helpers

— visual translation with sync to PO files

Add helpers

— visual translation with sync to PO files

— language selectors for user facing code and admin

Add helpers

— visual translation with sync to PO files

— language selectors for user facing code and admin

— extend language detection to take HOST into account

Add helpers

— visual translation with sync to PO files

— language selectors for user facing code and admin

— extend language detection to take HOST into account

— add timezone selectors

Call for action!

— rewrite on top of Babel

— push the bounderies

— make i18n a first class citizen

Thanks! Questions?

@jezdez

Recommended