Internationalizing Ubuntu apps

14

Click here to load reader

description

Slides for the live presentation on how to internationalize Ubuntu apps as part of the Ubuntu App Developer Week. http://davidplanella.org/internationalizing-apps-ubuntu-app-developer-week/

Transcript of Internationalizing Ubuntu apps

Page 1: Internationalizing Ubuntu apps

Internationalizing Ubuntu apps David Planella @ Ubuntu App Developer Week, Mar 2014

Page 2: Internationalizing Ubuntu apps

> the concepts

Page 3: Internationalizing Ubuntu apps

(c) 2013 Canonical

Ubuntu internationalization 101> Internationalization (i18n): “what developers do”

> Localization (l10n): “what translators do”

> Ubuntu app use Gettext technologies for internationalization

> Developers:

> mark text for translation using the i18n API in the SDK

> extract those translatable messages and expose them to translators

> build the finished translations and ship them in the app’s click package

> Translators:

> work in language teams to provide translations for a given language

> start their work once a call for translations is done

Internationalization concepts

Page 4: Internationalizing Ubuntu apps

(c) 2013 Canonical

Gettext glossary: POT files> POT files or translation templates are textual files with .pot extensions

> Developers create the .pot file for translators, using gettext tools

> Each app has one template which is exposed to translators

> It consists of a standard header and contains msgid/msgid pairs

> msgid lines contain the original message

> msgstr contain the translated message but are empty in templates

> From one template, many translations are generated,

one for each language

#: ../NewEvent.qml:143

msgid "Add Location"

msgstr ""

Internationalization concepts

Page 5: Internationalizing Ubuntu apps

(c) 2013 Canonical

Gettext glossary: PO files> PO files or translations are textual files with .po extension

> Translators or an online translation tool generate translation files

> Each app has as many translations as languages it’s available on

> They consist of a standard header and contains msgid/msgid pairs

> msgid lines contain the original message

> msgstr contain the translated message but are empty in templates

> Each translation file is named after LANGCODE.po, where LANGCODE

is a valid ISO 639 language code, with an optional country code

#: ../NewEvent.qml:143

msgid "Add Location"

msgstr "Afegeix una ubicació"

Internationalization concepts

Page 6: Internationalizing Ubuntu apps

(c) 2013 Canonical

Gettext glossary: MO files> MO files are binary files that contain the translations loaded at runtime

> They are generated at build time from the .po files, using gettext tools

> Use msgfmt to generate .mo files from .po files

> They are efficient: fast binary hash table to look up translations

> MO files are shipped within the app’s click package, one per language

> They follow a standard layout when installed:

share/locale/$LANGCODE/LC_MESSAGES/$APPID.mo

> $LANGCODE is the ISO 639 language code (e.g. ‘de’ or ‘pt_BR’)

> $APPID is the app’s ID (e.g. com.ubuntu.developer.dplanella.myapp)

Internationalization concepts

Page 7: Internationalizing Ubuntu apps

> internationalizing apps

Page 8: Internationalizing Ubuntu apps

(c) 2013 Canonical

Use the SDK to mark messages for translation> Make messages translatable using the i18n.tr() call:

property: i18n.tr(“Hello world”)

> At runtime, if there is an available translation for the user’s language

it will be loaded from the corresponding .mo file

> Use count arguments and the plural mode for plural messages

property string appleCount: i18n.tr("%1 apple",

"%1 apples",

applecount).arg(applecount)

> Documentation at http://developer.ubuntu.com/api/qml/sdk-1.0/Ubuntu.Components.i18n/

Internationalizing apps

Page 9: Internationalizing Ubuntu apps

(c) 2013 Canonical

Use gettext and CMake to extract translatable messages

> Once marked for translation, messages need to be extracted from

the sources and put into the .pot file

> Use xgettext and a CMake rule for extraction,

and store the .pot file under a

po/ folder at the top of your source tree

> See the core apps code for an example,

Weather is a good choice

http://bazaar.launchpad.net/~ubuntu-weather-dev/ubuntu-weather-app/trunk/view/head:/po/CMakeLists.txt

Internationalizing apps

Page 10: Internationalizing Ubuntu apps

(c) 2013 Canonical

Use msgfmt and CMake to build translations

> Once translators have done their work,

.po files need to be built and shipped

> Use xgettext and a CMake rule for build,

and ship translations in the click package

> See the core apps code for an example,

Weather is a good choice

http://bazaar.launchpad.net/~ubuntu-weather-dev/ubuntu-weather-app/trunk/view/head:/po/CMakeLists.txt

Internationalizing apps

Page 11: Internationalizing Ubuntu apps

> localizing apps

Page 12: Internationalizing Ubuntu apps

(c) 2013 Canonical

Translators rock!, so be nice to them :)> A community of translators will be ready to translate your app in

hundreds of languages

> They are kindly exposing your app to millions users in their language:

make their lifes easier to translate

> Add comments to your translatable messages

> Use an online translation service (Launchpad is a good choice)

> At least a week or two before release

> Send calls for translations on your social channels

> Send calls for translations on [email protected]

Localizing apps

Page 13: Internationalizing Ubuntu apps

demo> Launchpad project i18n setup

Page 14: Internationalizing Ubuntu apps

Thank youandstay in touch!

> David Planella <[email protected]>

> +DavidPlanella · @dplanella

> developer.ubuntu.com

> @ubuntuappdev

> gplus.to/ubuntuappdev

> facebook.com/ubuntuappdev