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
DEFINES += QT_DEPRECATED_WARNINGS
RESOURCES += src/desktop/desktop.qrc
RESOURCES += \
src/desktop/desktop.qrc \
src/i18n/i18n.qrc
DISTFILES += \
README.md \
......
......@@ -34,7 +34,7 @@ void OcsUrlHandler::process()
if (!isValid()) {
QJsonObject result;
result["status"] = QString("error_validation");
result["message"] = QString("Invalid OCS-URL " + ocsUrl_);
result["message"] = tr("Invalid OCS-URL");
emit finishedWithError(result);
return;
}
......@@ -138,14 +138,14 @@ void OcsUrlHandler::saveDownloadedFile(qtlib::NetworkResource *resource)
if (!resource->saveData(destFile.path())) {
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);
resource->deleteLater();
return;
}
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);
resource->deleteLater();
......@@ -159,7 +159,7 @@ void OcsUrlHandler::installDownloadedFile(qtlib::NetworkResource *resource)
if (!resource->saveData(tempFile.path())) {
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);
resource->deleteLater();
return;
......@@ -173,41 +173,41 @@ void OcsUrlHandler::installDownloadedFile(qtlib::NetworkResource *resource)
if (type == "bin"
&& 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")
&& 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")
&& 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")
&& 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"
&& 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"
&& 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"
&& 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())) {
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())) {
result["message"] = QString("The file has been installed into " + destDir.path());
result["message"] = tr("The file has been installed");
}
else {
result["status"] = QString("error_install");
result["message"] = QString("Failed to installation");
result["message"] = tr("Failed to installation");
emit finishedWithError(result);
tempFile.remove();
return;
......
......@@ -2,6 +2,8 @@
#include <QStringList>
#include <QUrl>
#include <QJsonObject>
#include <QTranslator>
#include <QLocale>
#include <QCommandLineParser>
#include <QGuiApplication>
#include <QIcon>
......@@ -25,12 +27,18 @@ int main(int argc, char *argv[])
app.setOrganizationDomain(appConfigApplication["domain"].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
QCommandLineParser clParser;
clParser.setApplicationDescription(appConfigApplication["description"].toString());
clParser.addHelpOption();
clParser.addVersionOption();
clParser.addPositionalArgument("ocsurl", "OCS-URL");
clParser.addPositionalArgument("OCS-URL", "OCS-URL that starts with ocs://");
clParser.process(app);
QStringList args = clParser.positionalArguments();
......
......@@ -153,7 +153,7 @@ Window {
}
else {
errorDialog.text = qsTr("Validation error");
errorDialog.detailedText = qsTr("Invalid OCS-URL") + " " + ocsUrlHandler.ocsUrl();
errorDialog.detailedText = qsTr("Invalid OCS-URL");
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