GNOME Bugzilla – Bug 169329
locale prioritisation broken for mime type descriptions
Last modified: 2005-04-04 02:49:58 UTC
1: have en_CA as your locale 2: go into /usr/share/mime/application/octet-stream.xml add these lines: <comment xml:lang="en_CA">correct</comment> <comment xml:lang="en">incorrect</comment> 3: restart nautilus 4: create an empty file 5: go into properties to see "Type: incorrect" This is caused by the language_level function in gnome-vfs-mime-info.c and gnome-vfs-application-registry.c working opposite to how they are documented. /* this gives us a number of the language in the current language list, the higher the number the "better" the translation */ Really, the function returns lower numbers for better results. The attached patch modifies the two uses of this function to behave correctly. Additionally, language_level requires a global variable current_lang to be set. This variable is set from calling gnome_vfs_i18n_get_language_list which in turn calls bonobo_activation_i18n_get_language_list. This function isn't in any header file (gnome-vfs uses it by prototyping it for itself). Calling this function is deprecated since it causes 100k of anonymous memory to be permanently allocated per process. The patch also modifies get_language_list to use g_get_language_names() instead and removes the use of the global variable. See bug 168948 for more information.
Created attachment 38315 [details] [review] mwah.
Removing gnome_vfs_i18n_get_language_list was something I had in mind for 2.12, you beat me to it ;) It can't go in before 2.10 though, maybe your patch would be good for 2.10.1. @@ -639,7 +638,7 @@ /* our language level really sucks and the previous translation was of better language quality so just ignore us */ - previous_key_lang_level > lang_level) { + previous_key_lang_level < lang_level) { return; } Is this hunk enough to fix the bug initially described in this report?
iirc, this is the right chunk to fix that: @@ -338,7 +341,7 @@ MimeEntry *entry; int ret; int depth; - int previous_lang_level = -1; + int previous_lang_level = INT_MAX; entry = g_new0 (MimeEntry, 1); @@ -361,7 +364,8 @@ lang_level = language_level (lang); - if (lang_level > previous_lang_level) { + if (lang_level != -1 && + lang_level < previous_lang_level) { char *comment; comment = handle_simple_string (reader); g_free (entry->description);
there's one problem that i forgot to mention. if you call the old language_level with NULL, then it will return 0. applying this patch fragment without also applying the rest of them will cause the NULL translation (ie: untranslated) to always be counted higher. (since 0 is lower than anything else).
Just commited this, as per Christian's request. Closing.