fix: should install and use qm files

This commit is contained in:
Gary Wang 2020-06-05 00:20:36 +08:00
parent dbd576161a
commit 5c3523648e
3 changed files with 46 additions and 0 deletions

View File

@ -125,3 +125,17 @@ install (
TARGETS ${EXE_NAME}
${INSTALL_TARGETS_DEFAULT_ARGS}
)
if (WIN32)
set (QM_FILE_INSTALL_DIR "${CMAKE_INSTALL_BINDIR}/translations")
else ()
set (QM_FILE_INSTALL_DIR "${CMAKE_INSTALL_FULL_DATADIR}/pineapple-music/translations")
target_compile_definitions(${EXE_NAME}
PRIVATE QM_FILE_INSTALL_DIR=${QM_FILE_INSTALL_DIR}
)
endif ()
install (
FILES ${PMUSIC_QM_FILES}
DESTINATION ${QM_FILE_INSTALL_DIR}
)

View File

@ -23,6 +23,26 @@
<source>Audio Files</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Pineapple Player</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>^</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No song loaded...</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Drag and drop file to load</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>0:00</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>main</name>

View File

@ -6,11 +6,23 @@
#include <QCommandLineParser>
#include <QUrl>
#include <QDebug>
#include <QTranslator>
#include <QDir>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QTranslator translator;
QString qmDir;
#ifdef _WIN32
qmDir = QDir(QCoreApplication::applicationDirPath()).absoluteFilePath("translations");
#else
qmDir = QT_STRINGIFY(QM_FILE_INSTALL_DIR);
#endif
translator.load(QString("pineapple-music_%1").arg(QLocale::system().name()), qmDir);
a.installTranslator(&translator);
// parse commandline arguments
QCommandLineParser parser;
parser.addPositionalArgument("File list", QCoreApplication::translate("main", "File list."));