Commit 4530b56a authored by Tomi Leppänen's avatar Tomi Leppänen

Add translations.

Signed-off-by: Tomi Leppänen's avatarTomi Leppänen <tomi.leppanen@jolla.com>
parent 66203bda
......@@ -2,7 +2,6 @@ Name: nemo-qml-plugin-systemsettings
Summary: System settings plugin for Nemo Mobile
Version: 0.5.37
Release: 1
Group: System/Libraries
License: BSD
URL: https://git.sailfishos.org/mer-core/nemo-qml-plugin-systemsettings
Source0: %{name}-%{version}.tar.bz2
......@@ -35,13 +34,13 @@ BuildRequires: pkgconfig(glib-2.0)
BuildRequires: pkgconfig(sailfishaccesscontrol)
BuildRequires: pkgconfig(libsystemd)
BuildRequires: pkgconfig(sailfishusermanager)
BuildRequires: qt5-qttools-linguist
%description
%{summary}.
%package devel
Summary: System settings C++ library
Group: System/Libraries
Requires: %{name} = %{version}-%{release}
%description devel
......@@ -49,11 +48,16 @@ Requires: %{name} = %{version}-%{release}
%package tests
Summary: System settings C++ library (unit tests)
Group: System/Libraries
%description tests
%{summary}.
%package ts-devel
Summary: Translation source for %{name}
%description ts-devel
%{summary}.
%prep
%setup -q -n %{name}-%{version}
......@@ -94,6 +98,7 @@ fi
%attr(4710,-,privileged) %{_libexecdir}/setlocale
%dir %attr(0775, root, privileged) /etc/location
%config %attr(0664, root, privileged) /etc/location/location.conf
%{_datadir}/translations/*.qm
%files devel
%defattr(-,root,root,-)
......@@ -105,3 +110,6 @@ fi
%defattr(-,root,root,-)
%{_libdir}/%{name}-tests/ut_diskusage
%{_datadir}/%{name}-tests/tests.xml
%files ts-devel
%{_datadir}/translations/source/*.ts
......@@ -204,7 +204,7 @@ QList<Language> LanguageModel::supportedLanguages()
QString localeCode = settings.value("LocaleCode").toString();
QString region = settings.value("Region").toString();
//% "Region: %1"
QString regionLabel = settings.value("RegionLabel", qtTrId("settings_system-la-region")).toString();
QString regionLabel = settings.value("RegionLabel", qtTrId("systemsettings-la-region")).toString();
if (name.isEmpty() || localeCode.isEmpty()) {
continue;
}
......
......@@ -33,6 +33,7 @@
#include <QtQml>
#include <QQmlEngine>
#include <QQmlExtensionPlugin>
#include <QTranslator>
#include <qusbmoded.h>
......@@ -54,6 +55,22 @@
#include "userinfo.h"
#include "usermodel.h"
class AppTranslator: public QTranslator
{
Q_OBJECT
public:
AppTranslator(QObject *parent)
: QTranslator(parent)
{
qApp->installTranslator(this);
}
virtual ~AppTranslator()
{
qApp->removeTranslator(this);
}
};
template<class T>
static QObject *api_factory(QQmlEngine *, QJSEngine *)
{
......@@ -68,8 +85,11 @@ class SystemSettingsPlugin : public QQmlExtensionPlugin
public:
void initializeEngine(QQmlEngine *engine, const char *uri)
{
Q_UNUSED(engine)
Q_UNUSED(uri)
Q_ASSERT(QLatin1String(uri) == QLatin1String("org.nemomobile.systemsettings"));
AppTranslator *engineeringEnglish = new AppTranslator(engine);
engineeringEnglish->load("qml_plugin_systemsettings_eng_en", "/usr/share/translations");
AppTranslator *translator = new AppTranslator(engine);
translator->load(QLocale(), "qml_plugin_systemsettings", "-", "/usr/share/translations");
}
void registerTypes(const char *uri)
......
......@@ -6,4 +6,4 @@ src_plugins.depends = src
OTHER_FILES += rpm/nemo-qml-plugin-systemsettings.spec
SUBDIRS = src src_plugins setlocale tests
SUBDIRS = src src_plugins setlocale tests translations
TEMPLATE = aux
TRANSLATION_CATALOG = qml_plugin_systemsettings
# Translation Source
TS_FILE = $$OUT_PWD/$${TRANSLATION_CATALOG}.ts
ts.commands += lupdate $$PWD/.. -ts $$TS_FILE
ts.CONFIG += no_check_exist no_link
ts.output = $$TS_FILE
ts.input = ..
ts_install.files = $$TS_FILE
ts_install.path = /usr/share/translations/source
ts_install.CONFIG += no_check_exist
# Engineering English Translation
EE_QM = $$OUT_PWD/$${TRANSLATION_CATALOG}_eng_en.qm
# XXX should add -markuntranslated "-" when proper translations are in place
qm.commands += lrelease -idbased $$TS_FILE -qm $$EE_QM
qm.CONFIG += no_check_exist no_link
qm.depends = ts
qm.input = $$TS_FILE
qm.output = $$EE_QM
qm_install.path = /usr/share/translations
qm_install.files = $$EE_QM
qm_install.CONFIG += no_check_exist
QMAKE_EXTRA_TARGETS += ts qm
PRE_TARGETDEPS += ts qm
INSTALLS += ts_install qm_install
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment