[PC-BSD Commits] r5717 - pcbsd/trunk/XGUISource

svn at pcbsd.org svn at pcbsd.org
Wed Dec 30 10:47:39 PST 2009


Author: kris
Date: 2009-12-30 10:47:39 -0800 (Wed, 30 Dec 2009)
New Revision: 5717

Modified:
   pcbsd/trunk/XGUISource/main.cpp
Log:

Fixed XGUI loading the correct i18n data



Modified: pcbsd/trunk/XGUISource/main.cpp
===================================================================
--- pcbsd/trunk/XGUISource/main.cpp	2009-12-30 18:47:26 UTC (rev 5716)
+++ pcbsd/trunk/XGUISource/main.cpp	2009-12-30 18:47:39 UTC (rev 5717)
@@ -6,6 +6,7 @@
 #include <kcmdlineargs.h>
 #include <qstylefactory.h>
 #include <qdesktopwidget.h>
+#include <QDebug>
 #include "xgui.h"
 #include "dialogconfirm.h"
 
@@ -35,18 +36,21 @@
 
     KApplication a;
 
-    QString locale = KGlobal::locale()->language();
     QTranslator translator;
-    translator.load(QString("XGUISource_") + locale, "/usr/local/kde4/share/apps/pcbsd/i18n/");
-    a.installTranslator(&translator);
+    QLocale mylocale;
+    QString langCode = mylocale.name();
+    if ( ! QFile::exists("/usr/local/kde4/share/apps/pcbsd/i18n/XGUISource_" + langCode + ".qm" ) )
+      langCode.truncate(langCode.indexOf("_"));
+    translator.load( QString("XGUISource_") + langCode, "/usr/local/kde4/share/apps/pcbsd/i18n/" );
+    a.installTranslator( &translator );
+    qDebug() << "Locale:" << langCode;
 
-
     // Check the language we are running in, and set the correct font
-    if (  locale == "zh_CN" ||  locale == "zh_TW" )
+    if (  langCode == "zh_CN" ||  langCode == "zh_TW" )
     {
       QFont f( "mingunittf", 10);
       a.setFont( f);
-    } else if ( locale == "ja" ) {
+    } else if ( langCode == "ja" ) {
       QFont f( "vlgothic", 10);
       a.setFont( f);
     } else {



More information about the Commits mailing list