Default to system locale language
This commit is contained in:
parent
2c2c22ccf8
commit
236c0166f6
@ -143,6 +143,8 @@ struct TranslationsModel::Private
|
|||||||
|
|
||||||
std::unique_ptr<POTranslator> m_po_translator;
|
std::unique_ptr<POTranslator> m_po_translator;
|
||||||
QFileSystemWatcher *watcher;
|
QFileSystemWatcher *watcher;
|
||||||
|
|
||||||
|
bool no_language_set = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
TranslationsModel::TranslationsModel(QString path, QObject* parent): QAbstractListModel(parent)
|
TranslationsModel::TranslationsModel(QString path, QObject* parent): QAbstractListModel(parent)
|
||||||
@ -165,7 +167,26 @@ void TranslationsModel::translationDirChanged(const QString& path)
|
|||||||
{
|
{
|
||||||
qDebug() << "Dir changed:" << path;
|
qDebug() << "Dir changed:" << path;
|
||||||
reloadLocalFiles();
|
reloadLocalFiles();
|
||||||
|
|
||||||
|
if (d->no_language_set)
|
||||||
|
{
|
||||||
|
auto bcp47Name = QLocale::system().name();
|
||||||
|
if (!findLanguage(bcp47Name))
|
||||||
|
{
|
||||||
|
bcp47Name = bcp47Name.split('_').front();
|
||||||
|
}
|
||||||
|
selectLanguage(bcp47Name);
|
||||||
|
if (selectedLanguage() != defaultLangCode)
|
||||||
|
{
|
||||||
|
updateLanguage(selectedLanguage());
|
||||||
|
APPLICATION->settings()->set("Language", selectedLanguage());
|
||||||
|
}
|
||||||
|
d->no_language_set = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
selectLanguage(selectedLanguage());
|
selectLanguage(selectedLanguage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TranslationsModel::indexReceived()
|
void TranslationsModel::indexReceived()
|
||||||
@ -439,6 +460,12 @@ bool TranslationsModel::selectLanguage(QString key)
|
|||||||
{
|
{
|
||||||
QString &langCode = key;
|
QString &langCode = key;
|
||||||
auto langPtr = findLanguage(key);
|
auto langPtr = findLanguage(key);
|
||||||
|
|
||||||
|
if (langCode.length() == 0)
|
||||||
|
{
|
||||||
|
d->no_language_set = true;
|
||||||
|
}
|
||||||
|
|
||||||
if(!langPtr)
|
if(!langPtr)
|
||||||
{
|
{
|
||||||
qWarning() << "Selected invalid language" << key << ", defaulting to" << defaultLangCode;
|
qWarning() << "Selected invalid language" << key << ", defaulting to" << defaultLangCode;
|
||||||
|
Loading…
Reference in New Issue
Block a user