SOURCES: qt4-locale.patch - new, a little bit better locale patch

pascalek pascalek at pld-linux.org
Tue Nov 28 20:02:09 CET 2006


Author: pascalek                     Date: Tue Nov 28 19:02:09 2006 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- new, a little bit better locale patch

---- Files affected:
SOURCES:
   qt4-locale.patch (1.9 -> 1.10) 

---- Diffs:

================================================================
Index: SOURCES/qt4-locale.patch
diff -u SOURCES/qt4-locale.patch:1.9 SOURCES/qt4-locale.patch:1.10
--- SOURCES/qt4-locale.patch:1.9	Wed Oct  4 23:17:38 2006
+++ SOURCES/qt4-locale.patch	Tue Nov 28 20:02:04 2006
@@ -1,17 +1,156 @@
---- qt-copy/tools/assistant/main.cpp.niedakh	2005-05-13 16:39:06.000000000 +0200
-+++ qt-copy/tools/assistant/main.cpp	2005-05-14 14:34:40.000000000 +0200
-@@ -272,11 +272,12 @@
+diff -Nur qt-x11-opensource-src-4.2.1.orig/src/corelib/kernel/qtranslator.cpp qt-x11-opensource-src-4.2.1.chng/src/corelib/kernel/qtranslator.cpp
+--- qt-x11-opensource-src-4.2.1.orig/src/corelib/kernel/qtranslator.cpp	2006-10-20 17:35:15.000000000 +0200
++++ qt-x11-opensource-src-4.2.1.chng/src/corelib/kernel/qtranslator.cpp	2006-11-28 14:17:12.000000000 +0100
+@@ -37,6 +37,7 @@
+ #include "qalgorithms.h"
+ #include "qhash.h"
+ #include "qtranslator_p.h"
++#include <qlibraryinfo.h>
+ 
+ #if defined(Q_OS_UNIX)
+ #define QT_USE_MMAP
+@@ -377,33 +378,72 @@
+     QString delims;
+     delims = search_delimiters.isNull() ? QString::fromLatin1("_.") : search_delimiters;
+ 
+-    for (;;) {
+-        QFileInfo fi;
+-
+-        realname = prefix + fname + (suffix.isNull() ? QString::fromLatin1(".qm") : suffix);
+-        fi.setFile(realname);
+-        if (fi.isReadable())
+-            break;
+-
+-        realname = prefix + fname;
+-        fi.setFile(realname);
+-        if (fi.isReadable())
+-            break;
++    if (directory == QLibraryInfo::location(QLibraryInfo::TranslationsPath)) {
++	QString locale;
++        int idelim = 0, leftmost;
++                    
++        for (;;) {
++    	    leftmost = filename.size();
++            for (int i = 0; i < (int)delims.length(); i++) {
++        	int k = filename.indexOf(delims[i], idelim);
++                if ((k > 0)&&(k < leftmost))
++                leftmost = k;
++            }
++            
++            if (leftmost == filename.size())
++        	return false;
++                                                                                                                                                
++            idelim = leftmost + 1;
++            fname = filename.left(leftmost);
++            locale = filename.mid(leftmost+1);
++            
++            while (!locale.isEmpty()) {
++        	QFileInfo fi;
++                realname = prefix + locale + QString::fromLatin1("/LC_MESSAGES/") +  fname + QString::fromLatin1(".qm");
++                
++                fi.setFile(realname);
++                if (fi.isReadable())
++            	    break;
++                                                                                                                                                                                                                                                                                    
++                int rightmost = 0;
++                for (int i = 0; i < (int)delims.length(); i++) {
++            	    int k = locale.lastIndexOf(delims[i]);
++                    if (k > rightmost)
++                	rightmost = k;
++                }
++                locale.truncate(rightmost);
++            }
++            if (!locale.isEmpty())
++        	break;
++	}
++    } else {
++	for (;;) {
++    	    QFileInfo fi;
++
++    	    realname = prefix + fname + (suffix.isNull() ? QString::fromLatin1(".qm") : suffix);
++    	    fi.setFile(realname);
++    	    if (fi.isReadable())
++        	break;
++
++    	    realname = prefix + fname;
++    	    fi.setFile(realname);
++    	    if (fi.isReadable())
++        	break;
++
++    	    int rightmost = 0;
++    	    for (int i = 0; i < (int)delims.length(); i++) {
++        	int k = fname.lastIndexOf(delims[i]);
++        	if (k > rightmost)
++            	    rightmost = k;
++    	    }
++
++            // no truncations? fail
++    	    if (rightmost == 0)
++    	    return false;
+ 
+-        int rightmost = 0;
+-        for (int i = 0; i < (int)delims.length(); i++) {
+-            int k = fname.lastIndexOf(delims[i]);
+-            if (k > rightmost)
+-                rightmost = k;
++	    fname.truncate(rightmost);
+         }
+-
+-        // no truncations? fail
+-        if (rightmost == 0)
+-            return false;
+-
+-        fname.truncate(rightmost);
+     }
+-
+     // realname is now the fully qualified name of a readable file.
+ 
+     bool ok = false;
+diff -Nur qt-x11-opensource-src-4.2.1.orig/tools/assistant/main.cpp qt-x11-opensource-src-4.2.1.chng/tools/assistant/main.cpp
+--- qt-x11-opensource-src-4.2.1.orig/tools/assistant/main.cpp	2006-10-20 17:35:28.000000000 +0200
++++ qt-x11-opensource-src-4.2.1.chng/tools/assistant/main.cpp	2006-11-28 14:23:03.000000000 +0100
+@@ -310,11 +310,11 @@
          resourceDir = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
  
      QTranslator translator( 0 );
 -    translator.load( QLatin1String("assistant_") + QLocale::system().name(), resourceDir );
-+    QLocale locale = QLocale::system();
-+    translator.load( QLatin1String("assistant"), resourceDir + QLatin1String("/") + QLocale::languageToString(locale.language())  + QLatin1String("/LC_MESSAGES") );
++    translator.load( QLatin1String("qt4-assistant_") + QLocale::system().name(), resourceDir );
      a.installTranslator( &translator );
  
      QTranslator qtTranslator( 0 );
 -    qtTranslator.load( QLatin1String("qt_") + QLocale::system().name(), resourceDir );
-+    qtTranslator.load( QLatin1String("qt4"), resourceDir + QLatin1String("/") + QLocale::languageToString(locale.language()) + QLatin1String("/LC_MESSAGES") );
++    qtTranslator.load( QLatin1String("qt4_") + QLocale::system().name(), resourceDir );
      a.installTranslator( &qtTranslator );
  
      Config *conf = Config::loadConfig( profileName );
+diff -Nur qt-x11-opensource-src-4.2.1.orig/tools/designer/src/designer/qdesigner.cpp qt-x11-opensource-src-4.2.1.chng/tools/designer/src/designer/qdesigner.cpp
+--- qt-x11-opensource-src-4.2.1.orig/tools/designer/src/designer/qdesigner.cpp	2006-10-20 17:35:40.000000000 +0200
++++ qt-x11-opensource-src-4.2.1.chng/tools/designer/src/designer/qdesigner.cpp	2006-11-28 14:22:20.000000000 +0100
+@@ -112,8 +112,8 @@
+ 
+     QTranslator *translator = new QTranslator;
+     QTranslator *qtTranslator = new QTranslator;
+-    translator->load(QLatin1String("designer_") + QLocale::system().name().toLower(), resourceDir);
+-    qtTranslator->load(QLatin1String("qt_") + QLocale::system().name().toLower(), resourceDir);
++    translator->load(QLatin1String("qt4-designer_") + QLocale::system().name(), resourceDir);
++    qtTranslator->load(QLatin1String("qt4_") + QLocale::system().name(), resourceDir);
+     installTranslator(translator);
+     installTranslator(qtTranslator);
+ 
+diff -Nur qt-x11-opensource-src-4.2.1.orig/tools/linguist/linguist/main.cpp qt-x11-opensource-src-4.2.1.chng/tools/linguist/linguist/main.cpp
+--- qt-x11-opensource-src-4.2.1.orig/tools/linguist/linguist/main.cpp	2006-10-20 17:35:26.000000000 +0200
++++ qt-x11-opensource-src-4.2.1.chng/tools/linguist/linguist/main.cpp	2006-11-28 14:21:19.000000000 +0100
+@@ -41,11 +41,11 @@
+     QApplication::setOverrideCursor(Qt::WaitCursor);
+ 
+     QTranslator translator(0);
+-    translator.load(QLatin1String("linguist_") + QLocale::system().name(), ".");
++    translator.load(QLatin1String("qt4-linguist_") + QLocale::system().name(), QLibraryInfo::location(QLibraryInfo::TranslationsPath));
+     app.installTranslator(&translator);
+ 
+     QTranslator qtTranslator(0);
+-    qtTranslator.load(QLatin1String("qt_") + QLocale::system().name(), QLibraryInfo::location(QLibraryInfo::TranslationsPath));
++    qtTranslator.load(QLatin1String("qt4_") + QLocale::system().name(), QLibraryInfo::location(QLibraryInfo::TranslationsPath));
+     app.installTranslator(&qtTranslator);
+ 
+     app.setOrganizationName("Trolltech");
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/SOURCES/qt4-locale.patch?r1=1.9&r2=1.10&f=u



More information about the pld-cvs-commit mailing list