[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    Some kpersonalizer bugs (and fixes)
From:       Bernhard Rosenkraenzer <bero () redhat ! de>
Date:       2001-07-30 12:01:27
[Download RAW message or body]

When all of kde-i18n is installed, and LANG is set to en_US or C,
kpersonalizer suggests traditional chinese as default language. Looking at
the code, that's because "zh_*C*N.GBxxxx" happens to be the last language
in the list that contains "C". ;)
Fixed by attachment #1.

Also (still at first start, without previous definitions), if LANG is set
to en_US (which is translated to "C"), the default county becomes the
invalid selection "Europe, Central" (contains "C"), LANG=de_AT becomes
Germany ("de") rather than Austria ("at") - the langs variable is read
from locale/l10n/COUNTRY/entry.desktop (where COUNTRY is the first 2
letters of $LANG), and de/entry.desktop doesn't say anything about de_AT,
de_CH or the likes.
COUNTRY should be the part of the the locale after the "_" (if present),
truncated at a "." if present.
Fixed by attachment #2, tested for C, en_US, en_GB, de, de_DE, de_AT,
zh_CN, zh_CN.GB2312 - does the right thing(tm) for each of them.

ok to commit?

LLaP
bero


["kdebase-2.2-localedef.patch" (TEXT/PLAIN)]

--- kdebase/kpersonalizer/kcountrypage.cpp.localedef	Sat Jul 21 04:15:54 2001
+++ kdebase/kpersonalizer/kcountrypage.cpp	Mon Jul 30 13:58:13 2001
@@ -85,14 +85,26 @@
   }
 
   // Highlight the users's language
+  int bestmatch = 0;
+  int best = -1;
   for(int i = 0; i < cb_language->count(); i++)
   {
+    int match=0;
     if(cb_language->tag(i).contains(compare))
-    {
-	cb_language->setCurrentItem(i);
-	locale->setLanguage(cb_language->tag(i));
+	    match++;
+    if(cb_language->tag(i).left(compare.length()) == compare)
+	    match+=10;
+    if(cb_language->tag(i) == compare)
+	    match+=100;
+    if(compare == "en_US" && cb_language->tag(i) == "C")
+	    match+=50;
+    if(match > bestmatch) {
+	    bestmatch=match;
+	    best=i;
     }
   }
+  cb_language->setCurrentItem(best);
+  locale->setLanguage(cb_language->tag(best));
 
   // Highlight the users's country
   for(int i = 0; i < cb_country->count(); i++)

["kdebase-2.2-countrydef.patch" (TEXT/PLAIN)]

--- kdebase/kpersonalizer/kcountrypage.cpp.countrydef	Mon Jul 30 13:18:29 2001
+++ kdebase/kpersonalizer/kcountrypage.cpp	Mon Jul 30 13:55:05 2001
@@ -60,8 +60,17 @@
 
   QString country = config->readEntry(QString::fromLatin1("Country"),
                                       QString::fromLatin1("C"));
-  if(country == QString::fromLatin1("C"))
-    country = QString::fromLatin1(getenv("LANG")).left(2);
+  if(country == QString::fromLatin1("C")) {
+    country = QString::fromLatin1(getenv("LANG"));
+    if(country.contains("_"))
+      country = country.mid(country.find("_")+1);
+    if(country.contains("."))
+      country = country.left(country.find("."));
+    if(country != "C")
+      country = country.lower();
+    if(country == "en") // special-case "en" - should be "en_GB" or "en_US", but \
plain "en" is in use quite often +      country = "C";
+  }
 
   KSimpleConfig ent(locate("locale",
                QString::fromLatin1("l10n/%1/entry.desktop")



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic