[PC-BSD Commits] r6091 - in pcbsd/trunk/pcbsd-netmanager/src: NetworkManagerAdmin NetworkTray ethernetconfig wificonfig

svn at pcbsd.org svn at pcbsd.org
Fri Jan 29 08:48:39 PST 2010


Author: kris
Date: 2010-01-29 08:48:38 -0800 (Fri, 29 Jan 2010)
New Revision: 6091

Modified:
   pcbsd/trunk/pcbsd-netmanager/src/NetworkManagerAdmin/main.cpp
   pcbsd/trunk/pcbsd-netmanager/src/NetworkTray/main.cpp
   pcbsd/trunk/pcbsd-netmanager/src/ethernetconfig/main.cpp
   pcbsd/trunk/pcbsd-netmanager/src/wificonfig/main.cpp
Log:

Fixed i18n for network toolset



Modified: pcbsd/trunk/pcbsd-netmanager/src/NetworkManagerAdmin/main.cpp
===================================================================
--- pcbsd/trunk/pcbsd-netmanager/src/NetworkManagerAdmin/main.cpp	2010-01-29 16:37:22 UTC (rev 6090)
+++ pcbsd/trunk/pcbsd-netmanager/src/NetworkManagerAdmin/main.cpp	2010-01-29 16:48:38 UTC (rev 6091)
@@ -1,5 +1,7 @@
 #include <qtranslator.h>
 #include <qlocale.h>
+#include <QDebug>
+#include <QFile>
 #include <kapplication.h>
 #include <kaboutdata.h>
 #include <kcmdlineargs.h>
@@ -31,14 +33,15 @@
 
     KApplication a;
 
-    QString locale = KGlobal::locale()->language();
     QTranslator translator;
-    translator.load(QString("NetworkManagerAdmin_") + 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/NetworkManagerAdmin_" + langCode + ".qm" ) )
+      langCode.truncate(langCode.indexOf("_"));
+    translator.load( QString("NetworkManagerAdmin_") + langCode, "/usr/local/kde4/share/apps/pcbsd/i18n/" );
+    a.installTranslator( &translator );
+    qDebug() << "Locale:" << langCode;
 
-
-    
-
     NetworkManAdmin w;
 
     w.Init();

Modified: pcbsd/trunk/pcbsd-netmanager/src/NetworkTray/main.cpp
===================================================================
--- pcbsd/trunk/pcbsd-netmanager/src/NetworkTray/main.cpp	2010-01-29 16:37:22 UTC (rev 6090)
+++ pcbsd/trunk/pcbsd-netmanager/src/NetworkTray/main.cpp	2010-01-29 16:48:38 UTC (rev 6091)
@@ -7,6 +7,8 @@
 #include <kuniqueapplication.h>
 #include <kstandarddirs.h>
 #include <QTranslator>
+#include <QDebug>
+#include <QFile>
 #include <qtextcodec.h>
 #include <QLocale>
 
@@ -35,13 +37,18 @@
 
    KApplication a;
 
-   NetworkTray tray;
 
-   QString locale = KGlobal::locale()->language();
    QTranslator translator;
-   translator.load(QString("NetworkTray_") + 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/NetworkTray_" + langCode + ".qm" ) )
+     langCode.truncate(langCode.indexOf("_"));
+   translator.load( QString("NetworkTray_") + langCode, "/usr/local/kde4/share/apps/pcbsd/i18n/" );
+   a.installTranslator( &translator );
+   qDebug() << "Locale:" << langCode;
 
+   NetworkTray tray;
+
    //a.setMainWidget(tray.contextMenu());
    a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
 

Modified: pcbsd/trunk/pcbsd-netmanager/src/ethernetconfig/main.cpp
===================================================================
--- pcbsd/trunk/pcbsd-netmanager/src/ethernetconfig/main.cpp	2010-01-29 16:37:22 UTC (rev 6090)
+++ pcbsd/trunk/pcbsd-netmanager/src/ethernetconfig/main.cpp	2010-01-29 16:48:38 UTC (rev 6091)
@@ -30,6 +30,8 @@
 #include <klocale.h>
 #include <kstandarddirs.h>
 #include <QLocale>
+#include <QDebug>
+#include <QFile>
 #include <qtranslator.h>
 #include <qdesktopwidget.h>
 #include <qtextcodec.h>
@@ -61,18 +63,19 @@
 
     KApplication app;
 
+    QTranslator translator;
+    QLocale mylocale;
+    QString langCode = mylocale.name();
+    if ( ! QFile::exists("/usr/local/kde4/share/apps/pcbsd/i18n/ethernetconfig_" + langCode + ".qm" ) )
+      langCode.truncate(langCode.indexOf("_"));
+    translator.load( QString("ethernetconfig_") + langCode, "/usr/local/kde4/share/apps/pcbsd/i18n/" );
+    app.installTranslator( &translator );
+    qDebug() << "Locale:" << langCode;
 
 
-
-
     ethernetconfig *mainWin = 0;
 
-    QString locale = KGlobal::locale()->language();
-    QTranslator translator;
-    translator.load(QString("ethernetconfig_") + locale, "/usr/local/kde4/share/apps/pcbsd/i18n/");
-    app.installTranslator(&translator);
 
-
      // no session.. just start up normally
      KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
      mainWin = new ethernetconfig();

Modified: pcbsd/trunk/pcbsd-netmanager/src/wificonfig/main.cpp
===================================================================
--- pcbsd/trunk/pcbsd-netmanager/src/wificonfig/main.cpp	2010-01-29 16:37:22 UTC (rev 6090)
+++ pcbsd/trunk/pcbsd-netmanager/src/wificonfig/main.cpp	2010-01-29 16:48:38 UTC (rev 6091)
@@ -4,6 +4,7 @@
 #include <qtranslator.h>
 #include <kstandarddirs.h>
 #include <qtextcodec.h>
+#include <QDebug>
 #include "wificonfigwidgetbase.h"
 #include "ui_wificonfigwidgetbase.h"
 
@@ -33,10 +34,14 @@
 
     KApplication a;
 
-    QString locale = KGlobal::locale()->language();
     QTranslator translator;
-    translator.load(QString("wificonfig_") + 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/wificonfig_" + langCode + ".qm" ) )
+      langCode.truncate(langCode.indexOf("_"));
+    translator.load( QString("wificonfig_") + langCode, "/usr/local/kde4/share/apps/pcbsd/i18n/" );
+    a.installTranslator( &translator );
+    qDebug() << "Locale:" << langCode;
 
     wificonfigwidgetbase w;
     //a.setMainWidget(&w);



More information about the Commits mailing list