Skip to content
Snippets Groups Projects
Commit 5df521eb authored by Aline Gondim Santos's avatar Aline Gondim Santos Committed by Sébastien Blin
Browse files

misc: fix plugin translation

Change-Id: Ia94e47c26ded5f3d7271c1d81253eca6d67001dd
parent cbdfe26d
No related branches found
No related tags found
No related merge requests found
...@@ -57,6 +57,13 @@ AppSettingsManager::setValue(const Settings::Key key, const QVariant& value) ...@@ -57,6 +57,13 @@ AppSettingsManager::setValue(const Settings::Key key, const QVariant& value)
settings_->setValue(Settings::toString(key), 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 void
AppSettingsManager::loadTranslations() AppSettingsManager::loadTranslations()
{ {
...@@ -75,9 +82,7 @@ AppSettingsManager::loadTranslations() ...@@ -75,9 +82,7 @@ AppSettingsManager::loadTranslations()
qApp->removeTranslator(tr); qApp->removeTranslator(tr);
installedTr_.clear(); installedTr_.clear();
auto pref = getValue(Settings::Key::LANG).toString(); QString locale_name = getLanguage();
QString locale_name = pref == "SYSTEM" ? QLocale::system().name() : pref;
qDebug() << QString("Using locale: %1").arg(locale_name); qDebug() << QString("Using locale: %1").arg(locale_name);
QString locale_lang = locale_name.split('_')[0]; QString locale_lang = locale_name.split('_')[0];
......
...@@ -111,6 +111,7 @@ public: ...@@ -111,6 +111,7 @@ public:
Q_INVOKABLE QVariant getValue(const Settings::Key key); Q_INVOKABLE QVariant getValue(const Settings::Key key);
Q_INVOKABLE void setValue(const Settings::Key key, const QVariant& value); Q_INVOKABLE void setValue(const Settings::Key key, const QVariant& value);
QString getLanguage();
void loadTranslations(); void loadTranslations();
......
...@@ -132,7 +132,7 @@ MainApplication::init() ...@@ -132,7 +132,7 @@ MainApplication::init()
setWindowIcon(QIcon(":/images/jami.ico")); setWindowIcon(QIcon(":/images/jami.ico"));
Utils::removeOldVersions(); Utils::removeOldVersions();
qputenv("JAMI_LANG", settingsManager_->getValue(Settings::Key::LANG).toByteArray()); qputenv("JAMI_LANG", settingsManager_->getLanguage().toUtf8());
settingsManager_->loadTranslations(); settingsManager_->loadTranslations();
setApplicationFont(); setApplicationFont();
......
...@@ -688,14 +688,11 @@ MessagesAdapter::getFormattedTime(const quint64 timestamp) ...@@ -688,14 +688,11 @@ MessagesAdapter::getFormattedTime(const quint64 timestamp)
auto interval = qFloor(seconds / 60); auto interval = qFloor(seconds / 60);
if (interval > 1) { if (interval > 1) {
auto curLang = settingsManager_->getValue(Settings::Key::LANG); auto curLang = settingsManager_->getLanguage();
auto curLocal(QLocale(curLang.toString())); auto curLocal = QLocale(curLang);
auto curTime = QDateTime::fromSecsSinceEpoch(timestamp).time(); auto curTime = QDateTime::fromSecsSinceEpoch(timestamp).time();
QString timeLocale; QString timeLocale;
if (curLang == "SYSTEM") timeLocale = curLocal.toString(curTime, curLocal.ShortFormat);
timeLocale = QLocale::system().toString(curTime, QLocale::system().ShortFormat);
else
timeLocale = curLocal.toString(curTime, curLocal.ShortFormat);
return timeLocale; return timeLocale;
} }
...@@ -722,14 +719,11 @@ MessagesAdapter::getFormattedDay(const quint64 timestamp) ...@@ -722,14 +719,11 @@ MessagesAdapter::getFormattedDay(const quint64 timestamp)
if (timestampDate.daysTo(currentDate) == 1) if (timestampDate.daysTo(currentDate) == 1)
return QObject::tr("Yesterday"); return QObject::tr("Yesterday");
auto curLang = settingsManager_->getValue(Settings::Key::LANG); auto curLang = settingsManager_->getLanguage();
auto curLocal(QLocale(curLang.toString())); auto curLocal = QLocale(curLang);
auto curDate = QDateTime::fromSecsSinceEpoch(timestamp).date(); auto curDate = QDateTime::fromSecsSinceEpoch(timestamp).date();
QString dateLocale; QString dateLocale;
if (curLang == "SYSTEM") dateLocale = curLocal.toString(curDate, curLocal.ShortFormat);
dateLocale = QLocale::system().toString(curDate, QLocale::system().ShortFormat);
else
dateLocale = curLocal.toString(curDate, curLocal.ShortFormat);
return dateLocale; return dateLocale;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment