Public bug reported: Binary package hint: language-selector-qt
Hello, I am a Turkish user of Ubuntu Hardy and I have noticed that qt-language-selector does not start in the Turkish locale. Here are what I found out and a fix for this problem. qt-language-selector crashes when it is started in locales that 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-selector. (Please note that you will be unable to change your default locale using qt-language-selector afterwards unless you apply the attached patch.) 2) [The safer method] Modify /usr/share/locale/"your locale name"/LC_MESSAGES/iso_639.mo 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/locale/de/LC_MESSAGES # 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-selector --mode select ### Realize that qt-language-selector crashes... ================================================== Here is the trace of the crash of qt-language-selector 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/qt-language-selector", line 29, in <module> lc = QtLanguageSelector(app, "/usr/share/language-selector/", sys.argv[2]) File "/usr/lib/python2.5/site-packages/LanguageSelector/qt/QtLanguageSelector.py", line 43, in __init__ self.init() File "/usr/lib/python2.5/site-packages/LanguageSelector/qt/QtLanguageSelector.py", line 77, in init self.updateLanguagesList() File "/usr/lib/python2.5/site-packages/LanguageSelector/qt/QtLanguageSelector.py", line 120, in updateLanguagesList languages.sort() 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/pyshared/LanguageSelector/qt/QtLanguageSelector.py" ================================================== 116 self._localeinfo.listviewStrToLangInfoMap = {} 117 for lang in languageList: 118 self._localeinfo.listviewStrToLangInfoMap[lang.language] = lang 119 languages = self._localeinfo.listviewStrToLangInfoMap.keys() 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/pyshared/LanguageSelector/qt/QtLanguageSelector.py": ================================================== 99 for locale in self._localeinfo.generated_locales(): 100 name = utf8(self._localeinfo.translate(locale)) 101 locales.append(name) 102 self._localeinfo.localeToCodeMap[name] = locale ================================================== 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 ** Affects: language-selector (Ubuntu) Importance: Undecided Status: New -- [PATCH] qt-language-selector crashes during startup in certain locales https://bugs.launchpad.net/bugs/266971 You received this bug notification because you are a member of Ubuntu Bugs, which is subscribed to Ubuntu. -- ubuntu-bugs mailing list ubuntu-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs