Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
cmake: Load lang from source tree or install location
Browse files Browse the repository at this point in the history
  • Loading branch information
cryptomilk committed Dec 20, 2018
1 parent 749d8f3 commit 115ade8
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 5 deletions.
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -114,5 +114,4 @@ install(TARGETS
${CMAKE_INSTALL_BINDIR}
COMPONENT ${PROJECT_NAME})

add_subdirectory(lng)
add_subdirectory(res)
17 changes: 14 additions & 3 deletions mainwindow.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "mainwindow.h"
#include "config.h"

int main(int argc, char *argv[])
{
Expand All @@ -17,15 +18,25 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)

if(!QLocale::system().name().startsWith("en_"))
{
if(appTranslator.load("rrcc_" + QLocale::system().name(), QApplication::applicationDirPath() + "/lng"))
QString resource_dir;

resource_dir = QString::fromUtf8(RRCC_INSOURCE_RESOURCE_DIR);
if (!QDir(resource_dir).exists()) {
resource_dir = QString::fromUtf8(RRCC_INSTALL_RESOURCE_DIR);
if (!QDir(resource_dir).exists()) {
resource_dir = QApplication::applicationDirPath();
}
}

if(appTranslator.load("rrcc_" + QLocale::system().name(), resource_dir + "/lang"))
{
QApplication::installTranslator(&appTranslator);

if(baseTranslator.load("qtbase_" + QLocale::system().name(), QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
{
QApplication::installTranslator(&baseTranslator);
}
else if(baseTranslator.load("qtbase_" + QLocale::system().name(), QApplication::applicationDirPath() + "/lng"))
else if(baseTranslator.load("qtbase_" + QLocale::system().name(), resource_dir + "/lang"))
{
QApplication::installTranslator(&baseTranslator);
}
Expand All @@ -34,7 +45,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
{
QApplication::installTranslator(&helpTranslator);
}
else if(helpTranslator.load("qt_help_" + QLocale::system().name(), QApplication::applicationDirPath() + "/lng"))
else if(helpTranslator.load("qt_help_" + QLocale::system().name(), resource_dir + "/lang"))
{
QApplication::installTranslator(&helpTranslator);
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion rrcc.pro
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ LIBS += -lssh
FORMS += res/ui/mainwindow.ui res/ui/history.ui res/ui/timer.ui res/ui/setup.ui res/ui/logger.ui res/ui/upload.ui res/ui/packager.ui res/ui/unpackager.ui res/ui/converter.ui res/ui/about.ui res/ui/zones.ui res/ui/installer.ui res/ui/uninstaller.ui res/ui/update.ui res/ui/download.ui
RESOURCES += res/rrcc.qrc

TRANSLATIONS+= lng/rrcc_de.ts
TRANSLATIONS+= res/lang/rrcc_de.ts

unix:!macx {
QMAKE_LFLAGS+= -Wl,-rpath=.
Expand Down

0 comments on commit 115ade8

Please sign in to comment.