mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 02:36:34 +01:00
Remove option to change language on per-profile basis
System locale is now always used.
This commit is contained in:
parent
27506e3ba1
commit
4d2f02ac45
@ -305,7 +305,6 @@ MainApplication::MainApplication(int &argc, char** argv)
|
|||||||
m_restoreManager = new RestoreManager(sessionManager()->askSessionFromUser());
|
m_restoreManager = new RestoreManager(sessionManager()->askSessionFromUser());
|
||||||
}
|
}
|
||||||
|
|
||||||
translateApp();
|
|
||||||
loadSettings();
|
loadSettings();
|
||||||
|
|
||||||
m_plugins = new PluginProxy(this);
|
m_plugins = new PluginProxy(this);
|
||||||
@ -489,22 +488,6 @@ void MainApplication::setProxyStyle(ProxyStyle *style)
|
|||||||
setStyle(style);
|
setStyle(style);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString MainApplication::currentLanguageFile() const
|
|
||||||
{
|
|
||||||
return m_languageFile;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString MainApplication::currentLanguage() const
|
|
||||||
{
|
|
||||||
QString lang = m_languageFile;
|
|
||||||
|
|
||||||
if (lang.isEmpty()) {
|
|
||||||
return "en_US";
|
|
||||||
}
|
|
||||||
|
|
||||||
return lang.left(lang.length() - 3);
|
|
||||||
}
|
|
||||||
|
|
||||||
History* MainApplication::history()
|
History* MainApplication::history()
|
||||||
{
|
{
|
||||||
if (!m_history) {
|
if (!m_history) {
|
||||||
@ -1023,65 +1006,6 @@ void MainApplication::loadTheme(const QString &name)
|
|||||||
setStyleSheet(qss);
|
setStyleSheet(qss);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainApplication::translateApp()
|
|
||||||
{
|
|
||||||
QString file = Settings().value(QSL("Language/language"), QLocale::system().name()).toString();
|
|
||||||
|
|
||||||
// It can only be "C" locale, for which we will use default English language
|
|
||||||
if (file.size() < 2)
|
|
||||||
file.clear();
|
|
||||||
|
|
||||||
if (!file.isEmpty() && !file.endsWith(QL1S(".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);
|
|
||||||
|
|
||||||
if (!file.isEmpty()) {
|
|
||||||
const QStringList translationsPaths = DataPaths::allPaths(DataPaths::Translations);
|
|
||||||
|
|
||||||
foreach (const QString &path, translationsPaths) {
|
|
||||||
// If "xx_yy" translation doesn't exists, try to use "xx*" translation
|
|
||||||
// It can only happen when language is chosen from system locale
|
|
||||||
|
|
||||||
if (!QFile(QString("%1/%2").arg(path, file)).exists()) {
|
|
||||||
QDir dir(path);
|
|
||||||
QString lang = file.left(2) + QL1S("*.qm");
|
|
||||||
|
|
||||||
const QStringList translations = dir.entryList(QStringList(lang));
|
|
||||||
|
|
||||||
// If no translation can be found, default English will be used
|
|
||||||
file = translations.isEmpty() ? QString() : translations.at(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!file.isEmpty() && QFile(QString("%1/%2").arg(path, file)).exists()) {
|
|
||||||
translationPath = path;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load application translation
|
|
||||||
QTranslator* app = new QTranslator(this);
|
|
||||||
app->load(file, translationPath);
|
|
||||||
|
|
||||||
// Load Qt translation (first try to load from Qt path)
|
|
||||||
QTranslator* sys = new QTranslator(this);
|
|
||||||
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;
|
|
||||||
|
|
||||||
installTranslator(app);
|
|
||||||
installTranslator(sys);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainApplication::checkDefaultWebBrowser()
|
void MainApplication::checkDefaultWebBrowser()
|
||||||
{
|
{
|
||||||
if (isPortable()) {
|
if (isPortable()) {
|
||||||
|
@ -91,9 +91,6 @@ public:
|
|||||||
QString styleName() const;
|
QString styleName() const;
|
||||||
void setProxyStyle(ProxyStyle *style);
|
void setProxyStyle(ProxyStyle *style);
|
||||||
|
|
||||||
QString currentLanguageFile() const;
|
|
||||||
QString currentLanguage() const;
|
|
||||||
|
|
||||||
History* history();
|
History* history();
|
||||||
Bookmarks* bookmarks();
|
Bookmarks* bookmarks();
|
||||||
|
|
||||||
@ -157,8 +154,6 @@ private:
|
|||||||
void loadSettings();
|
void loadSettings();
|
||||||
void loadTheme(const QString &name);
|
void loadTheme(const QString &name);
|
||||||
|
|
||||||
void translateApp();
|
|
||||||
|
|
||||||
void setupUserScripts();
|
void setupUserScripts();
|
||||||
void setUserStyleSheet(const QString &filePath);
|
void setUserStyleSheet(const QString &filePath);
|
||||||
|
|
||||||
@ -197,8 +192,6 @@ private:
|
|||||||
|
|
||||||
QList<PostLaunchAction> m_postLaunchActions;
|
QList<PostLaunchAction> m_postLaunchActions;
|
||||||
|
|
||||||
QString m_languageFile;
|
|
||||||
|
|
||||||
void createJumpList();
|
void createJumpList();
|
||||||
void initPulseSupport();
|
void initPulseSupport();
|
||||||
|
|
||||||
|
@ -97,8 +97,8 @@ void Plugins::shutdown()
|
|||||||
PluginSpec Plugins::createSpec(const DesktopFile &metaData)
|
PluginSpec Plugins::createSpec(const DesktopFile &metaData)
|
||||||
{
|
{
|
||||||
PluginSpec spec;
|
PluginSpec spec;
|
||||||
spec.name = metaData.name(mApp->currentLanguage());
|
spec.name = metaData.name();
|
||||||
spec.description = metaData.comment(mApp->currentLanguage());
|
spec.description = metaData.comment();
|
||||||
spec.version = metaData.value(QSL("X-Falkon-Version")).toString();
|
spec.version = metaData.value(QSL("X-Falkon-Version")).toString();
|
||||||
spec.author = QSL("%1 <%2>").arg(metaData.value(QSL("X-Falkon-Author")).toString(), metaData.value(QSL("X-Falkon-Email")).toString());
|
spec.author = QSL("%1 <%2>").arg(metaData.value(QSL("X-Falkon-Author")).toString(), metaData.value(QSL("X-Falkon-Email")).toString());
|
||||||
spec.hasSettings = metaData.value(QSL("X-Falkon-Settings")).toBool();
|
spec.hasSettings = metaData.value(QSL("X-Falkon-Settings")).toBool();
|
||||||
@ -352,7 +352,6 @@ bool Plugins::initPlugin(PluginInterface::InitState state, Plugin *plugin)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
qApp->installTranslator(plugin->instance->getTranslator(mApp->currentLanguageFile()));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,7 +100,6 @@ Preferences::Preferences(BrowserWindow* window)
|
|||||||
{
|
{
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
ui->languages->setLayoutDirection(Qt::LeftToRight);
|
|
||||||
QzTools::centerWidgetOnScreen(this);
|
QzTools::centerWidgetOnScreen(this);
|
||||||
|
|
||||||
m_themesManager = new ThemeManager(ui->themesWidget, this);
|
m_themesManager = new ThemeManager(ui->themesWidget, this);
|
||||||
@ -458,37 +457,6 @@ Preferences::Preferences(BrowserWindow* window)
|
|||||||
ui->spellcheckNoLanguages->hide();
|
ui->spellcheckNoLanguages->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
//OTHER
|
|
||||||
//Languages
|
|
||||||
QString activeLanguage = mApp->currentLanguage();
|
|
||||||
|
|
||||||
if (!activeLanguage.isEmpty() && activeLanguage != QLatin1String("en_US")) {
|
|
||||||
ui->languages->addItem(createLanguageItem(activeLanguage), activeLanguage);
|
|
||||||
}
|
|
||||||
|
|
||||||
ui->languages->addItem("English (en_US)");
|
|
||||||
|
|
||||||
const QStringList translationPaths = DataPaths::allPaths(DataPaths::Translations);
|
|
||||||
|
|
||||||
foreach (const QString &path, translationPaths) {
|
|
||||||
QDir lanDir(path);
|
|
||||||
QStringList list = lanDir.entryList(QStringList("*.qm"));
|
|
||||||
foreach (const QString &name, list) {
|
|
||||||
if (name.startsWith(QLatin1String("qt_"))) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString loc = name;
|
|
||||||
loc.remove(QLatin1String(".qm"));
|
|
||||||
|
|
||||||
if (loc == activeLanguage) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
ui->languages->addItem(createLanguageItem(loc), loc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Proxy Configuration
|
// Proxy Configuration
|
||||||
settings.beginGroup("Web-Proxy");
|
settings.beginGroup("Web-Proxy");
|
||||||
int proxyType = settings.value("ProxyType", 2).toInt();
|
int proxyType = settings.value("ProxyType", 2).toInt();
|
||||||
@ -1021,11 +989,6 @@ void Preferences::saveSettings()
|
|||||||
settings.setValue("showSearchSuggestions", ui->showABSearchSuggestions->isChecked());
|
settings.setValue("showSearchSuggestions", ui->showABSearchSuggestions->isChecked());
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
|
|
||||||
//Languages
|
|
||||||
settings.beginGroup("Language");
|
|
||||||
settings.setValue("language", ui->languages->itemData(ui->languages->currentIndex()).toString());
|
|
||||||
settings.endGroup();
|
|
||||||
|
|
||||||
//Proxy Configuration
|
//Proxy Configuration
|
||||||
int proxyType;
|
int proxyType;
|
||||||
if (ui->noProxy->isChecked()) {
|
if (ui->noProxy->isChecked()) {
|
||||||
|
@ -412,46 +412,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="18" column="1" colspan="2">
|
|
||||||
<widget class="QLabel" name="label_17">
|
|
||||||
<property name="text">
|
|
||||||
<string>In order to change language, you must restart browser.</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="14" column="0" colspan="3">
|
|
||||||
<widget class="QLabel" name="label_11">
|
|
||||||
<property name="text">
|
|
||||||
<string><b>Language</b></string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="15" column="1">
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_13">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label_16">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>200</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Available translations: </string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item row="15" column="2">
|
|
||||||
<widget class="QComboBox" name="languages"/>
|
|
||||||
</item>
|
|
||||||
<item row="5" column="1" colspan="2">
|
<item row="5" column="1" colspan="2">
|
||||||
<widget class="QCheckBox" name="dontLoadTabsUntilSelected">
|
<widget class="QCheckBox" name="dontLoadTabsUntilSelected">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@ -2419,8 +2379,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>560</width>
|
<width>96</width>
|
||||||
<height>80</height>
|
<height>31</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_14">
|
<layout class="QHBoxLayout" name="horizontalLayout_14">
|
||||||
|
@ -111,8 +111,8 @@ ThemeManager::Theme ThemeManager::parseTheme(const QString &path, const QString
|
|||||||
}
|
}
|
||||||
|
|
||||||
DesktopFile metadata(path + QSL("metadata.desktop"));
|
DesktopFile metadata(path + QSL("metadata.desktop"));
|
||||||
info.name = metadata.name(mApp->currentLanguage());
|
info.name = metadata.name();
|
||||||
info.description = metadata.comment(mApp->currentLanguage());
|
info.description = metadata.comment();
|
||||||
info.author = metadata.value(QSL("X-Falkon-Author")).toString();
|
info.author = metadata.value(QSL("X-Falkon-Author")).toString();
|
||||||
|
|
||||||
const QString iconName = metadata.icon();
|
const QString iconName = metadata.icon();
|
||||||
|
@ -329,7 +329,7 @@ CertificateInfoWidget::CertificateInfoWidget(const QSslCertificate &cert, QWidge
|
|||||||
ui->issuedByO->setText(showCertInfo(cert.issuerInfo(QSslCertificate::Organization)));
|
ui->issuedByO->setText(showCertInfo(cert.issuerInfo(QSslCertificate::Organization)));
|
||||||
ui->issuedByOU->setText(showCertInfo(cert.issuerInfo(QSslCertificate::OrganizationalUnitName)));
|
ui->issuedByOU->setText(showCertInfo(cert.issuerInfo(QSslCertificate::OrganizationalUnitName)));
|
||||||
//Validity
|
//Validity
|
||||||
QLocale locale = QLocale(mApp->currentLanguageFile());
|
QLocale locale = QLocale::system();
|
||||||
ui->validityIssuedOn->setText(locale.toString(cert.effectiveDate(), "dddd d. MMMM yyyy"));
|
ui->validityIssuedOn->setText(locale.toString(cert.effectiveDate(), "dddd d. MMMM yyyy"));
|
||||||
ui->validityExpiresOn->setText(locale.toString(cert.expiryDate(), "dddd d. MMMM yyyy"));
|
ui->validityExpiresOn->setText(locale.toString(cert.expiryDate(), "dddd d. MMMM yyyy"));
|
||||||
}
|
}
|
||||||
|
@ -30,14 +30,14 @@ DesktopFile::DesktopFile(const QString &filePath)
|
|||||||
m_settings->beginGroup(QSL("Desktop Entry"));
|
m_settings->beginGroup(QSL("Desktop Entry"));
|
||||||
}
|
}
|
||||||
|
|
||||||
QString DesktopFile::name(const QString &locale) const
|
QString DesktopFile::name() const
|
||||||
{
|
{
|
||||||
return value(QSL("Name"), locale).toString();
|
return value(QSL("Name"), true).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString DesktopFile::comment(const QString &locale) const
|
QString DesktopFile::comment() const
|
||||||
{
|
{
|
||||||
return value(QSL("Comment"), locale).toString();
|
return value(QSL("Comment"), true).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString DesktopFile::type() const
|
QString DesktopFile::type() const
|
||||||
@ -50,16 +50,28 @@ QString DesktopFile::icon() const
|
|||||||
return value(QSL("Icon")).toString();
|
return value(QSL("Icon")).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant DesktopFile::value(const QString &key, const QString &locale) const
|
QVariant DesktopFile::value(const QString &key, bool localized) const
|
||||||
{
|
{
|
||||||
if (!m_settings) {
|
if (!m_settings) {
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
if (!locale.isEmpty()) {
|
if (localized) {
|
||||||
const QString localeKey = QSL("%1[%2]").arg(key, locale);
|
const QLocale locale = QLocale::system();
|
||||||
|
QString localeKey = QSL("%1[%2]").arg(key, locale.name());
|
||||||
if (m_settings->contains(localeKey)) {
|
if (m_settings->contains(localeKey)) {
|
||||||
return m_settings->value(localeKey);
|
return m_settings->value(localeKey);
|
||||||
}
|
}
|
||||||
|
localeKey = QSL("%1[%2]").arg(key, locale.bcp47Name());
|
||||||
|
if (m_settings->contains(localeKey)) {
|
||||||
|
return m_settings->value(localeKey);
|
||||||
|
}
|
||||||
|
const int i = locale.name().indexOf(QLatin1Char('_'));
|
||||||
|
if (i > 0) {
|
||||||
|
localeKey = QSL("%1[%2]").arg(key, locale.name().left(i));
|
||||||
|
if (m_settings->contains(localeKey)) {
|
||||||
|
return m_settings->value(localeKey);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return m_settings->value(key);
|
return m_settings->value(key);
|
||||||
}
|
}
|
||||||
|
@ -29,11 +29,11 @@ public:
|
|||||||
explicit DesktopFile();
|
explicit DesktopFile();
|
||||||
explicit DesktopFile(const QString &filePath);
|
explicit DesktopFile(const QString &filePath);
|
||||||
|
|
||||||
QString name(const QString &locale = QString()) const;
|
QString name() const;
|
||||||
QString comment(const QString &locale = QString()) const;
|
QString comment() const;
|
||||||
QString type() const;
|
QString type() const;
|
||||||
QString icon() const;
|
QString icon() const;
|
||||||
QVariant value(const QString &key, const QString &locale = QString()) const;
|
QVariant value(const QString &key, bool localized = false) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QSharedPointer<QSettings> m_settings;
|
QSharedPointer<QSettings> m_settings;
|
||||||
|
@ -795,7 +795,7 @@ void WebView::createPageContextMenu(QMenu* menu)
|
|||||||
const QUrl w3url = QUrl::fromEncoded("http://validator.w3.org/check?uri=" + QUrl::toPercentEncoding(url().toEncoded()));
|
const QUrl w3url = QUrl::fromEncoded("http://validator.w3.org/check?uri=" + QUrl::toPercentEncoding(url().toEncoded()));
|
||||||
menu->addAction(QIcon(":icons/sites/w3.png"), tr("Validate page"), this, SLOT(openUrlInSelectedTab()))->setData(w3url);
|
menu->addAction(QIcon(":icons/sites/w3.png"), tr("Validate page"), this, SLOT(openUrlInSelectedTab()))->setData(w3url);
|
||||||
|
|
||||||
QByteArray langCode = mApp->currentLanguage().left(2).toUtf8();
|
QByteArray langCode = QLocale::system().name().left(2).toUtf8();
|
||||||
const QUrl gturl = QUrl::fromEncoded("http://translate.google.com/translate?sl=auto&tl=" + langCode + "&u=" + QUrl::toPercentEncoding(url().toEncoded()));
|
const QUrl gturl = QUrl::fromEncoded("http://translate.google.com/translate?sl=auto&tl=" + langCode + "&u=" + QUrl::toPercentEncoding(url().toEncoded()));
|
||||||
menu->addAction(QIcon(":icons/sites/translate.png"), tr("Translate page"), this, SLOT(openUrlInSelectedTab()))->setData(gturl);
|
menu->addAction(QIcon(":icons/sites/translate.png"), tr("Translate page"), this, SLOT(openUrlInSelectedTab()))->setData(gturl);
|
||||||
}
|
}
|
||||||
@ -868,7 +868,7 @@ void WebView::createSelectedTextContextMenu(QMenu* menu, const WebHitTestResult
|
|||||||
menu->addAction(QIcon::fromTheme("mail-message-new"), tr("Send text..."), this, SLOT(sendTextByMail()))->setData(selectedText);
|
menu->addAction(QIcon::fromTheme("mail-message-new"), tr("Send text..."), this, SLOT(sendTextByMail()))->setData(selectedText);
|
||||||
menu->addSeparator();
|
menu->addSeparator();
|
||||||
|
|
||||||
QString langCode = mApp->currentLanguage().left(2).toUtf8();
|
QString langCode = QLocale::system().name().left(2).toUtf8();
|
||||||
QUrl googleTranslateUrl = QUrl(QString("https://translate.google.com/#auto/%1/%2").arg(langCode, selectedText));
|
QUrl googleTranslateUrl = QUrl(QString("https://translate.google.com/#auto/%1/%2").arg(langCode, selectedText));
|
||||||
Action* gtwact = new Action(QIcon(":icons/sites/translate.png"), tr("Google Translate"));
|
Action* gtwact = new Action(QIcon(":icons/sites/translate.png"), tr("Google Translate"));
|
||||||
gtwact->setData(googleTranslateUrl);
|
gtwact->setData(googleTranslateUrl);
|
||||||
|
Loading…
Reference in New Issue
Block a user