From dffde3af3d3dace6cb9d2d9fcfe249c285af64b2 Mon Sep 17 00:00:00 2001 From: Christian Hohnstaedt Date: Thu, 13 May 2010 11:05:29 +0200 Subject: [PATCH] add QT internal translations - currently german, spanish and russian is supported - drop W32 workaround for locale detection. QT does it correctly now. - add search-path for qt_*.qm --- INSTALL.w32 | 4 ++++ Makefile | 3 +-- lib/main.cpp | 37 ++++++++++++++++++------------------- misc/xca.nsi | 7 ++++++- 4 files changed, 29 insertions(+), 22 deletions(-) diff --git a/INSTALL.w32 b/INSTALL.w32 index 34e13437..ca70d1ff 100644 --- a/INSTALL.w32 +++ b/INSTALL.w32 @@ -78,9 +78,13 @@ Fix the missing System.dll in /usr/share/nsis/Plugins by copying it from an NSIS windows installation. Get the mingw runtime lib: $ zcat /usr/share/doc/mingw32-runtime/mingwm10.dll.gz >mingwm10.dll + get the precompiled db_dump.exe from an other XCA installation $ cp db_dump.exe xca-w32 +translate the QT language files +$ lrelease-qt4 ../qt/4.6.2/translations/qt_*.ts + create the setup.exe $ make setup.exe diff --git a/Makefile b/Makefile index ee30f267..a6defc30 100644 --- a/Makefile +++ b/Makefile @@ -44,7 +44,7 @@ pheaders: headers clean: for x in $(SUBDIRS) $(CLEANDIRS); do $(MAKE) -C $${x} clean; done - rm -f *~ xca$(SUFFIX) xca.o + rm -f *~ xca$(SUFFIX) xca.o setup_xca*.exe distclean: for x in $(SUBDIRS) $(CLEANDIRS); do $(MAKE) -C $${x} distclean; done @@ -74,7 +74,6 @@ setup.exe: xca$(SUFFIX) misc/xca.nsi doc lang $(STRIP) xca$(SUFFIX) $(MAKENSIS) -DINSTALLDIR=$(INSTALL_DIR) -DQTDIR=$(QTDIR) \ -DVERSION=$(VERSION) -DBDIR=$(BDIR) -NOCD -V2 misc/xca.nsi - cp setup.exe setup_xca-$(VERSION).exe .PHONY: $(SUBDIRS) $(INSTDIR) xca.app setup.exe doc lang diff --git a/lib/main.cpp b/lib/main.cpp index 1775d969..c8e784bf 100644 --- a/lib/main.cpp +++ b/lib/main.cpp @@ -20,30 +20,29 @@ int main( int argc, char *argv[] ) { int ret = 0, pkictr; QString locale; - QTranslator qtTr( 0 ); - QTranslator xcaTr( 0 ); + QTranslator qtTr; + QTranslator xcaTr; MainWindow *mw; QApplication a( argc, argv ); -#ifdef WIN32 - LANGID LangId = PRIMARYLANGID(GetUserDefaultLangID()); - switch (LangId) { - case 0x07: locale="de"; break; //German - case 0x0a: locale="es"; break; //Spanish - case 0x0b: locale="fi"; break; //Finn - case 0x0c: locale="fr"; break; //French - case 0x0e: locale="hu"; break; //Hungarian - case 0x19: locale="ru"; break; //Russian - default: locale="c"; - } -#else locale = QLocale::system().name(); -#endif - qtTr.load( QString( "qt_" ) + locale, "." ); - xcaTr.load( QString( "xca_" ) + locale, getPrefix() ); - a.installTranslator( &qtTr ); - a.installTranslator( &xcaTr ); + QStringList dirs; + dirs << getPrefix() + << "/usr/local/share/qt4/translations/" + << "/usr/share/qt4/translations/" + << "/usr/share/qt/translations/" + << "."; + + foreach(QString dir, dirs) { + if (qtTr.load(QString("qt_%1").arg(locale), dir)) { + break; + } + } + xcaTr.load(QString("xca_%1").arg(locale), getPrefix()); + + a.installTranslator(&qtTr); + a.installTranslator(&xcaTr); #ifdef Q_WS_MAC QStringList libp = a.libraryPaths(); diff --git a/misc/xca.nsi b/misc/xca.nsi index 37dd6145..72d01c54 100755 --- a/misc/xca.nsi +++ b/misc/xca.nsi @@ -5,7 +5,7 @@ ; The name of the installer Name "XCA" Caption "XCA ${VERSION} Setup" -OutFile "setup.exe" +OutFile "setup_xca-${VERSION}.exe" InstallDir $PROGRAMFILES\xca ; Registry key to check for directory (so if you install again, it will @@ -71,6 +71,11 @@ Section "xca (required)" SecMain File "${QTDIR}\bin\QtGui4.dll" File "${QTDIR}\bin\QtCore4.dll" + File "${QTDIR}\bin\libgcc_s_dw2-1.dll" + + File "${QTDIR}\translations\qt_de.qm" + File "${QTDIR}\translations\qt_es.qm" + File "${QTDIR}\translations\qt_ru.qm" File "${INSTALLDIR}\bin\libltdl-7.dll" File "${INSTALLDIR}\bin\libeay32.dll"