localization support under ubuntu

Mathias Broxvall mathias.broxvall at gmail.com
Thu Sep 27 18:51:21 BST 2007


Hi,

I am the main developer of trackballs, a quite popular OpenSource  
arcade style game, and have encountered a number of problems with  
localization support which seem to be specific to Ubuntu based  
distributions (I have tested both Dapper and Feisty and noted  
problems). The major problem is that the gettext function fails to  
find any localization strings under circumstances which have  
previously worked with other linux distributions (Gentoo,  
RedHat,Mandrake).

To illustrate my problem, please take a look at the following code  
snippet (apologies for spamming you with so many logs)

   printf("setlocale\n");
   setlocale(LC_MESSAGES,"sv_SE.utf8");
   printf("binding to: %s\n",localedir);
   bindtextdomain(PACKAGE,localedir);
   printf("textdomain: %s\n",PACKAGE);
   textdomain(PACKAGE);
   printf("setlocale\n");
   setlocale(LC_MESSAGES,"sv_SE");
   printf(_("Important keyboard shortcuts\n"));

which yields the following OS calls

$ strace ./trackballs
... snip ...
write(1, "setlocale\n", 10setlocale)             = 10
open("/usr/lib/locale/sv_SE.utf8/LC_MESSAGES", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
close(3)                                = 0
open("/usr/lib/locale/sv_SE.utf8/LC_MESSAGES/SYS_LC_MESSAGES",  
O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/locale/sv_SE/LC_MESSAGES", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
close(3)                                = 0
open("/usr/lib/locale/sv_SE/LC_MESSAGES/SYS_LC_MESSAGES", O_RDONLY) =  
-1 ENOENT (No such file or directory)
open("/usr/lib/locale/sv.utf8/LC_MESSAGES", O_RDONLY) = -1 ENOENT (No  
such file or directory)
open("/usr/lib/locale/sv/LC_MESSAGES", O_RDONLY) = -1 ENOENT (No such  
file or directory)
open("/usr/share/locale-langpack/sv_SE.utf8/LC_MESSAGES", O_RDONLY) =  
-1 ENOENT (No such file or directory)
open("/usr/share/locale-langpack/sv_SE/LC_MESSAGES", O_RDONLY) = -1  
ENOENT (No such file or directory)
open("/usr/share/locale-langpack/sv.utf8/LC_MESSAGES", O_RDONLY) = -1  
ENOENT (No such file or directory)
open("/usr/share/locale-langpack/sv/LC_MESSAGES", O_RDONLY) = -1  
ENOENT (No such file or directory)
write(1, "binding to: /usr/local/share/loc"..., 36binding to: /usr/ 
local/share/local) = 36
write(1, "textdomain: trackballs\n", 23textdomain: trackballs) = 23
write(1, "setlocale\n", 10setlocale)             = 10
open("/usr/local/share/locale/en_US.UTF-8/LC_MESSAGES/trackballs.mo",  
O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/local/share/locale/en_US.utf8/LC_MESSAGES/trackballs.mo",  
O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/local/share/locale/en_US/LC_MESSAGES/trackballs.mo",  
O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/local/share/locale/en.UTF-8/LC_MESSAGES/trackballs.mo",  
O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/local/share/locale/en.utf8/LC_MESSAGES/trackballs.mo",  
O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/local/share/locale/en/LC_MESSAGES/trackballs.mo",  
O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale-langpack/en_US.UTF-8/LC_MESSAGES/ 
trackballs.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale-langpack/en_US.utf8/LC_MESSAGES/ 
trackballs.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale-langpack/en_US/LC_MESSAGES/trackballs.mo",  
O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale-langpack/en.UTF-8/LC_MESSAGES/trackballs.mo",  
O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale-langpack/en.utf8/LC_MESSAGES/trackballs.mo",  
O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale-langpack/en/LC_MESSAGES/trackballs.mo",  
O_RDONLY) = -1 ENOENT (No such file or directory)
write(1, "Important keyboard shortcuts\n", 29Important keyboard  
shortcuts

The thing which is confusing here, is that before the custom command  
to set the bindtextdomain call, the custom sv_SE directories are  
searched but with the wrong package. However, after setting the  
bindtextdomain call, then en_US is used as the locale...

I have a vague memory about reading about a patch to the  
bindtextdomain function in glibc in ubuntu, as a way to hard-code  
applications to use .mo files under /usr/share/locale-langpack -  
probably in the intent of simplifying the creation of "packages" of  
language support files. Could anyone confirm that this is the case?  
And if so, is there any way to access the "normal" bindtextdomain  
function?

If anyone could either confirm or deny that there is some ubuntu  
specific way of handling i18n it would be very helpful. This is a  
problem that I have been stuck on for a long time, and since I don't  
have access to any non ubuntu based machines it is preventing me from  
testing and supporting i18n in the game.

many thanks in advance

/ Mathias Broxvall

PS. See also trackballs.sourceforge.net if interested




More information about the ubuntu-devel mailing list