[PATCH] qt-language-selector crashes during startup in certain locales
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
language-selector (Ubuntu) |
Fix Released
|
Undecided
|
Jonathan Riddell |
Bug Description
Binary package hint: language-
Hello,
I am a Turkish user of Ubuntu Hardy and I have noticed that
qt-language-
Here are what I found out and a fix for this problem.
qt-language-
do not have translations for certain locales whose names contain
UTF-8 characters. This happens because if the locale names with
the mentioned characteristics do not have translations, they are not
defined as UTF-8 strings and hence cause problems when one tries
to operate on them. (Such as trying to sort them.)
There are two ways to reproduce this problem:
1) Switch your default locale to Turkish and reboot.
Then start qt-language-
you will be unable to change your default locale using
qt-language-
attached patch.)
2) [The safer method] Modify
/usr/
using msgunfmt and msgfmt so that the following locale name
translation is removed from that file:
msgid "Norwegian Bokmål; Bokmål, Norwegian"
Since the second way is safer, I will demonstrate that one.
Steps to reproduce are as follows:
(I am assuming that you are using the German locale.)
=======
$ sudo su -
# cd /usr/share/
# cp iso_639.mo iso_639.orig.mo
# msgunfmt iso_639.mo > iso_639.txt
# nano iso_639.txt
### Remove the following two lines from that file:
### msgid "Norwegian Bokmål; Bokmål, Norwegian"
### msgstr "Buch-Norwegisch"
# msgfmt -o iso_639.mo iso_639.txt
# exit
$ sudo qt-language-
### Realize that qt-language-
=======
Here is the trace of the crash of qt-language-
after these steps have been carried out. This is
what is seen in locales that do not have translations
for that Norwegian locale name. To be specific, this
applies to the Turkish locale too.
=======
Traceback (most recent call last):
File "/usr/bin/
lc = QtLanguageSelec
File "/usr/lib/
self.init()
File "/usr/lib/
self.
File "/usr/lib/
languages.
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 3: ordinal not in range(128)
=======
This happens because the locale names that haven't been processed by
gettext are stored as regular ASCII labels in QtLanguageSelector.
Here is an excerpt from
"/usr/share/
=======
116 self._localeinf
117 for lang in languageList:
118 self._localeinf
119 languages = self._localeinf
120 languages.sort()
=======
As you can see on line 118, the locale name ("lang.language") is
utilized as a regular ASCII string for a key of the dictionary even
though it may contain UTF-8 characters. This causes problems when
".sort()" is called on the keys on line 120 if some keys contain
UTF-8 characters.
The inspiration for the fix of this problem comes from the following
lines in "/usr/share/
=======
99 for locale in self._localeinf
100 name = utf8(self.
101 locales.
102 self._localeinf
=======
As you can see, the "utf8()" function was used in line 100.
Hence, the fix for the mentioned bug also uses the "utf8()" function.
Attached is the patch which fixes this bug.
Regards,
M. Vefa Bicakci
Changed in language-selector: | |
assignee: | nobody → jr |
Changed in language-selector: | |
status: | Confirmed → Fix Committed |
I actually came up with the same patch, not knowing about this bug ID until using the "harvest" webapp (see bug #272405).