mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-10 23:07:59 +00:00
Improved UI translation (Thanks Владимир Головнёв)
This commit is contained in:
parent
370b986ab1
commit
015bdc7930
10
src/main.cpp
10
src/main.cpp
@ -31,6 +31,7 @@
|
|||||||
#include <QLocale>
|
#include <QLocale>
|
||||||
#include <QTranslator>
|
#include <QTranslator>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
#include <QLibraryInfo>
|
||||||
|
|
||||||
#ifndef DISABLE_GUI
|
#ifndef DISABLE_GUI
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
@ -196,11 +197,20 @@ int main(int argc, char *argv[]){
|
|||||||
|
|
||||||
// Load translation
|
// Load translation
|
||||||
locale = settings.value(QString::fromUtf8("Preferences/General/Locale"), QString()).toString();
|
locale = settings.value(QString::fromUtf8("Preferences/General/Locale"), QString()).toString();
|
||||||
|
QTranslator qtTranslator;
|
||||||
QTranslator translator;
|
QTranslator translator;
|
||||||
if(locale.isEmpty()){
|
if(locale.isEmpty()){
|
||||||
locale = QLocale::system().name();
|
locale = QLocale::system().name();
|
||||||
settings.setValue(QString::fromUtf8("Preferences/General/Locale"), locale);
|
settings.setValue(QString::fromUtf8("Preferences/General/Locale"), locale);
|
||||||
}
|
}
|
||||||
|
if(qtTranslator.load(
|
||||||
|
QString::fromUtf8("qt_") + locale, QLibraryInfo::location(QLibraryInfo::TranslationsPath)
|
||||||
|
)){
|
||||||
|
qDebug("Qt %s locale recognized, using translation.", qPrintable(locale));
|
||||||
|
}else{
|
||||||
|
qDebug("Qt %s locale unrecognized, using default (en_GB).", qPrintable(locale));
|
||||||
|
}
|
||||||
|
app.installTranslator(&qtTranslator);
|
||||||
if(translator.load(QString::fromUtf8(":/lang/qbittorrent_") + locale)){
|
if(translator.load(QString::fromUtf8(":/lang/qbittorrent_") + locale)){
|
||||||
qDebug("%s locale recognized, using translation.", qPrintable(locale));
|
qDebug("%s locale recognized, using translation.", qPrintable(locale));
|
||||||
}else{
|
}else{
|
||||||
|
Loading…
Reference in New Issue
Block a user