"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/gui/application.cpp" between
ownCloud-2.9.0.5150.tar.xz and ownCloud-2.9.1.5500.tar.xz

About: ownCloud Client (formerly "mirall") is a tool to synchronize files from ownCloud Server with your desktop client. It uses OCSync as its syncing backend.

application.cpp  (ownCloud-2.9.0.5150.tar.xz):application.cpp  (ownCloud-2.9.1.5500.tar.xz)
skipping to change at line 688 skipping to change at line 688
return QLatin1String("zh_CN"); return QLatin1String("zh_CN");
// Traditional Chinese // Traditional Chinese
if (lang == QLatin1String("zh_Hant")) if (lang == QLatin1String("zh_Hant"))
return QLatin1String("zh_TW"); return QLatin1String("zh_TW");
return lang; return lang;
} }
void Application::setupTranslations() void Application::setupTranslations()
{ {
const auto trPath = Translations::translationsDirectoryPath(); const auto trPath = Translations::translationsDirectoryPath();
qCDebug(lcApplication) << "Translations directory path:" << trPath;
QStringList uiLanguages = QLocale::system().uiLanguages(); QStringList uiLanguages = QLocale::system().uiLanguages();
qCDebug(lcApplication) << "UI languages:" << uiLanguages;
// the user can also set a locale in the settings, so we need to load the co nfig file // the user can also set a locale in the settings, so we need to load the co nfig file
ConfigFile cfg; ConfigFile cfg;
// allow user and theme to enforce a language via a commandline parameter // allow user and theme to enforce a language via a commandline parameter
const auto themeEnforcedLocale = Theme::instance()->enforcedLocale(); const auto themeEnforcedLocale = Theme::instance()->enforcedLocale();
qCDebug(lcApplication) << "Theme-enforced locale:" << themeEnforcedLocale;
// we need to track the enforced languages separately, since we need to dist inguish between locale-provided // we need to track the enforced languages separately, since we need to dist inguish between locale-provided
// and user-enforced ones below // and user-enforced ones below
QSet<QString> enforcedLanguages; QSet<QString> enforcedLanguages;
// note that user-enforced languages are prioritized over the theme enforced one // note that user-enforced languages are prioritized over the theme enforced one
// to make testing easier, --language overrides the setting from the config file // to make testing easier, --language overrides the setting from the config file
// as we are prepending to the list of languages, the list passed to the loo p must be sorted with ascending priority // as we are prepending to the list of languages, the list passed to the loo p must be sorted with ascending priority
for (const auto &enforcedLocale : { themeEnforcedLocale, cfg.uiLanguage(), _ userEnforcedLanguage }) { for (const auto &enforcedLocale : { themeEnforcedLocale, cfg.uiLanguage(), _ userEnforcedLanguage }) {
if (!enforcedLocale.isEmpty()) { if (!enforcedLocale.isEmpty()) {
enforcedLanguages.insert(enforcedLocale); enforcedLanguages.insert(enforcedLocale);
uiLanguages.prepend(enforcedLocale); uiLanguages.prepend(enforcedLocale);
} }
} }
qCDebug(lcApplication) << "Enforced languages:" << enforcedLanguages;
QTranslator *translator = new QTranslator(this); QTranslator *translator = new QTranslator(this);
QTranslator *qtTranslator = new QTranslator(this); QTranslator *qtTranslator = new QTranslator(this);
QTranslator *qtkeychainTranslator = new QTranslator(this); QTranslator *qtkeychainTranslator = new QTranslator(this);
for (QString lang : qAsConst(uiLanguages)) { for (QString lang : qAsConst(uiLanguages)) {
lang.replace(QLatin1Char('-'), QLatin1Char('_')); // work around QTBUG-2 5973 lang.replace(QLatin1Char('-'), QLatin1Char('_')); // work around QTBUG-2 5973
lang = substLang(lang); lang = substLang(lang);
const QString trFile = Translations::translationsFilePrefix() + lang; const QString trFile = Translations::translationsFilePrefix() + lang;
if (translator->load(trFile, trPath) || lang.startsWith(QLatin1String("e n"))) { if (translator->load(trFile, trPath) || lang.startsWith(QLatin1String("e n"))) {
// Permissive approach: Qt and keychain translations // Permissive approach: Qt and keychain translations
// may be missing, but Qt translations must be there in order // may be missing, but Qt translations must be there in order
// for us to accept the language. Otherwise, we try with the next. // for us to accept the language. Otherwise, we try with the next.
// "en" is an exception as it is the default language and may not // "en" is an exception as it is the default language and may not
// have a translation file provided. // have a translation file provided.
qCInfo(lcApplication) << "Using" << lang << "translation"; qCInfo(lcApplication) << "Using" << lang << "translation";
_displayLanguage = lang; _displayLanguage = lang;
const QString qtTrPath = QLibraryInfo::location(QLibraryInfo::Transl ationsPath); const QString qtTrPath = QLibraryInfo::location(QLibraryInfo::Transl ationsPath);
qCDebug(lcApplication) << "qtTrPath:" << qtTrPath;
const QString qtTrFile = QLatin1String("qt_") + lang; const QString qtTrFile = QLatin1String("qt_") + lang;
qCDebug(lcApplication) << "qtTrFile:" << qtTrFile;
const QString qtBaseTrFile = QLatin1String("qtbase_") + lang; const QString qtBaseTrFile = QLatin1String("qtbase_") + lang;
qCDebug(lcApplication) << "qtBaseTrFile:" << qtBaseTrFile;
if (!qtTranslator->load(qtTrFile, qtTrPath)) { if (!qtTranslator->load(qtTrFile, qtTrPath)) {
if (!qtTranslator->load(qtTrFile, trPath)) { if (!qtTranslator->load(qtTrFile, trPath)) {
if (!qtTranslator->load(qtBaseTrFile, qtTrPath)) { if (!qtTranslator->load(qtBaseTrFile, qtTrPath)) {
qtTranslator->load(qtBaseTrFile, trPath); if (!qtTranslator->load(qtBaseTrFile, trPath)) {
qCCritical(lcApplication) << "Could not load Qt tran
slations";
}
} }
} }
} }
const QString qtkeychainTrFile = QLatin1String("qtkeychain_") + lang ; const QString qtkeychainTrFile = QLatin1String("qtkeychain_") + lang ;
if (!qtkeychainTranslator->load(qtkeychainTrFile, qtTrPath)) { if (!qtkeychainTranslator->load(qtkeychainTrFile, qtTrPath)) {
qtkeychainTranslator->load(qtkeychainTrFile, trPath); if (!qtkeychainTranslator->load(qtkeychainTrFile, trPath)) {
qCCritical(lcApplication) << "Could not load qtkeychain tran
slations";
}
}
if (!translator->isEmpty() && !installTranslator(translator)) {
qCCritical(lcApplication) << "Failed to install translator";
}
if (!qtTranslator->isEmpty() && !installTranslator(qtTranslator)) {
qCCritical(lcApplication) << "Failed to install Qt translator";
}
if (!qtkeychainTranslator->isEmpty() && !installTranslator(qtkeychai
nTranslator)) {
qCCritical(lcApplication) << "Failed to install qtkeychain trans
lator";
} }
if (!translator->isEmpty())
installTranslator(translator);
if (!qtTranslator->isEmpty())
installTranslator(qtTranslator);
if (!qtkeychainTranslator->isEmpty())
installTranslator(qtkeychainTranslator);
// makes sure widgets with locale-dependent formatting, e.g., QDateE dit, display the correct formatting // makes sure widgets with locale-dependent formatting, e.g., QDateE dit, display the correct formatting
// if the language is provided by the system locale anyway (i.e., co ming from QLocale::system().uiLanguages()), we should // if the language is provided by the system locale anyway (i.e., co ming from QLocale::system().uiLanguages()), we should
// not mess with the system locale, though // not mess with the system locale, though
// if we did, we would enforce a locale for no apparent reason // if we did, we would enforce a locale for no apparent reason
// see https://github.com/owncloud/client/issues/8608 for more infor mation // see https://github.com/owncloud/client/issues/8608 for more infor mation
if (enforcedLanguages.contains(lang)) { if (enforcedLanguages.contains(lang)) {
QLocale newLocale(lang); QLocale newLocale(lang);
qCDebug(lcApplication) << "language" << lang << "was enforced, c hanging default locale to" << newLocale; qCDebug(lcApplication) << "language" << lang << "was enforced, c hanging default locale to" << newLocale;
QLocale::setDefault(newLocale); QLocale::setDefault(newLocale);
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
// setting the layout direction directly only appears to be need
ed on mac
setLayoutDirection(newLocale.textDirection());
#endif
} }
break; break;
} }
} }
} }
void Application::showSettingsDialog() void Application::showSettingsDialog()
{ {
_gui->slotShowSettings(); _gui->slotShowSettings();
 End of changes. 13 change blocks. 
8 lines changed or deleted 36 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)