mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-04 21:27:58 +02:00
Merge pull request #141 from lliehu/crash-reporter-i18n-fix
Fix showing of translations in crash reporter
This commit is contained in:
@@ -17,6 +17,8 @@ SET( TOMAHAWK_VERSION_PATCH 99 )
|
|||||||
|
|
||||||
#SET( TOMAHAWK_VERSION_RC 0 )
|
#SET( TOMAHAWK_VERSION_RC 0 )
|
||||||
|
|
||||||
|
SET( TOMAHAWK_TRANSLATION_LANGUAGES ar bg ca de en es fi fr ja pl pt_BR ru sv tr zh_CN zh_TW )
|
||||||
|
|
||||||
# enforce proper symbol exporting on all platforms
|
# enforce proper symbol exporting on all platforms
|
||||||
add_definitions( "-fvisibility=hidden" )
|
add_definitions( "-fvisibility=hidden" )
|
||||||
# enforce using constBegin, constEnd for const-iterators
|
# enforce using constBegin, constEnd for const-iterators
|
||||||
|
@@ -155,7 +155,7 @@ INCLUDE(GNUInstallDirs)
|
|||||||
|
|
||||||
# translations
|
# translations
|
||||||
include( ${CMAKE_SOURCE_DIR}/lang/translations.cmake )
|
include( ${CMAKE_SOURCE_DIR}/lang/translations.cmake )
|
||||||
add_tomahawk_translations(ar bg ca de en es fi fr ja pl pt_BR ru sv tr zh_CN zh_TW)
|
add_tomahawk_translations( ${TOMAHAWK_TRANSLATION_LANGUAGES} )
|
||||||
|
|
||||||
SET( final_src ${final_src} ${tomahawkMoc} ${tomahawkSources} ${trans_outfile})
|
SET( final_src ${final_src} ${tomahawkMoc} ${tomahawkSources} ${trans_outfile})
|
||||||
|
|
||||||
|
@@ -146,47 +146,7 @@ TomahawkApp::TomahawkApp( int& argc, char *argv[] )
|
|||||||
setApplicationVersion( QLatin1String( TOMAHAWK_VERSION ) );
|
setApplicationVersion( QLatin1String( TOMAHAWK_VERSION ) );
|
||||||
|
|
||||||
registerMetaTypes();
|
registerMetaTypes();
|
||||||
installTranslator();
|
TomahawkUtils::installTranslator(this);
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
TomahawkApp::installTranslator()
|
|
||||||
{
|
|
||||||
#if QT_VERSION >= 0x040800
|
|
||||||
QString locale = QLocale::system().uiLanguages().first().replace( "-", "_" );
|
|
||||||
#else
|
|
||||||
QString locale = QLocale::system().name();
|
|
||||||
#endif
|
|
||||||
if ( locale == "C" )
|
|
||||||
locale = "en";
|
|
||||||
|
|
||||||
// Tomahawk translations
|
|
||||||
QTranslator* translator = new QTranslator( this );
|
|
||||||
if ( translator->load( QString( ":/lang/tomahawk_" ) + locale ) )
|
|
||||||
{
|
|
||||||
tDebug( LOGVERBOSE ) << "Translation: Tomahawk: Using system locale:" << locale;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
tDebug( LOGVERBOSE ) << "Translation: Tomahawk: Using default locale, system locale one not found:" << locale;
|
|
||||||
translator->load( QString( ":/lang/tomahawk_en" ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
TOMAHAWK_APPLICATION::installTranslator( translator );
|
|
||||||
|
|
||||||
// Qt translations
|
|
||||||
translator = new QTranslator( this );
|
|
||||||
if ( translator->load( QString( ":/lang/qt_" ) + locale ) )
|
|
||||||
{
|
|
||||||
tDebug( LOGVERBOSE ) << "Translation: Qt: Using system locale:" << locale;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
tDebug( LOGVERBOSE ) << "Translation: Qt: Using default locale, system locale one not found:" << locale;
|
|
||||||
}
|
|
||||||
|
|
||||||
TOMAHAWK_APPLICATION::installTranslator( translator );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -115,7 +115,6 @@ private slots:
|
|||||||
void accountManagerReady();
|
void accountManagerReady();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void installTranslator();
|
|
||||||
void registerMetaTypes();
|
void registerMetaTypes();
|
||||||
|
|
||||||
void printHelp();
|
void printHelp();
|
||||||
|
@@ -16,7 +16,11 @@ INCLUDE( ${QT_USE_FILE} )
|
|||||||
INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR} ../../libtomahawk )
|
INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR} ../../libtomahawk )
|
||||||
ADD_DEFINITIONS( ${QT_DEFINITIONS} )
|
ADD_DEFINITIONS( ${QT_DEFINITIONS} )
|
||||||
|
|
||||||
ADD_EXECUTABLE( tomahawk_crash_reporter WIN32 ${crashreporter_SOURCES} ${crashreporter_HEADERS_MOC} ${crashreporter_UI_HEADERS} ${crashreporter_RC_RCC} )
|
# translations
|
||||||
|
include( ${CMAKE_SOURCE_DIR}/lang/translations.cmake )
|
||||||
|
add_tomahawk_translations( ${TOMAHAWK_TRANSLATION_LANGUAGES} )
|
||||||
|
|
||||||
|
ADD_EXECUTABLE( tomahawk_crash_reporter WIN32 ${crashreporter_SOURCES} ${crashreporter_HEADERS_MOC} ${crashreporter_UI_HEADERS} ${crashreporter_RC_RCC} ${trans_outfile} )
|
||||||
TARGET_LINK_LIBRARIES( tomahawk_crash_reporter ${QT_LIBRARIES} tomahawklib )
|
TARGET_LINK_LIBRARIES( tomahawk_crash_reporter ${QT_LIBRARIES} tomahawklib )
|
||||||
set_target_properties( tomahawk_crash_reporter PROPERTIES AUTOMOC ON)
|
set_target_properties( tomahawk_crash_reporter PROPERTIES AUTOMOC ON)
|
||||||
install(TARGETS tomahawk_crash_reporter RUNTIME DESTINATION ${CMAKE_INSTALL_LIBEXECDIR})
|
install(TARGETS tomahawk_crash_reporter RUNTIME DESTINATION ${CMAKE_INSTALL_LIBEXECDIR})
|
||||||
|
@@ -18,6 +18,8 @@
|
|||||||
|
|
||||||
#include "CrashReporter.h"
|
#include "CrashReporter.h"
|
||||||
|
|
||||||
|
#include "utils/TomahawkUtils.h"
|
||||||
|
|
||||||
#include <QTranslator>
|
#include <QTranslator>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@@ -36,12 +38,7 @@ int main( int argc, char* argv[] )
|
|||||||
|
|
||||||
QApplication app( argc, argv );
|
QApplication app( argc, argv );
|
||||||
|
|
||||||
QString langCode;
|
TomahawkUtils::installTranslator(&app);
|
||||||
QTranslator translatorApp;
|
|
||||||
QTranslator translatorQt;
|
|
||||||
|
|
||||||
/* app.installTranslator( &translatorApp );
|
|
||||||
app.installTranslator( &translatorQt );*/
|
|
||||||
|
|
||||||
if ( app.arguments().size() != 4 )
|
if ( app.arguments().size() != 4 )
|
||||||
{
|
{
|
||||||
|
@@ -46,6 +46,7 @@
|
|||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
#include <QCryptographicHash>
|
#include <QCryptographicHash>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
|
#include <QTranslator>
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
@@ -773,6 +774,44 @@ crash()
|
|||||||
*a = 1;
|
*a = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
installTranslator(QObject* parent)
|
||||||
|
{
|
||||||
|
#if QT_VERSION >= 0x040800
|
||||||
|
QString locale = QLocale::system().uiLanguages().first().replace( "-", "_" );
|
||||||
|
#else
|
||||||
|
QString locale = QLocale::system().name();
|
||||||
|
#endif
|
||||||
|
if ( locale == "C" )
|
||||||
|
locale = "en";
|
||||||
|
|
||||||
|
// Tomahawk translations
|
||||||
|
QTranslator* translator = new QTranslator( parent );
|
||||||
|
if ( translator->load( QString( ":/lang/tomahawk_" ) + locale ) )
|
||||||
|
{
|
||||||
|
tDebug( LOGVERBOSE ) << "Translation: Tomahawk: Using system locale:" << locale;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tDebug( LOGVERBOSE ) << "Translation: Tomahawk: Using default locale, system locale one not found:" << locale;
|
||||||
|
translator->load( QString( ":/lang/tomahawk_en" ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
QCoreApplication::installTranslator( translator );
|
||||||
|
|
||||||
|
// Qt translations
|
||||||
|
translator = new QTranslator( parent );
|
||||||
|
if ( translator->load( QString( ":/lang/qt_" ) + locale ) )
|
||||||
|
{
|
||||||
|
tDebug( LOGVERBOSE ) << "Translation: Qt: Using system locale:" << locale;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tDebug( LOGVERBOSE ) << "Translation: Qt: Using default locale, system locale one not found:" << locale;
|
||||||
|
}
|
||||||
|
|
||||||
|
QCoreApplication::installTranslator( translator );
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
verifyFile( const QString& filePath, const QString& signature )
|
verifyFile( const QString& filePath, const QString& signature )
|
||||||
|
@@ -212,6 +212,8 @@ namespace TomahawkUtils
|
|||||||
DLLEXPORT QList< Tomahawk::query_ptr > mergePlaylistChanges( const QList< Tomahawk::query_ptr >& orig, const QList< Tomahawk::query_ptr >& newTracks, bool& changed );
|
DLLEXPORT QList< Tomahawk::query_ptr > mergePlaylistChanges( const QList< Tomahawk::query_ptr >& orig, const QList< Tomahawk::query_ptr >& newTracks, bool& changed );
|
||||||
|
|
||||||
DLLEXPORT void crash();
|
DLLEXPORT void crash();
|
||||||
|
|
||||||
|
DLLEXPORT void installTranslator(QObject *parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // TOMAHAWKUTILS_H
|
#endif // TOMAHAWKUTILS_H
|
||||||
|
Reference in New Issue
Block a user