mirror of
https://git.jami.net/savoirfairelinux/jami-client-qt.git
synced 2025-09-10 12:03:18 +02:00
misc: fix plugin translation
Change-Id: Ia94e47c26ded5f3d7271c1d81253eca6d67001dd
This commit is contained in:
parent
cbdfe26dd1
commit
5df521eb70
4 changed files with 16 additions and 16 deletions
|
@ -57,6 +57,13 @@ AppSettingsManager::setValue(const Settings::Key key, const QVariant& value)
|
|||
settings_->setValue(Settings::toString(key), value);
|
||||
}
|
||||
|
||||
QString
|
||||
AppSettingsManager::getLanguage()
|
||||
{
|
||||
auto pref = getValue(Settings::Key::LANG).toString();
|
||||
return pref == "SYSTEM" ? QLocale::system().name() : pref;
|
||||
}
|
||||
|
||||
void
|
||||
AppSettingsManager::loadTranslations()
|
||||
{
|
||||
|
@ -75,9 +82,7 @@ AppSettingsManager::loadTranslations()
|
|||
qApp->removeTranslator(tr);
|
||||
installedTr_.clear();
|
||||
|
||||
auto pref = getValue(Settings::Key::LANG).toString();
|
||||
|
||||
QString locale_name = pref == "SYSTEM" ? QLocale::system().name() : pref;
|
||||
QString locale_name = getLanguage();
|
||||
qDebug() << QString("Using locale: %1").arg(locale_name);
|
||||
QString locale_lang = locale_name.split('_')[0];
|
||||
|
||||
|
|
|
@ -111,6 +111,7 @@ public:
|
|||
|
||||
Q_INVOKABLE QVariant getValue(const Settings::Key key);
|
||||
Q_INVOKABLE void setValue(const Settings::Key key, const QVariant& value);
|
||||
QString getLanguage();
|
||||
|
||||
void loadTranslations();
|
||||
|
||||
|
|
|
@ -132,7 +132,7 @@ MainApplication::init()
|
|||
setWindowIcon(QIcon(":/images/jami.ico"));
|
||||
|
||||
Utils::removeOldVersions();
|
||||
qputenv("JAMI_LANG", settingsManager_->getValue(Settings::Key::LANG).toByteArray());
|
||||
qputenv("JAMI_LANG", settingsManager_->getLanguage().toUtf8());
|
||||
settingsManager_->loadTranslations();
|
||||
setApplicationFont();
|
||||
|
||||
|
|
|
@ -688,14 +688,11 @@ MessagesAdapter::getFormattedTime(const quint64 timestamp)
|
|||
auto interval = qFloor(seconds / 60);
|
||||
|
||||
if (interval > 1) {
|
||||
auto curLang = settingsManager_->getValue(Settings::Key::LANG);
|
||||
auto curLocal(QLocale(curLang.toString()));
|
||||
auto curLang = settingsManager_->getLanguage();
|
||||
auto curLocal = QLocale(curLang);
|
||||
auto curTime = QDateTime::fromSecsSinceEpoch(timestamp).time();
|
||||
QString timeLocale;
|
||||
if (curLang == "SYSTEM")
|
||||
timeLocale = QLocale::system().toString(curTime, QLocale::system().ShortFormat);
|
||||
else
|
||||
timeLocale = curLocal.toString(curTime, curLocal.ShortFormat);
|
||||
timeLocale = curLocal.toString(curTime, curLocal.ShortFormat);
|
||||
|
||||
return timeLocale;
|
||||
}
|
||||
|
@ -722,14 +719,11 @@ MessagesAdapter::getFormattedDay(const quint64 timestamp)
|
|||
if (timestampDate.daysTo(currentDate) == 1)
|
||||
return QObject::tr("Yesterday");
|
||||
|
||||
auto curLang = settingsManager_->getValue(Settings::Key::LANG);
|
||||
auto curLocal(QLocale(curLang.toString()));
|
||||
auto curLang = settingsManager_->getLanguage();
|
||||
auto curLocal = QLocale(curLang);
|
||||
auto curDate = QDateTime::fromSecsSinceEpoch(timestamp).date();
|
||||
QString dateLocale;
|
||||
if (curLang == "SYSTEM")
|
||||
dateLocale = QLocale::system().toString(curDate, QLocale::system().ShortFormat);
|
||||
else
|
||||
dateLocale = curLocal.toString(curDate, curLocal.ShortFormat);
|
||||
dateLocale = curLocal.toString(curDate, curLocal.ShortFormat);
|
||||
|
||||
return dateLocale;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue