Slide 1

Slide 1 text

translations evolved ruchi varshney pycon 2014

Slide 2

Slide 2 text

about me @rvarshney on the web

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

most common tools are gettext and babel ! import gettext as _ print _("Translate me.") ! from babel import dates, numbers dates.format_datetime(date, locale='de') numbers.format_decimal(1.234, locale='de') ! ! basics

Slide 5

Slide 5 text

! # Extraction config file (babel.cfg) [python: **.py] [jinja2: **.html] [javascript: **.js] ! [extractors] python = babel.messages.extract:extract_python jinja2 = jinja2.ext:babel_extract javascript = babel.messages.extract:extract_javascript ! ! basics

Slide 6

Slide 6 text

# Run extraction $ pybabel extract --mapping-file babel.cfg --output out.po ! ! ! ! ! basics

Slide 7

Slide 7 text

! # Translations for MYAPP. # Copyright (c) 2014 ORGANIZATION ! #: app/views.py:20 #, python-format msgid "Translate me." msgstr "" ! ! basics

Slide 8

Slide 8 text

basics _("hello!") msgid "hello!" bonjour! translation service message.mo extract compile integrate

Slide 9

Slide 9 text

what could possibly go wrong?

Slide 10

Slide 10 text

latency

Slide 11

Slide 11 text

! def greeting(name, is_welcome): if is_welcome: return _("Hey there!") else: return _("Bye Bye") ! ! ! strings before logic

Slide 12

Slide 12 text

! class Greetings(object): WELCOME_MESSAGE = _("Hey there!") BYE_MESSAGE = _("Bye!") ! ! def greeting(name, is_welcome): if is_welcome: return Greetings.WELCOME_MESSAGE else: return Greetings.BYE_MESSAGE strings before logic

Slide 13

Slide 13 text

! class Greetings(object): WELCOME_MESSAGE = _("Hey there!”) BYE_MESSAGE = _("Bye!") BYE_MESSAGE = _("See you later!") ! ! ! ! ! lost in translation

Slide 14

Slide 14 text

! #, python-format msgid "Bye!" msgstr "Au revoir!" ! #, python-format msgid "See you later!" msgstr "" ! lost in translation

Slide 15

Slide 15 text

lost in translation

Slide 16

Slide 16 text

hooks https://17727.web.pr.dev.hearsaylabs.com/

Slide 17

Slide 17 text

! class Greetings(object): WELCOME_MESSAGE = _("Hey there!”) BYE_MESSAGE = _("Bye!") NEW_BYE_MESSAGE = _("See you later!") ! ! ! ! ! lost in translation

Slide 18

Slide 18 text

babel gotchas #: app/views.py:20 #, python-format #, fuzzy msgid "Translate them." msgstr "Traduisez-moi"

Slide 19

Slide 19 text

babel gotchas “strings might be marked as fuzzy — if you have fuzzy entries, make sure to check them by hand and remove the fuzzy flag before compiling.”

Slide 20

Slide 20 text

• —no-fuzzy-matching • other useful ones • —ignore-obsolete True • —add-comments TRANSLATOR: • —keyword "_lazy" babel flags

Slide 21

Slide 21 text

• find the last translation date • run string extraction • send po file for translation • wait… • get translations back • integrate with app • …. mundane dev

Slide 22

Slide 22 text

automation jenkins/travis translation upload translation download

Slide 23

Slide 23 text

dev intervention

Slide 24

Slide 24 text

content management

Slide 25

Slide 25 text

content management developer friendly apis translator friendly continuous, cross platform

Slide 26

Slide 26 text

• sample code • https://github.com/rvarshney/translations • how to i18n and l10n (pycon 2013) • http://bit.ly/pyconi18n • https://www.youtube.com/watch?v=QUFPPJMjn6k resources

Slide 27

Slide 27 text

• python packages and tools • gettext, babel, potpie, polib • githooks, webhooks, jenkins, travis • content management • smartling, transifex have known python support • django-rosetta (open source) resources

Slide 28

Slide 28 text

questions? @rvarshney we’re hiring!