Translations are not loaded when packaging for extras

Bug #1003818 reported by David Planella
12
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Quickly
Fix Released
Undecided
Unassigned
quickly (Ubuntu)
Fix Released
Undecided
Unassigned
Precise
Fix Released
Undecided
Unassigned

Bug Description

[Impact]

The commands 'quickly package --extras' and 'quickly submitubuntu' do not create debian packages that can load their shipped translations.

So those two commands which are used for ARB submission, will regress translation support compared to normal packages. Since we want to encourage ARB submission where appropriate, having such a bug would be unfortunate.

[Test Case]

cd /tmp
quickly create ubuntu-application ubuapp
# close opened window
cd ubuapp
mkdir po
# Download the attached files 'fr.po', 'POTFILES.in', and 'ubuapp.pot' and put them into po/
quickly package --extras
sudo dpkg -i ../ubuapp_0.1_all.deb
sudo apt-get install language-pack-fr # to create locale
# on 12.04, this is the binary path
LANGUAGE=fr /opt/extras.ubuntu.com/ubuapp/ubuapp/ubuapp
# in my fixed version, this will be the binary path
#LANGUAGE=fr /opt/extras.ubuntu.com/ubuapp/bin/ubuapp

Notice that the title will be "Ubuapp" in the unfixed version. But will be "French Ubuapp" in my fixed version.

[Regression Potential]

My fix carefully only affects the --extras path (which is also used for submitubuntu). I intentionally chose an ugly way to fix this so that I could only affect that path and not regress anything else.

In 12.10, my hope is to eventually implement a non-ugly fix. But I'm confident this will only affect users of --extras.

[Original Report]

Both 'quickly package --extras' and 'quickly submitubuntu' correctly install translations for applications in /opt/extras.ubuntu.com/appname/share/locale.

However, there is an additional step required to make applications to actually use those translations at runtime: use the bindtextdomain() call to specify that they should be loaded from /opt instead of /usr/share/locale.

Quickly's gettext setup is originally:

import gettext
from gettext import gettext as_
gettext.textdomain('appname')

And this should be changed to the following for apps in extras:

TEXTDOMAIN = 'appname'
LOCALEDIR = '/opt/extras.ubuntu.com/appname/share/locale'
import locale
from locale import gettext as _
locale.bindtextdomain(TEXTDOMAIN, LOCALEDIR)
locale.textdomain(TEXTDOMAIN)

Notice the use of the locale module (Python's C gettext API) instead of the gettext module (pure Python gettext API). This is needed to make Gtk.Builder() load translations in /opt.

I wonder whether the gettext initialization could be moved to a single place/module, rather than added to each .py file as it is done now. This would probably help if the implementation of 'quickly package --extras' or 'quickly submitubuntu' would rely on adding a patch to modify those lines of code or simply do text substitution.

This still does not take care of the translations for schemas and PolicyKit files in /opt (they should be filed as separate bugs), but at least gets us 90% there in being able to run localized apps from /opt

See more details on http://askubuntu.com/questions/140552/how-to-make-glade-load-translations-from-opt

ProblemType: Bug
DistroRelease: Ubuntu 12.04
Package: quickly 12.04-0ubuntu1
ProcVersionSignature: Ubuntu 3.2.0-24.37-generic 3.2.14
Uname: Linux 3.2.0-24-generic x86_64
NonfreeKernelModules: nvidia
ApportVersion: 2.0.1-0ubuntu7
Architecture: amd64
Date: Wed May 23 23:35:20 2012
EcryptfsInUse: Yes
InstallationMedia: Ubuntu 11.04 "Natty Narwhal" - Alpha amd64 (20110319)
PackageArchitecture: all
QuicklyDataPath: /usr/share/quickly
QuicklyTemplates:
 /home/dpm/quickly-templates/ubuntu-application-qt
 /usr/share/quickly/templates/unity-lens
 /usr/share/quickly/templates/ubuntu-application
 /usr/share/quickly/templates/ubuntu-flash-game
 /usr/share/quickly/templates/ubuntu-cli
QuicklyTemplatesDirectories:
 /home/dpm/quickly-templates
 /usr/share/quickly/templates/
SourcePackage: quickly
UpgradeStatus: No upgrade log present (probably fresh install)

Related branches

Revision history for this message
David Planella (dpm) wrote :
tags: added: arb
Michael Terry (mterry)
Changed in quickly:
status: New → Fix Committed
Michael Terry (mterry)
Changed in quickly:
milestone: none → 12.05
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package quickly - 12.05-0ubuntu1

---------------
quickly (12.05-0ubuntu1) quantal; urgency=low

  * New upstream release
    - Fix ubuntu-flash-game backend to work (LP: #1007086)
    - For ubuntu-cli and ubuntu-flash-game, don't keep warning about
      upgrading the project to use PyGI, even on fresh projects
      (LP: #1007006)
    - Fix 'package --extras' and 'submitubuntu' to create packages suitable
      for the ARB process again (LP: #1003818, LP: #998910, LP: #1002417)
 -- Michael Terry <email address hidden> Thu, 31 May 2012 15:25:44 -0400

Changed in quickly (Ubuntu):
status: New → Fix Released
Michael Terry (mterry)
Changed in quickly:
status: Fix Committed → Fix Released
Revision history for this message
Michael Terry (mterry) wrote :
description: updated
Revision history for this message
Michael Terry (mterry) wrote :
Revision history for this message
Michael Terry (mterry) wrote :
description: updated
Revision history for this message
Brian Murray (brian-murray) wrote : Please test proposed package

Hello David, or anyone else affected,

Accepted quickly into precise-proposed. The package will build now and be available in a few hours. Please test and give feedback here. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Thank you in advance!

Changed in quickly (Ubuntu Precise):
status: New → Fix Committed
tags: added: verification-needed
Revision history for this message
David Planella (dpm) wrote :

I've tested the precise-proposed package and it fixed the bug for me.

Note that in the test case, it is not necessary to download the attached 'POTFILES.in', and 'ubuapp.pot' files, as they are autogenerated. In fact, it's better not to download 'POTFILES.in' at all, since if python-distutils-extra will behave differently if it finds it. Only 'fr.po' is required.

I did not have to run the step to install the French language pack, as I had it installed it already. In any case, I think 'sudo locale-gen fr' should equally do the trick without having to install the whole langpack.

But apart from that, running 'LANGUAGE=fr /opt/extras.ubuntu.com/ubuapp/bin/ubuapp' gave the expected results and I was greeted with 'French Ubuapp', another proof that the French guys are teking over the Ubuntu desktop :-)

Thanks for the fix!

tags: added: verification-done
removed: verification-needed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package quickly - 12.04-0ubuntu2

---------------
quickly (12.04-0ubuntu2) precise-proposed; urgency=low

  * debian/patches/fix-extras.patch:
    - Fix 'package --extras' and 'submitubuntu' to create packages suitable
      for the ARB process again (LP: #1003818, LP: #998910, LP: #1002417)
  * debian/patches/no-warn-on-fresh-cli.patch:
    - For ubuntu-cli and ubuntu-flash-game, don't keep warning about
      upgrading the project to use PyGI, even on fresh projects
      (LP: #1007006)
  * debian/patches/fix-flash-template.patch:
    - Fix flash game template to still use gtk2, as flash requires that
      (LP: #1007086)
  * debian/control:
    - Depend on webkit-1.0 and gtk-2.0 for above flash change
 -- Michael Terry <email address hidden> Thu, 31 May 2012 16:35:33 -0400

Changed in quickly (Ubuntu Precise):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.