mirror of
https://github.com/tnodir/fort
synced 2024-11-15 08:25:20 +00:00
UI: TranslationManager: Minor refactor
This commit is contained in:
parent
ec6d1410fe
commit
2a6a22ed4b
@ -11,8 +11,12 @@
|
||||
#include <util/osutil.h>
|
||||
#include <util/stringutil.h>
|
||||
|
||||
#define TRANSLATION_FILE_PREFIX "i18n_"
|
||||
#define TRANSLATION_FILE_SUFFIX ".qm"
|
||||
namespace {
|
||||
|
||||
constexpr const QLatin1String translationFilePrefix("i18n_");
|
||||
constexpr const QLatin1String translationFileSuffix(".qm");
|
||||
|
||||
}
|
||||
|
||||
TranslationManager::TranslationManager(QObject *parent) : QObject(parent)
|
||||
{
|
||||
@ -50,12 +54,11 @@ void TranslationManager::setupTranslation()
|
||||
void TranslationManager::setupLocales()
|
||||
{
|
||||
// Collect locales from i18n files
|
||||
const auto i18nFileInfos =
|
||||
QDir(i18nDir()).entryInfoList(QStringList() << ("*" TRANSLATION_FILE_SUFFIX));
|
||||
const auto i18nFileInfos = QDir(i18nDir()).entryInfoList({ ('*' + translationFileSuffix) });
|
||||
|
||||
const QString systemLanguageName = OsUtil::systemLanguageName();
|
||||
|
||||
const int prefixLen = QLatin1String(TRANSLATION_FILE_PREFIX).size();
|
||||
const int prefixLen = translationFilePrefix.size();
|
||||
|
||||
m_locales.append(QLocale::system());
|
||||
m_locales.append(QLocale(QLocale::English, QLocale::UnitedStates));
|
||||
@ -186,7 +189,7 @@ QTranslator *TranslationManager::loadTranslator(int language, const QLocale &loc
|
||||
|
||||
// Load .qm file
|
||||
auto translator = new QTranslator(this);
|
||||
if (!translator->load(TRANSLATION_FILE_PREFIX + locale.name(), i18nDir())) {
|
||||
if (!translator->load(translationFilePrefix + locale.name(), i18nDir())) {
|
||||
delete translator;
|
||||
return nullptr;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user