## page was renamed from MeetingLogs/devweek1001/devweek1001/I18NYourApp == Dev Week -- Internationalizing your application with quickly and Launchpad -- dpm and didrocks -- Tue, Jan 26 == UTC {{{#!IRC [17:59] and I'll hand over to the wonderful dpm and didrocks who are talking about internationalisation, quickly, and Launchpad! [17:59] thanks aquarius! [17:59] thanks aquarius :) [18:00] [SLIDE 1] [18:00] hey everyone [18:00] and welcome to this session on internationalizating applications with Quickly (https://wiki.ubuntu.com/Quickly) [18:00] https://wiki.ubuntu.com/Quickly [18:00] now [18:01] In the next hour we'll be talking on how to make applications speak your own language using several awesome technologies: Quickly, Gettext and Launchpad [18:01] Your equally awesome speakers today (well, at least didrocks is) will be: [18:01] Hi, I'm Didier Roche, I work in the Ubuntu Desktop team. I'm more focused on packaging UNE (Ubuntu Netbook Edition), which is the new name of UNR (Ubuntu Netbook Remix) and some GNOME related components. [18:01] [SLIDE 1] [18:01] Hi my name is David Planella, I work as the Ubuntu Translations Coordinator and as such my job is to work together the wonderful Ubuntu translations teams and make sure translations keep rocking as usual. I'm also a GNOME and Ubuntu translator, and lead of the Ubuntu Catalan translation team [18:02] So, without further ado, let's start the session by having a quick look at the main players involved in the internationalization game: [18:02] [SLIDE 2] [18:02] == GNU Gettext == [18:02] dpm: maybe, the link to the slides for people not having lernid if you have it :) [18:03] here it is : http://people.ubuntu.com/~dpm/Quickly-i18n.pdf [18:04] Gettext is the underlying and most widely used technology to enable translations of Open Source projects. [18:04] It defines a standard format of translation files translators can do their work with (PO files) [18:04] and lets applications load those translations compiled in a binary format (MO files) at runtime. [18:04] It has implementations for many programming languages, and amongst them, of course, Python. [18:05] You'll find that the comprehensive gettext manual at http://www.gnu.org/software/gettext/manual/gettext.html can be a very useful reference, [18:05] especially in those sleepless nights. [18:05] The Python implementation of the gettext API is what we'll use to internationalize our project with Quickly today. [18:05] Needless to say, it also comes with some nifty documentation at http://docs.python.org/library/gettext.html [18:05] == intltool == [18:06] Intltool is a higher level tool that adds functionality to gettext by allowing the extraction of translatable strings from a variety of file formats [18:06] It has also become a standard tool when implementing internationalization for OSS projects. Nearly all (if not all) GNOME projects, for example, use intltool. [18:06] It has also become a standard tool when implementing internationalization for OSS projects. Nearly all (if not all) GNOME projects, for example, use intltool. [18:06] For those interested in trivia, Danilo Šegan (or Данило Шеган, for those who can read cyrillic), our very own Launchpad Translations developer lead is also the co-maintainer of intltool. [18:07] == python-distutils-extra == [18:07] Python-distutils-extra is a python package that makes it easy to integrate themable icons, documentation and gettext based translations in your python install and build tools, and it's basically an enhancement to python-distutils. [18:07] The project's page is at http://www.glatzor.de/projects/python-distutils-extra/ [18:08] The three above technologies (gettext, intltool, python-distutils-extra) are transparently used by quickly, so we won't get into much more detail for now. [18:08] There are also more aspects involved in internationalizing applications, such as font rendering, input methods, etc., but this should get you started for now. [18:08] == Quickly == [18:08] I'll be very brief here and let Didier tell you more about Quickly in a bit. [18:08] For now, it will suffice give you a teaser and tell you that it is the tool which brings back the fun in writing applications [18:09] == Launchpad Translations == [18:09] Launchpad Translations ( https://translations.launchpad.net/ ) is the collaborative online tool which allows translation communities to be brought together and translate applications online through its web UI. [18:09] Apart from the very polished UI to provide translations, it has other nice features such as message sharing across project series (translate one message in a series and it instantly propagates to all other shared series), [18:10] global suggestions (suggestions of translations across _all_ projects in Launchpad), automatic imports of translations and automatic commits to bzr branches, several levels of permissions, and a huge translator base. [18:10] On the right hand side of the URL I gave you you can see that there are quite a lot of projects using Launchpad to make translations easy both for developers and translators. [18:10] I'll now hand over the mike to Didier to tell you more about what you all have wanted to hear: Quickly! [18:11] [SLIDE 3] [18:11] To follow that session, you can install Quickly on karmic or lucid simply by executing $ sudo aptitude install quickly. [18:11] well, if you are brave an courageous, you can also run from the trunk lp:quickly ;) [18:12] Once Quickly is installed, close the terminal and open a new one so that statement completion works (and you will love Quickly statement completion ;)) [18:12] But first, what is Quickly? In a nutshell, Quickly makes it easy and fun to write apps. [18:12] Rick Spencer (leader of Ubuntu Desktop team) is the inspiring sources of Quickly and he started the first version of the app in May 2009. [18:12] In Ubuntu and more generally in GNU/Linux, we have tons of good libraries, rocking technologies and programming languages. [18:13] But there are so many that some times it's difficult to pick "what I should choose". [18:13] Not talking about deprecating technologies that you just discover their current unmaintained state once you have almost finished your apps (libglade, I'm looking at you!) [18:14] So, what's in Quickly? [18:14] Quickly has two parts: the core, which basically parses your input and templates. [18:14] Templates are sets of commands and code generators that are designed to work together in an end to end fashion to help developers write a certain kind of application. [18:15] But we can also imagine a LaTeX template, a template to manage doc… [18:15] A template can be written for using whatever technology in whatever language of your choice. [18:15] for instance, I'm working on a snippet template for awesome Jono's acire app :) [18:16] So, with templates, you can then create application or document set. [18:16] We'll focus there only on i18n with the first template that Quickly 0.2 provides: ubuntu-project (renamed ubuntu-application on the coming 0.4 release!) [18:16] (this template is using Glade, couchdb, has some nice trick for gedit, use bzr, and complete integration with LaunchPad and debian packaging) [18:16] For instance, Lernid that some of you may use to assist UDW, has been created with the ubuntu-project template. (http://www.jonobacon.org/?p=2258 for a shot of the story) [18:17] [SLIDE 4] [18:17] So, let's create first a simple ubuntu-project (assuming you are using Quickly 0.2): [18:17] $ quickly create ubuntu-project fooby [18:17] (assuming also that you successfully installed Quickly and opened a command line ;)) [18:18] this tells Quickly to use the ubuntu-project template, and to call what is created "fooby" [18:18] This causes a bunch of info to be dumped to the command line, but ends with the application being run [18:18] What Quickly did was to copy over basically a sample application, and do some text switcheroos to customize the app [18:18] You can see there the ui which contains some text that needs translation. [18:19] To start making change to your app, cd to it (normally "$ cd fooby"). [18:19] You can then edit your code with $ quickly edit, change the ui with $ quickly glade, and try your changes with $ quickly run [18:19] You can save your change with $ quickly save [18:19] Finally, to package, share, release your apps so that other will be, with the following commands (not all are necessary): $ quickly package / $ quickly share / $ quickly release [18:20] It would ask for minor things that it'll do for you as creating the package, licensing, etc. [18:20] We won't cover in anymore detail Quickly or ubuntu-project template here (quickly help does this for you), you can find more pratical info at: https://wiki.ubuntu.com/MeetingLogs/devweek0909/QuicklyFun [18:21] And a detail review of Quickly there: http://blog.didrocks.fr/index.php/post/Build-your-application-quickly-with-Quickly%3A-part1 (this will kill my local Internet connection as I'm self-hosted ;)) [18:21] You can also appreciate (or not) my French accent and see Rick and myself (jet lagged for my defense) presenting how to create an app with Quickly ubuntu-project template at http://www.youtube.com/watch?v=OOQOzPgLGLg [18:21] It was during last Ubuntu Developer Summit at it's starting at minute 17'. [18:22] David will now present you in more details what you will do in "quickly edit" and "quickly glade": adding internalization support to your app. [18:22] Thanks Didier, I hope this got you all excited about trying out Quickly! [18:23] As the project stands now, it has the infrastructure for internationalization in place, but we have to initialize it to enable it. [18:23] This will include: [18:23] * Initializing gettext [18:23] * Marking strings for translation [18:23] * Updating the translation template [18:23] [SLIDE 5] [18:24] [SLIDE 5] [18:24] First of all, we'll initialize gettext, which will basically be adding four lines of code. Here's how it goes: [18:24] quickly edit [18:24] This will open all your project files in a text editor (Gedit by default) [18:24] 1. Go to the fooby file and add the following two lines below 'import gtk', near the top of the file: [18:24] import gettext [18:24] import locale [18:25] This will import the required modules for internationalization [18:25] 2. Still on the fooby file, add the following line below the 'import logging, optparse' one, near the end of the file: [18:25] gettext.install('fooby', unicode=True) [18:25] This will install the _() function to mark (and call) translations as such in Python’s builtins namespace, based on the 'fooby' domain. The domain basically tells gettext where to load translations from. [18:25] This will also save you to include 'import gettext' statements in all of your project files using gettext. [18:25] Refer to the gettext documentation to find out more about translation domains. [18:26] 3. Finally, add the following line to 'fooby', before the 'builder = gtk.Builder()' line [18:26] locale.textdomain('fooby') [18:26] This will tell GtkBuilder about the translation domain as well [18:26] So that was it! Let's move on to marking strings for translation: [18:26] First of all we'll tackle the .destop file [18:27] Open the fooby.desktop.in file and prepend the Name and comment fields with an underscore (_), so they look like: [18:27] _Name=Fooby [18:27] _Comment=Fooby application [18:27] This will tell intltool that this strings contain translations [18:27] Next comes the UI. Let's see how you can mark strings in the UI for translation. Try: [18:27] quickly glade [18:27] This will open your UI files in the glade editor. [18:28] Once opened, click on the "Your application has been created! ..." label, find it in the General > Label field on the right, click on the ellipsis (the three dots) button and... [18:28] amaze at the fact that it has already been marked as "Translatable", so you won't have to do anything. [18:28] Right, so next comes something very important that you'll have to bear in mind for all strings you'd like to be translatable in your application: [18:28] using the _() function call. [18:28] This will mark them as translatable and call gettext to load the translations, and should be used for all messages you'd like to present to users. [18:29] Let's just see how we can do this. [18:29] Go back to your fooby file and find the "parser.add_option("-v", "--verbose", action="store_true", dest="verbose", help="Show debug messages")" line near the bottom. [18:29] We want the "Show debug messages" message to get shown to users in their language, so we'll enclose it with the _() function, and it will look like: [18:29] parser.add_option("-v", "--verbose", action="store_true", dest="verbose", help=_("Show debug messages")) [18:30] Now we're done [18:30] The last part will be to update the translations template. [18:30] A translations template is a formatted text file generally named yourproject.pot [18:30] which contains your project's translatable strings in English and what translators use as a basis for their translations. [18:30] You should do this before each release, so that translations are put in this template and are up-to-date for translators to work on. [18:30] It is considered good practice to announce a string freeze (that is, the period in which strings are considered to be stable) a week or two before the release, so that translators know when they can start their work. [18:31] This can be done in several ways with quickly, let's pick one: [18:31] quickly package [18:31] After running this, you'll notice that (apart from having your application packaged!) there is a 'po' folder containing the translation template, ready for translators to work on. [18:31] If you open it, you'll notice the format and will see that all the strings you marked for translation are there. [18:31] You can also do this with 'quickly share', 'quickly release' or directly using the python-distutils-extra command: './setup.py build_i18n' [18:32] == Launchpad Translations == [18:32] If this weren't awesome enough, once you've created a project in Launchpad ('quickly share', 'quickly release' or https://help.launchpad.net/ will help you on that) you can expose it for translations, [18:32] so that you as a developer can use the automatic bzr import/export features to basically "forget" about translations and translators can use the web UI to translate. [18:33] Let me tell you a bit more on those: [18:33] [SLIDE 6] [18:33] == Automatic imports == [18:33] Enabling this feature will allow you to automatically import the translation template for your application into Launchpad upon commit, with no further steps required. [18:34] So the basic workflow will be: hack, hack, hack, update template, commit, have translators automagically see the new strings in Launchpad. [18:34] In time, Launchpad Translations will grow the ability to automatically generate the templates, so you won't have to worry about updating it and commit it, but for now, the .pot template has to be kept under revision control. [18:34] You can find more about this at http://blog.launchpad.net/translations/import-translation-templates-from-your-projects-bazaar-branches and http://blog.launchpad.net/general/trying-out-launchpad-translations [18:34] Even better, there's a screencast available showing how to enable this at http://blog.launchpad.net/translations/screencast-importing-translation-templates-from-a-bazaar-branch [18:35] == Automatic exports == [18:35] With automatic exports, you'll be able to complete the whole circle for automation: getting translations committed automatically (daily) to a bzr branch of your choice, so that neither you nor translators have to worry to get translations into your project. [18:35] I personally find this one of the most coolest features [18:35] Here's more info: http://blog.launchpad.net/general/exporting-translations-to-a-bazaar-branch [18:35] And here's a screencast on how to enable it http://blog.launchpad.net/translations/screencast-exporting-translations-to-a-bazaar-branch [18:36] Least but not last, you might also want to find out more on what message sharing is, enabling translations between multiple project series to have strings translated automagically across those series: http://blog.launchpad.net/translations/screencast-sharing-translations-between-releases-of-the-same-project [18:36] == Permissions == [18:36] One very important aspect is how you want translations permissions for your project to be. This basically means choosing who will be responsible for submitting and reviewing those translations for each language. [18:37] Launchpad is flexible in allowing different levels of openness for translating your project. [18:37] This generally means that you as a maintainer will have to make a decision to balance openness (open translations for everyone) with quality control (a more closed process with reviewers and a QA workflow). [18:37] The Launchpad help page on permissions at https://help.launchpad.net/Translations/YourProject/PermissionPolicies explains very well the different permissions you can use (Open, Structured, Restricted and Closed). [18:37] If you decide for quality, you'll next have to choose to whom you assign the translation of your project. [18:38] Here is where translation groups come to the rescue. [18:38] Translation groups are confederations of translation teams, one for each language you can assign as a pack to translate your project. The teams in those groups are considered to be trusted to have experience with translations and generally have a review process in place. [18:38] Here's a list of all current translation groups: https://translations.launchpad.net/+groups [18:39] You can see that the two biggest ones are Launchpad Translators and Ubuntu Translators. [18:39] While you can create a translation group specific to your project, we generally encourage maintainers to choose one of the existing ones, [18:39] in order to reuse the pool of translators and not to further fragment translations communities. [18:39] I personally recommend choosing Restricted (or Structured), assigned to the trusted Launchpad Translators or Ubuntu Translators (if your project is Ubuntu-specific) translations groups [18:39] I'll now leave you in didrocks' good hands to tell you more on Quickly's new to come in the internationalization front: [18:40] * dpm hands the mike to didrocks [18:40] Thanks David, you know that Quickly is using automatic export/import for Quickly itself? That's just awesome, no more to bother about generating templates, uploading them, downloading the localization: just use bzr! [18:40] It's using Restricted permission and we already have a lot of language supported in Quickly thanks to the rocking Launchpad Translator groups :) [18:40] * dpm knew, he's been translating Quickly into Catalan! ;) [18:41] amazing ;) [18:41] (you started it IIRC) [18:41] ;) [18:41] [SLIDE 7] [18:41] Quickly 0.4 will bring a lot of new experiences and commodities to the users (more than 200 commits, 6 months of hard work!) and will be delivered in lucid. [18:42] Regarding internationalization, all the tedious job of importing/initalizing gettext and adding _() will be done for you in all newly created apps. [18:42] (now that I've assisted to the session, will be easier to do the right thing ;)) [18:42] "$ quickly add pythonfile" will also add one boiler plate file containing that for you. [18:42] Quickly 0.6 (don't know when it'll be available but at least in 6 months ;)) will try to achieve the automatic imports and exports previously described on each $ quickly share / $ quickly release command. [18:43] So, normally, you won't have to bother anymore about localization and being in sync with the awesome work of your contributors [18:43] just use _(…) for each string [18:43] I think we should then announce that there won't be any need for such talks in the future, as quickly will do nearly all this for you! [18:43] ok, and that's it for the session, dpm, back on the field to tackle questions? ;) [18:44] sure, didrocks, if you give me a hand with the quickly ones? [18:44] dpm: for great pleasure :) [18:44] with* [18:44] AnAnt> QUESTION: why is it advisable to export to another bzr branch ? [18:44] you can use the main branch if you like [18:45] in fact Lernid does IIRC [18:45] but this adds a lot of automatic commits to the branch [18:45] and not all developers like this [18:45] so they use a separate b ranch for the auto-commits [18:45] of translations [18:45] and then merge those translations back to the main branch when they need to [18:46] e.g before release [18:46] next question? [18:46] look at: https://code.edge.launchpad.net/~quickly/quickly/quickly-po for instance (merged in Quickly trunk before release) :) [18:46] < foobob> QUESTION: any plans to use transifex for the localization of ubuntu? [18:47] that's a bit out of topic, since we're not discussing the translation of Ubuntu - in any case, as awesome as Transifex is, we'll continue using owr own awesome translations tool [18:47] Launchpad Translations [18:47] which has got many features no other tool has [18:47] next questio, please? [18:47] If you asked a question during the class that has not yet been answered, please ask it again. [18:48] < lernid_alucardni> QUESTION: any plans to integrate Quickly with other version control systems such as git? [18:48] lernid_alucardni: Quickly is only the core: so, you can implement your own template using any other vcs [18:48] something like ubuntu-application-with-git :) [18:48] or a better name of course [18:49] but if you want to develop a template with that, you can. Quickly 0.4 is able to import commands from another template [18:49] so, that save a lot of typing and ease your template creations [18:50] I don't personnaly know very well git and I think ubuntu-application user, in the ideal case, don't have to bother with which VCS its using [18:50] also, moving to another VCS means loosing the tight integration with Launchpad :/ [18:50] so, well, it's possible and if you want to give it a try, just go on #quickly, I'll help you to be on the track :) [18:51] next? [18:51] < AnAnt> QUESTION: some projects use XML (rather than po) for translation, is that supported (or will be supported) in Launchpad ? [18:51] Launchpad standardises on the Gettext format, so it does not directly work with xml. That said, [18:52] you can use conversion tools to convert e.g. docbook, xml docs to PO and then import them to Launchpad [18:52] There are some projects which successfully do that [18:52] like for example the ubuntu-dosc [18:52] ubuntu-docs [18:52] also, [18:53] Launchpad is open source, so if anyone is willing to implement other formats [18:53] the developers will be happy to mentor them [18:53] check out [18:53] https://dev.launchpad.net/Getting [18:53] and the session tomorrow on Launchpad translations under the hood [18:54] by adiroiban and henninge [18:54] or you can ask for help on #launchpad-dev [18:54] sorry, I forgot to mention the tool to convert xml to PO [18:54] that's xml2po, available in the main repositories [18:55] and it can convert back to xml once the translations are done [18:55] ok, next question? [18:55] < bullgard47> QUESTION: You showed us wonderful translation tools. Why does a German user still find a lot of untranslated strings in Karmic GNOME programs? [18:56] Well, there's quite a lot of translation work to do to translate a full OS - you can contribute to the German translation by joining the Ubuntu German translations team at https://launchpad.net/~ubuntu-l10n-de [18:56] and they should get you started [18:56] or ask us at #ubuntu-translators [18:57] any quickly-related questions? [18:57] dpm: seems, that people are more focussed on i18n ones ;) You won't get any rest :) [18:57] hehe [18:58] I like that [18:58] oh, I saw that one: [18:58] Nafai | Question: Can quickly be configured to use an editor other than gedit? [18:58] well spotted ;) [18:58] Nafai: yes, you just have to configure it with sensible-editor or export EDITOR variable in your shell [18:58] then, ubuntu-project template will spot your preferred editor with quickly edit [18:58] quickly help edit for more info :) [18:59] < OwaisLone> QUESTION: Any plans for a Quickly API so that it can kinda hooked into IDEs like Anjuta and Geany? [18:59] OwaisLone: yes, it's on the road for 0.4 [19:00] so, you'll get a nice API on lucid version of Quickly :) [19:00] * didrocks taps gavel [19:00] cool, so I think we can just to thank everyone listening to us and participating, you truly rocked! Thanks! [19:00] I think we should leave the field to the next session before being hit :) [19:00] thanks a lot everybody, feel free to ping us and join #quickly }}}