Reviewers: #plasma, mart, davidedmundson, crossi, bport Subscribers: plasma-devel Tags: #plasma Differential Revision: https://phabricator.kde.org/D26242wilder-5.18
parent
56529e7be7
commit
34216709c0
8 changed files with 148 additions and 61 deletions
@ -0,0 +1,41 @@ |
|||||||
|
/*
|
||||||
|
* Copyright (C) 2019 Kevin Ottens <kevin.ottens@enioka.com> |
||||||
|
* |
||||||
|
* This library is free software; you can redistribute it and/or |
||||||
|
* modify it under the terms of the GNU Library General Public |
||||||
|
* License as published by the Free Software Foundation; either |
||||||
|
* version 2 of the License, or (at your option) any later version. |
||||||
|
* |
||||||
|
* This library is distributed in the hope that it will be useful, |
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
||||||
|
* Library General Public License for more details. |
||||||
|
* |
||||||
|
* You should have received a copy of the GNU Library General Public License |
||||||
|
* along with this library; see the file COPYING.LIB. If not, write to |
||||||
|
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
||||||
|
* Boston, MA 02110-1301, USA. |
||||||
|
*/ |
||||||
|
|
||||||
|
#include "translationssettings.h" |
||||||
|
|
||||||
|
TranslationsSettings::TranslationsSettings(QObject *parent) |
||||||
|
: TranslationsSettingsBase(parent) |
||||||
|
{ |
||||||
|
connect(this, &TranslationsSettingsBase::languageStringChanged, |
||||||
|
this, &TranslationsSettings::configuredLanguagesChanged); |
||||||
|
} |
||||||
|
|
||||||
|
TranslationsSettings::~TranslationsSettings() |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
QStringList TranslationsSettings::configuredLanguages() const |
||||||
|
{ |
||||||
|
return languageString().split(QLatin1Char(':'), QString::SkipEmptyParts); |
||||||
|
} |
||||||
|
|
||||||
|
void TranslationsSettings::setConfiguredLanguages(const QStringList &langs) |
||||||
|
{ |
||||||
|
setLanguageString(langs.join(QLatin1Char(':'))); |
||||||
|
} |
||||||
@ -0,0 +1,40 @@ |
|||||||
|
/*
|
||||||
|
* Copyright (C) 2019 Kevin Ottens <kevin.ottens@enioka.com> |
||||||
|
* |
||||||
|
* This library is free software; you can redistribute it and/or |
||||||
|
* modify it under the terms of the GNU Library General Public |
||||||
|
* License as published by the Free Software Foundation; either |
||||||
|
* version 2 of the License, or (at your option) any later version. |
||||||
|
* |
||||||
|
* This library is distributed in the hope that it will be useful, |
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
||||||
|
* Library General Public License for more details. |
||||||
|
* |
||||||
|
* You should have received a copy of the GNU Library General Public License |
||||||
|
* along with this library; see the file COPYING.LIB. If not, write to |
||||||
|
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
||||||
|
* Boston, MA 02110-1301, USA. |
||||||
|
*/ |
||||||
|
|
||||||
|
#ifndef TRANSLATIONSSETTINGS_H |
||||||
|
#define TRANSLATIONSSETTINGS_H |
||||||
|
|
||||||
|
#include "translationssettingsbase.h" |
||||||
|
|
||||||
|
class TranslationsSettings : public TranslationsSettingsBase |
||||||
|
{ |
||||||
|
Q_OBJECT |
||||||
|
Q_PROPERTY(QStringList configuredLanguages READ configuredLanguages WRITE setConfiguredLanguages NOTIFY configuredLanguagesChanged) |
||||||
|
public: |
||||||
|
TranslationsSettings(QObject *parent = nullptr); |
||||||
|
~TranslationsSettings() override; |
||||||
|
|
||||||
|
QStringList configuredLanguages() const; |
||||||
|
void setConfiguredLanguages(const QStringList &langs); |
||||||
|
|
||||||
|
signals: |
||||||
|
void configuredLanguagesChanged(); |
||||||
|
}; |
||||||
|
|
||||||
|
#endif // TRANSLATIONSSETTINGS_H
|
||||||
@ -0,0 +1,28 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0" |
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||||
|
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0 |
||||||
|
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" > |
||||||
|
<kcfgfile name="plasma-localerc" /> |
||||||
|
<include>KLocalizedString</include> |
||||||
|
<group name="Translations"> |
||||||
|
<entry name="languageString" key="LANGUAGE" type="String"> |
||||||
|
<code> |
||||||
|
KConfigGroup formatsConfig = KConfigGroup(KSharedConfig::openConfig("plasma-localerc"), "Formats"); |
||||||
|
|
||||||
|
QString lang = formatsConfig.readEntry("LANG", QString()); |
||||||
|
|
||||||
|
if (lang.isEmpty() |
||||||
|
|| !KLocalizedString::availableDomainTranslations("plasmashell").contains(lang)) { |
||||||
|
lang = QLocale::system().name(); |
||||||
|
} |
||||||
|
|
||||||
|
if (!KLocalizedString::availableDomainTranslations("plasmashell").contains(lang)) { |
||||||
|
lang = QStringLiteral("en_US"); |
||||||
|
} |
||||||
|
</code> |
||||||
|
<default code="true">lang</default> |
||||||
|
<label>Configured languages</label> |
||||||
|
</entry> |
||||||
|
</group> |
||||||
|
</kcfg> |
||||||
@ -0,0 +1,6 @@ |
|||||||
|
File=translationssettingsbase.kcfg |
||||||
|
ClassName=TranslationsSettingsBase |
||||||
|
Mutators=true |
||||||
|
DefaultValueGetters=true |
||||||
|
GenerateProperties=true |
||||||
|
ParentInConstructor=true |
||||||
Loading…
Reference in new issue