Skip to content
Snippets Groups Projects
Commit 7500bd97 authored by akiraohgaki's avatar akiraohgaki Committed by GitHub
Browse files

Merge pull request #40 from ocs-url/feature/translation

Feature/translation
parents 3a985fb0 6a6a18d9
No related branches found
No related tags found
No related merge requests found
...@@ -6,7 +6,9 @@ CONFIG += c++11 ...@@ -6,7 +6,9 @@ CONFIG += c++11
DEFINES += QT_DEPRECATED_WARNINGS DEFINES += QT_DEPRECATED_WARNINGS
RESOURCES += src/desktop/desktop.qrc RESOURCES += \
src/desktop/desktop.qrc \
src/i18n/i18n.qrc
DISTFILES += \ DISTFILES += \
README.md \ README.md \
......
...@@ -34,7 +34,7 @@ void OcsUrlHandler::process() ...@@ -34,7 +34,7 @@ void OcsUrlHandler::process()
if (!isValid()) { if (!isValid()) {
QJsonObject result; QJsonObject result;
result["status"] = QString("error_validation"); result["status"] = QString("error_validation");
result["message"] = QString("Invalid OCS-URL " + ocsUrl_); result["message"] = tr("Invalid OCS-URL");
emit finishedWithError(result); emit finishedWithError(result);
return; return;
} }
...@@ -138,14 +138,14 @@ void OcsUrlHandler::saveDownloadedFile(qtlib::NetworkResource *resource) ...@@ -138,14 +138,14 @@ void OcsUrlHandler::saveDownloadedFile(qtlib::NetworkResource *resource)
if (!resource->saveData(destFile.path())) { if (!resource->saveData(destFile.path())) {
result["status"] = QString("error_save"); result["status"] = QString("error_save");
result["message"] = QString("Failed to save data as " + destFile.path()); result["message"] = tr("Failed to save data");
emit finishedWithError(result); emit finishedWithError(result);
resource->deleteLater(); resource->deleteLater();
return; return;
} }
result["status"] = QString("success_download"); result["status"] = QString("success_download");
result["message"] = QString("The file has been stored into " + destDir.path()); result["message"] = tr("The file has been downloaded");
emit finishedWithSuccess(result); emit finishedWithSuccess(result);
resource->deleteLater(); resource->deleteLater();
...@@ -159,7 +159,7 @@ void OcsUrlHandler::installDownloadedFile(qtlib::NetworkResource *resource) ...@@ -159,7 +159,7 @@ void OcsUrlHandler::installDownloadedFile(qtlib::NetworkResource *resource)
if (!resource->saveData(tempFile.path())) { if (!resource->saveData(tempFile.path())) {
result["status"] = QString("error_save"); result["status"] = QString("error_save");
result["message"] = QString("Failed to save data as " + tempFile.path()); result["message"] = tr("Failed to save data");
emit finishedWithError(result); emit finishedWithError(result);
resource->deleteLater(); resource->deleteLater();
return; return;
...@@ -173,41 +173,41 @@ void OcsUrlHandler::installDownloadedFile(qtlib::NetworkResource *resource) ...@@ -173,41 +173,41 @@ void OcsUrlHandler::installDownloadedFile(qtlib::NetworkResource *resource)
if (type == "bin" if (type == "bin"
&& package.installAsProgram(destFile.path())) { && package.installAsProgram(destFile.path())) {
result["message"] = QString("The file has been installed into " + destDir.path()); result["message"] = tr("The file has been installed as program");
} }
else if ((type == "plasma_plasmoids" || type == "plasma4_plasmoids" || type == "plasma5_plasmoids") else if ((type == "plasma_plasmoids" || type == "plasma4_plasmoids" || type == "plasma5_plasmoids")
&& package.installAsPlasmapkg("plasmoid")) { && package.installAsPlasmapkg("plasmoid")) {
result["message"] = QString("The plasmoid has been installed"); result["message"] = tr("The plasmoid has been installed");
} }
else if ((type == "plasma_look_and_feel" || type == "plasma5_look_and_feel") else if ((type == "plasma_look_and_feel" || type == "plasma5_look_and_feel")
&& package.installAsPlasmapkg("lookandfeel")) { && package.installAsPlasmapkg("lookandfeel")) {
result["message"] = QString("The plasma look and feel has been installed"); result["message"] = tr("The plasma look and feel has been installed");
} }
else if ((type == "plasma_desktopthemes" || type == "plasma5_desktopthemes") else if ((type == "plasma_desktopthemes" || type == "plasma5_desktopthemes")
&& package.installAsPlasmapkg("theme")) { && package.installAsPlasmapkg("theme")) {
result["message"] = QString("The plasma desktop theme has been installed"); result["message"] = tr("The plasma desktop theme has been installed");
} }
else if (type == "kwin_effects" else if (type == "kwin_effects"
&& package.installAsPlasmapkg("kwineffect")) { && package.installAsPlasmapkg("kwineffect")) {
result["message"] = QString("The KWin effect has been installed"); result["message"] = tr("The KWin effect has been installed");
} }
else if (type == "kwin_scripts" else if (type == "kwin_scripts"
&& package.installAsPlasmapkg("kwinscript")) { && package.installAsPlasmapkg("kwinscript")) {
result["message"] = QString("The KWin script has been installed"); result["message"] = tr("The KWin script has been installed");
} }
else if (type == "kwin_tabbox" else if (type == "kwin_tabbox"
&& package.installAsPlasmapkg("windowswitcher")) { && package.installAsPlasmapkg("windowswitcher")) {
result["message"] = QString("The KWin window switcher has been installed"); result["message"] = tr("The KWin window switcher has been installed");
} }
else if (package.installAsArchive(destDir.path())) { else if (package.installAsArchive(destDir.path())) {
result["message"] = QString("The archive file has been extracted into " + destDir.path()); result["message"] = tr("The archive file has been extracted");
} }
else if (package.installAsFile(destFile.path())) { else if (package.installAsFile(destFile.path())) {
result["message"] = QString("The file has been installed into " + destDir.path()); result["message"] = tr("The file has been installed");
} }
else { else {
result["status"] = QString("error_install"); result["status"] = QString("error_install");
result["message"] = QString("Failed to installation"); result["message"] = tr("Failed to installation");
emit finishedWithError(result); emit finishedWithError(result);
tempFile.remove(); tempFile.remove();
return; return;
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
#include <QStringList> #include <QStringList>
#include <QUrl> #include <QUrl>
#include <QJsonObject> #include <QJsonObject>
#include <QTranslator>
#include <QLocale>
#include <QCommandLineParser> #include <QCommandLineParser>
#include <QGuiApplication> #include <QGuiApplication>
#include <QIcon> #include <QIcon>
...@@ -25,12 +27,18 @@ int main(int argc, char *argv[]) ...@@ -25,12 +27,18 @@ int main(int argc, char *argv[])
app.setOrganizationDomain(appConfigApplication["domain"].toString()); app.setOrganizationDomain(appConfigApplication["domain"].toString());
app.setWindowIcon(QIcon::fromTheme(appConfigApplication["id"].toString(), QIcon(appConfigApplication["icon"].toString()))); app.setWindowIcon(QIcon::fromTheme(appConfigApplication["id"].toString(), QIcon(appConfigApplication["icon"].toString())));
// Setup translator
QTranslator translator;
if (translator.load(QLocale(), "messages", ".", ":/i18n")) {
app.installTranslator(&translator);
}
// Setup CLI // Setup CLI
QCommandLineParser clParser; QCommandLineParser clParser;
clParser.setApplicationDescription(appConfigApplication["description"].toString()); clParser.setApplicationDescription(appConfigApplication["description"].toString());
clParser.addHelpOption(); clParser.addHelpOption();
clParser.addVersionOption(); clParser.addVersionOption();
clParser.addPositionalArgument("ocsurl", "OCS-URL"); clParser.addPositionalArgument("OCS-URL", "OCS-URL that starts with ocs://");
clParser.process(app); clParser.process(app);
QStringList args = clParser.positionalArguments(); QStringList args = clParser.positionalArguments();
......
...@@ -153,7 +153,7 @@ Window { ...@@ -153,7 +153,7 @@ Window {
} }
else { else {
errorDialog.text = qsTr("Validation error"); errorDialog.text = qsTr("Validation error");
errorDialog.detailedText = qsTr("Invalid OCS-URL") + " " + ocsUrlHandler.ocsUrl(); errorDialog.detailedText = qsTr("Invalid OCS-URL");
errorDialog.open(); errorDialog.open();
} }
} }
......
SOURCES += $$system(find ../app -type f -name "*.cpp" -or -name "*.qml" -or -name "*.js")
TRANSLATIONS += \
messages.ts \
messages.en_US.ts
RESOURCES += i18n.qrc
<RCC>
<qresource prefix="/i18n">
<file>messages.en_US.qm</file>
</qresource>
</RCC>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment