Add static data path for ... static data. Like translations. Move translations there.
This commit is contained in:
parent
8a8c4193e6
commit
7f2a16917e
15
MultiMC.cpp
15
MultiMC.cpp
@ -161,6 +161,17 @@ MultiMC::MultiMC(int &argc, char **argv, bool root_override)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// static data paths... mostly just for translations
|
||||||
|
#ifdef Q_OS_LINUX
|
||||||
|
QDir foo(PathCombine(binPath, ".."));
|
||||||
|
staticDataPath = foo.absolutePath();
|
||||||
|
#elif defined(Q_OS_WIN32)
|
||||||
|
staticDataPath = binPath;
|
||||||
|
#elif defined(Q_OS_MAC)
|
||||||
|
QDir foo(PathCombine(rootPath, "Contents/Resources"));
|
||||||
|
staticDataPath = foo.absolutePath();
|
||||||
|
#endif
|
||||||
|
|
||||||
// init the logger
|
// init the logger
|
||||||
initLogger();
|
initLogger();
|
||||||
|
|
||||||
@ -179,6 +190,7 @@ MultiMC::MultiMC(int &argc, char **argv, bool root_override)
|
|||||||
}
|
}
|
||||||
QLOG_INFO() << "Binary path : " << binPath;
|
QLOG_INFO() << "Binary path : " << binPath;
|
||||||
QLOG_INFO() << "Application root path : " << rootPath;
|
QLOG_INFO() << "Application root path : " << rootPath;
|
||||||
|
QLOG_INFO() << "Static data path : " << staticDataPath;
|
||||||
|
|
||||||
// load settings
|
// load settings
|
||||||
initGlobalSettings();
|
initGlobalSettings();
|
||||||
@ -287,7 +299,8 @@ void MultiMC::initTranslations()
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_mmc_translator.reset(new QTranslator());
|
m_mmc_translator.reset(new QTranslator());
|
||||||
if (m_mmc_translator->load("mmc_" + locale.bcp47Name(), MMC->root() + "/translations"))
|
if (m_mmc_translator->load("mmc_" + locale.bcp47Name(),
|
||||||
|
MMC->staticData() + "/translations"))
|
||||||
{
|
{
|
||||||
QLOG_DEBUG() << "Loading MMC Language File for"
|
QLOG_DEBUG() << "Loading MMC Language File for"
|
||||||
<< locale.bcp47Name().toLocal8Bit().constData() << "...";
|
<< locale.bcp47Name().toLocal8Bit().constData() << "...";
|
||||||
|
@ -147,6 +147,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
bool openJsonEditor(const QString &filename);
|
bool openJsonEditor(const QString &filename);
|
||||||
|
|
||||||
|
/// this is the static data. it stores things that don't move.
|
||||||
|
const QString &staticData()
|
||||||
|
{
|
||||||
|
return staticDataPath;
|
||||||
|
}
|
||||||
/// this is the root of the 'installation'. Used for automatic updates
|
/// this is the root of the 'installation'. Used for automatic updates
|
||||||
const QString &root()
|
const QString &root()
|
||||||
{
|
{
|
||||||
@ -215,6 +220,7 @@ private:
|
|||||||
UpdateFlags m_updateOnExitFlags = None;
|
UpdateFlags m_updateOnExitFlags = None;
|
||||||
|
|
||||||
QString rootPath;
|
QString rootPath;
|
||||||
|
QString staticDataPath;
|
||||||
QString binPath;
|
QString binPath;
|
||||||
QString dataPath;
|
QString dataPath;
|
||||||
QString origcwdPath;
|
QString origcwdPath;
|
||||||
|
@ -407,8 +407,8 @@ void SettingsDialog::loadSettings(SettingsObject *s)
|
|||||||
// Language
|
// Language
|
||||||
ui->languageBox->clear();
|
ui->languageBox->clear();
|
||||||
ui->languageBox->addItem(tr("English"), QLocale(QLocale::English));
|
ui->languageBox->addItem(tr("English"), QLocale(QLocale::English));
|
||||||
foreach(const QString & lang,
|
foreach(const QString & lang, QDir(MMC->staticData() + "/translations")
|
||||||
QDir(MMC->root() + "/translations").entryList(QStringList() << "*.qm", QDir::Files))
|
.entryList(QStringList() << "*.qm", QDir::Files))
|
||||||
{
|
{
|
||||||
QLocale locale(lang.section(QRegExp("[_\.]"), 1));
|
QLocale locale(lang.section(QRegExp("[_\.]"), 1));
|
||||||
ui->languageBox->addItem(QLocale::languageToString(locale.language()), locale);
|
ui->languageBox->addItem(QLocale::languageToString(locale.language()), locale);
|
||||||
|
@ -10,7 +10,7 @@ add_custom_target(translations_update DEPENDS ${TRANSLATION_MESSAGES})
|
|||||||
add_custom_target(translations DEPENDS ${TRANSLATION_QM})
|
add_custom_target(translations DEPENDS ${TRANSLATION_QM})
|
||||||
|
|
||||||
if(APPLE AND UNIX) ## OSX
|
if(APPLE AND UNIX) ## OSX
|
||||||
install(FILES ${TRANSLATION_QM} DESTINATION MultiMC.app/Contents/MacOS/translations)
|
install(FILES ${TRANSLATION_QM} DESTINATION MultiMC.app/Contents/Resources/translations)
|
||||||
else()
|
else()
|
||||||
install(FILES ${TRANSLATION_QM} DESTINATION translations)
|
install(FILES ${TRANSLATION_QM} DESTINATION translations)
|
||||||
endif()
|
endif()
|
||||||
|
Loading…
Reference in New Issue
Block a user