mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-20 07:49:42 +01:00
Merge pull request #141 from lliehu/crash-reporter-i18n-fix
Fix showing of translations in crash reporter
This commit is contained in:
commit
bac515990f
@ -17,6 +17,8 @@ SET( TOMAHAWK_VERSION_PATCH 99 )
|
||||
|
||||
#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
|
||||
add_definitions( "-fvisibility=hidden" )
|
||||
# enforce using constBegin, constEnd for const-iterators
|
||||
|
@ -155,7 +155,7 @@ INCLUDE(GNUInstallDirs)
|
||||
|
||||
# translations
|
||||
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})
|
||||
|
||||
|
@ -146,47 +146,7 @@ TomahawkApp::TomahawkApp( int& argc, char *argv[] )
|
||||
setApplicationVersion( QLatin1String( TOMAHAWK_VERSION ) );
|
||||
|
||||
registerMetaTypes();
|
||||
installTranslator();
|
||||
}
|
||||
|
||||
|
||||
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 );
|
||||
TomahawkUtils::installTranslator(this);
|
||||
}
|
||||
|
||||
|
||||
|
@ -115,7 +115,6 @@ private slots:
|
||||
void accountManagerReady();
|
||||
|
||||
private:
|
||||
void installTranslator();
|
||||
void registerMetaTypes();
|
||||
|
||||
void printHelp();
|
||||
|
@ -16,7 +16,11 @@ INCLUDE( ${QT_USE_FILE} )
|
||||
INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR} ../../libtomahawk )
|
||||
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 )
|
||||
set_target_properties( tomahawk_crash_reporter PROPERTIES AUTOMOC ON)
|
||||
install(TARGETS tomahawk_crash_reporter RUNTIME DESTINATION ${CMAKE_INSTALL_LIBEXECDIR})
|
||||
|
@ -18,6 +18,8 @@
|
||||
|
||||
#include "CrashReporter.h"
|
||||
|
||||
#include "utils/TomahawkUtils.h"
|
||||
|
||||
#include <QTranslator>
|
||||
|
||||
#include <iostream>
|
||||
@ -36,12 +38,7 @@ int main( int argc, char* argv[] )
|
||||
|
||||
QApplication app( argc, argv );
|
||||
|
||||
QString langCode;
|
||||
QTranslator translatorApp;
|
||||
QTranslator translatorQt;
|
||||
|
||||
/* app.installTranslator( &translatorApp );
|
||||
app.installTranslator( &translatorQt );*/
|
||||
TomahawkUtils::installTranslator(&app);
|
||||
|
||||
if ( app.arguments().size() != 4 )
|
||||
{
|
||||
|
@ -46,6 +46,7 @@
|
||||
#include <QMutex>
|
||||
#include <QCryptographicHash>
|
||||
#include <QProcess>
|
||||
#include <QTranslator>
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
#include <windows.h>
|
||||
@ -773,6 +774,44 @@ crash()
|
||||
*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
|
||||
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 void crash();
|
||||
|
||||
DLLEXPORT void installTranslator(QObject *parent);
|
||||
}
|
||||
|
||||
#endif // TOMAHAWKUTILS_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user