Translation paths based on OS
This commit is contained in:
@@ -120,7 +120,8 @@ SOURCES += src/main.cpp \
|
||||
src/capture/workers/launcher/terminallauncher.cpp \
|
||||
src/config/visualseditor.cpp \
|
||||
src/config/extendedslider.cpp \
|
||||
src/capture/workers/launcher/openwithprogram.cpp
|
||||
src/capture/workers/launcher/openwithprogram.cpp \
|
||||
src/utils/pathinfo.cpp
|
||||
|
||||
HEADERS += src/capture/widgets/buttonhandler.h \
|
||||
src/infowindow.h \
|
||||
@@ -176,7 +177,8 @@ HEADERS += src/capture/widgets/buttonhandler.h \
|
||||
src/capture/workers/launcher/terminallauncher.h \
|
||||
src/config/visualseditor.h \
|
||||
src/config/extendedslider.h \
|
||||
src/capture/workers/launcher/openwithprogram.h
|
||||
src/capture/workers/launcher/openwithprogram.h \
|
||||
src/utils/pathinfo.h
|
||||
|
||||
unix:!macx {
|
||||
SOURCES += src/core/flameshotdbusadapter.cpp \
|
||||
|
||||
13
src/main.cpp
13
src/main.cpp
@@ -21,6 +21,7 @@
|
||||
#include "src/utils/confighandler.h"
|
||||
#include "src/cli/commandlineparser.h"
|
||||
#include "src/utils/systemnotification.h"
|
||||
#include "src/utils/pathinfo.h"
|
||||
#include <QApplication>
|
||||
#include <QTranslator>
|
||||
#include <QTextStream>
|
||||
@@ -41,8 +42,16 @@ int main(int argc, char *argv[]) {
|
||||
qApp->setApplicationVersion(static_cast<QString>(APP_VERSION));
|
||||
|
||||
QTranslator translator;
|
||||
translator.load(QLocale::system().language(),
|
||||
"Internationalization", "_", "/usr/share/flameshot/translations/");
|
||||
QStringList trPaths = PathInfo::translations();
|
||||
bool match = false;
|
||||
for (const QString &path: trPaths) {
|
||||
match = translator.load(QLocale::system().language(),
|
||||
"Internationalization", "_",
|
||||
path);
|
||||
if (match) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// no arguments, just launch Flameshot
|
||||
if (argc == 1) {
|
||||
|
||||
36
src/utils/pathinfo.cpp
Normal file
36
src/utils/pathinfo.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
// Copyright(c) 2017-2018 Alejandro Sirgo Rica & Contributors
|
||||
//
|
||||
// This file is part of Flameshot.
|
||||
//
|
||||
// Flameshot is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Flameshot 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 General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Flameshot. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "pathinfo.h"
|
||||
#include <QApplication>
|
||||
#include <QFileInfo>
|
||||
#include <QDir>
|
||||
|
||||
QStringList PathInfo::translations() {
|
||||
QString binaryPath = QFileInfo(qApp->applicationFilePath())
|
||||
.absoluteFilePath();
|
||||
QString trPath = QDir::toNativeSeparators(binaryPath) + "translations";
|
||||
#if defined(Q_OS_LINUX)
|
||||
return QStringList()
|
||||
<< trPath
|
||||
<< "/usr/share/flameshot/translations"
|
||||
<< "/usr/local/share/flameshot/translations";
|
||||
#elif defined(Q_OS_WIN)
|
||||
return QStringList()
|
||||
<< trPath;
|
||||
#endif
|
||||
}
|
||||
26
src/utils/pathinfo.h
Normal file
26
src/utils/pathinfo.h
Normal file
@@ -0,0 +1,26 @@
|
||||
// Copyright(c) 2017-2018 Alejandro Sirgo Rica & Contributors
|
||||
//
|
||||
// This file is part of Flameshot.
|
||||
//
|
||||
// Flameshot is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Flameshot 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 General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Flameshot. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QStringList>
|
||||
|
||||
class PathInfo
|
||||
{
|
||||
public:
|
||||
static QStringList translations();
|
||||
};
|
||||
Reference in New Issue
Block a user