Internationalizing Ubuntu apps
Click here to load reader
-
Upload
david-planella -
Category
Software
-
view
288 -
download
0
description
Transcript of Internationalizing Ubuntu apps
Internationalizing Ubuntu apps David Planella @ Ubuntu App Developer Week, Mar 2014
> the concepts
(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
(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
(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
(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
> internationalizing 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
(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
(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
> localizing 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
demo> Launchpad project i18n setup
Thank youandstay in touch!
> David Planella <[email protected]>
> +DavidPlanella · @dplanella
> developer.ubuntu.com
> @ubuntuappdev
> gplus.to/ubuntuappdev
> facebook.com/ubuntuappdev