mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 10:46:35 +01:00
[Translations] Try to load Qt (qt_*.qm) translations from Qt path
Also removed all qt_*.qm translations that are part of official Qt distribution.
This commit is contained in:
parent
458f6fecf0
commit
543c3b8732
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -54,6 +54,7 @@
|
|||||||
#include <QNetworkDiskCache>
|
#include <QNetworkDiskCache>
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
#include <QSqlDatabase>
|
#include <QSqlDatabase>
|
||||||
|
#include <QLibraryInfo>
|
||||||
#include <QTranslator>
|
#include <QTranslator>
|
||||||
#include <QThreadPool>
|
#include <QThreadPool>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
@ -932,12 +933,15 @@ void MainApplication::loadTheme(const QString &name)
|
|||||||
void MainApplication::translateApp()
|
void MainApplication::translateApp()
|
||||||
{
|
{
|
||||||
Settings settings;
|
Settings settings;
|
||||||
QString file = settings.value("Language/language", QLocale::system().name()).toString();
|
QString file = settings.value(QSL("Language/language"), QLocale::system().name()).toString();
|
||||||
|
|
||||||
if (!file.isEmpty() && !file.endsWith(QLatin1String(".qm"))) {
|
if (!file.isEmpty() && !file.endsWith(QL1S(".qm"))) {
|
||||||
file.append(".qm");
|
file.append(QL1S(".qm"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Either we load default language (with empty file), or we attempt to load xx.qm (xx_yy.qm)
|
||||||
|
Q_ASSERT(file.isEmpty() || file.size() >= 5);
|
||||||
|
|
||||||
QString translationPath = DataPaths::path(DataPaths::Translations);
|
QString translationPath = DataPaths::path(DataPaths::Translations);
|
||||||
|
|
||||||
if (!file.isEmpty()) {
|
if (!file.isEmpty()) {
|
||||||
@ -945,11 +949,11 @@ void MainApplication::translateApp()
|
|||||||
|
|
||||||
foreach (const QString &path, translationsPaths) {
|
foreach (const QString &path, translationsPaths) {
|
||||||
// If "xx_yy" translation doesn't exists, try to use "xx*" translation
|
// If "xx_yy" translation doesn't exists, try to use "xx*" translation
|
||||||
// It can only happen when Language is chosen from system locale
|
// It can only happen when language is chosen from system locale
|
||||||
|
|
||||||
if (!QFile(QString("%1/%2").arg(path, file)).exists()) {
|
if (!QFile(QString("%1/%2").arg(path, file)).exists()) {
|
||||||
QDir dir(path);
|
QDir dir(path);
|
||||||
QString lang = file.left(2) + QLatin1String("*.qm");
|
QString lang = file.left(2) + QL1S("*.qm");
|
||||||
|
|
||||||
const QStringList translations = dir.entryList(QStringList(lang));
|
const QStringList translations = dir.entryList(QStringList(lang));
|
||||||
|
|
||||||
@ -964,11 +968,18 @@ void MainApplication::translateApp()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Load application translation
|
||||||
QTranslator* app = new QTranslator(this);
|
QTranslator* app = new QTranslator(this);
|
||||||
app->load(file, translationPath);
|
app->load(file, translationPath);
|
||||||
|
|
||||||
|
// Load Qt translation (first try to load from Qt path)
|
||||||
QTranslator* sys = new QTranslator(this);
|
QTranslator* sys = new QTranslator(this);
|
||||||
sys->load("qt_" + file, translationPath);
|
sys->load(QL1S("qt_") + file, QLibraryInfo::location(QLibraryInfo::TranslationsPath));
|
||||||
|
|
||||||
|
// If there is no translation in Qt path for specified language, try to load it from our path
|
||||||
|
if (sys->isEmpty()) {
|
||||||
|
sys->load(QL1S("qt_") + file, translationPath);
|
||||||
|
}
|
||||||
|
|
||||||
m_languageFile = file;
|
m_languageFile = file;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user