Comment 7 for bug 560956

Revision history for this message
Aisano (info-ais-sanmarino) wrote : Re: wrong language code: eo.utf8

I did a little digging in C++ code and found that the error message ("Wrong language code") is produced in libapt; the problem affects not only synaptic but also its command-line twin "apt-get". The message is produced in "apt-pkg/indexfile.cc" in line 99, in the "pkgIndexFile::CheckLanguageCode()" method. This method's comment does not give a pattern for language codes but a list of "common cases": "de_DE, de_DE@euro, de_DE.UTF-8, de_DE.UTF-8@euro, de_DE.ISO8859-1, tig_ER", adding "more in /etc/gdm/locale.conf" (which I cannot find on my system).

The problem, however, is not in "CheckLanguageCode()" but in the "LanguageCode()" method, which parses the language code from the LANG value (only the result is then checked in "CheckLanguageCode()"). Unless the language is one of "en", "pt", "sv", or "zh" it uses the underscore to extract the language code. With no underscore found it uses the whole value of LANG, including the encoding. The obvious fix would be to look for a period when no underscore is found. I will try if I can get this to work; should not be too hard.