mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2026-06-29 01:54:20 +03:00
Fixes to translations (#5512)
This commit is contained in:
commit
0fee29559f
2 changed files with 19 additions and 19 deletions
|
|
@ -937,15 +937,6 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
|
|||
qInfo() << "<> Network done.";
|
||||
}
|
||||
|
||||
// load translations
|
||||
{
|
||||
m_translations.reset(new TranslationsModel("translations"));
|
||||
auto bcp47Name = m_settings->get("Language").toString();
|
||||
m_translations->selectLanguage(bcp47Name);
|
||||
qInfo() << "Your language is" << bcp47Name;
|
||||
qInfo() << "<> Translations loaded.";
|
||||
}
|
||||
|
||||
// Instance icons
|
||||
{
|
||||
auto setting = APPLICATION->settings()->getSetting("IconsDir");
|
||||
|
|
@ -1024,8 +1015,13 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
|
|||
qInfo() << "<> Cache initialized.";
|
||||
}
|
||||
|
||||
// now we have network, download translation updates
|
||||
// load translations
|
||||
{
|
||||
m_translations.reset(new TranslationsModel("translations"));
|
||||
m_translations->downloadIndex();
|
||||
qInfo() << "Your language is" << m_translations->selectedLanguage();
|
||||
qInfo() << "<> Translations loaded.";
|
||||
}
|
||||
|
||||
// FIXME: what to do with these?
|
||||
m_profilers.insert("jprofiler", std::shared_ptr<BaseProfilerFactory>(new JProfilerFactory()));
|
||||
|
|
|
|||
|
|
@ -179,6 +179,7 @@ TranslationsModel::TranslationsModel(const QString& path, QObject* parent) : QAb
|
|||
{
|
||||
d = std::make_unique<Private>();
|
||||
d->m_dir.setPath(path);
|
||||
d->m_selectedLanguage = APPLICATION->settings()->get("Language").toString();
|
||||
FS::ensureFolderPathExists(path);
|
||||
reloadLocalFiles();
|
||||
|
||||
|
|
@ -202,22 +203,20 @@ void TranslationsModel::indexReceived()
|
|||
{
|
||||
qDebug() << "Got translations index!";
|
||||
d->m_indexJob.reset();
|
||||
|
||||
if (d->m_noLanguageSet) {
|
||||
reloadLocalFiles();
|
||||
|
||||
if (d->m_noLanguageSet) {
|
||||
auto language = getSystemLocaleName();
|
||||
if (!findLanguageAsOptional(language).has_value()) {
|
||||
language = getSystemLanguage();
|
||||
}
|
||||
selectLanguage(language);
|
||||
if (selectedLanguage() != g_defaultLangCode) {
|
||||
updateLanguage(selectedLanguage());
|
||||
}
|
||||
APPLICATION->settings()->set("Language", selectedLanguage());
|
||||
d->m_noLanguageSet = false;
|
||||
} else if (d->m_selectedLanguage != g_defaultLangCode) {
|
||||
downloadTranslation(d->m_selectedLanguage);
|
||||
}
|
||||
|
||||
if (selectedLanguage() != g_defaultLangCode) {
|
||||
updateLanguage(selectedLanguage());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -267,7 +266,12 @@ void TranslationsModel::reloadLocalFiles()
|
|||
{
|
||||
QMap<QString, Language> languages = { { g_defaultLangCode, Language(g_defaultLangCode) } };
|
||||
|
||||
readIndex(d->m_dir.absoluteFilePath("index_v2.json"), languages);
|
||||
const auto indexPath = d->m_dir.absoluteFilePath("index_v2.json");
|
||||
if (!QFileInfo::exists(indexPath)) {
|
||||
downloadIndex();
|
||||
return;
|
||||
}
|
||||
readIndex(indexPath, languages);
|
||||
auto entries = d->m_dir.entryInfoList({ "mmc_*.qm", "*.po" }, QDir::Files | QDir::NoDotAndDotDot);
|
||||
for (auto& entry : entries) {
|
||||
auto completeSuffix = entry.completeSuffix();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue