Skip to content

Commit

Permalink
[Trans] update default path
Browse files Browse the repository at this point in the history
  • Loading branch information
jared2020 committed Dec 18, 2020
1 parent 41a9f53 commit fa91d11
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions 3rdparty/TaoCommon/Trans/Trans.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@ const static auto cEnglisthStr = u8"English";
const static auto cChineseStr = u8"简体中文";
Trans::Trans(QObject *parent) : QTranslator(parent) {}

void Trans::beforeUiReady(QQmlContext *ctx)
void Trans::beforeUiReady(QQmlContext *ctx, const QString &folder)
{
m_ctx = ctx;
ctx->setContextProperty("trans", this);
loadFolder(qApp->applicationDirPath() + "/Trans");
if (folder.isEmpty()) {
loadFolder(qApp->applicationDirPath() + "/Trans");
} else {
loadFolder(folder);
}
qApp->installTranslator(this);
}

Expand Down
4 changes: 2 additions & 2 deletions 3rdparty/TaoCommon/Trans/Trans.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <QTranslator>
#include "TaoCommonGlobal.h"
class QQmlContext;
class Trans : public QTranslator
class TAO_API Trans : public QTranslator
{
Q_OBJECT
Q_PROPERTY(QString currentLang READ currentLang WRITE setCurrentLang NOTIFY currentLangChanged)
Expand All @@ -21,7 +21,7 @@ class Trans : public QTranslator
Q_INVOKABLE bool load(QString &lang, const QString &filePath);

public:
void beforeUiReady(QQmlContext *ctx);
void beforeUiReady(QQmlContext *ctx, const QString &folder = {});

void afterUiReady();

Expand Down

0 comments on commit fa91d11

Please sign in to comment.