mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-26 00:08:13 +00:00
System languages based on QLocale and not name.
This commit is contained in:
parent
61e1050cdc
commit
76a6a8b6ea
8 changed files with 33 additions and 30 deletions
|
|
@ -4,6 +4,8 @@
|
|||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>English</string>
|
||||
<key>CFBundleAllowMixedLocalizations</key>
|
||||
<true/>
|
||||
<key>CFBundleName</key>
|
||||
<string>@APPLICATION_NAME@</string>
|
||||
<key>CFBundleDisplayName</key>
|
||||
|
|
|
|||
|
|
@ -254,7 +254,7 @@ App::App (int &argc, char *argv[]) : SingleApplication(argc, argv, true, Mode::U
|
|||
mAutoStart = autoStartEnabled();
|
||||
|
||||
qInfo() << QStringLiteral("Starting " APPLICATION_NAME " (bin: " EXECUTABLE_NAME ")");
|
||||
qInfo() << QStringLiteral("Use locale: %1").arg(mLocale);
|
||||
qInfo() << QStringLiteral("Use locale: %1 with language: %2").arg(mLocale.name()).arg(QLocale::languageToString(mLocale.language()));
|
||||
}
|
||||
|
||||
App::~App () {
|
||||
|
|
@ -841,22 +841,34 @@ void App::initLocale (const shared_ptr<linphone::Config> &config) {
|
|||
QString locale;
|
||||
|
||||
// Use english. This default translator is used if there are no found translations in others loads
|
||||
mLocale = Constants::DefaultLocale;
|
||||
if (!installLocale(*this, *mDefaultTranslator, QLocale(mLocale)))
|
||||
mLocale = QLocale(Constants::DefaultLocale);
|
||||
if (!installLocale(*this, *mDefaultTranslator, mLocale))
|
||||
qFatal("Unable to install default translator.");
|
||||
|
||||
if (config)
|
||||
locale = Utils::coreStringToAppString(config->getString(SettingsModel::UiSection, "locale", ""));
|
||||
|
||||
if (!locale.isEmpty() && installLocale(*this, *mTranslator, QLocale(locale))) {
|
||||
mLocale = locale;
|
||||
mLocale = QLocale(locale);
|
||||
return;
|
||||
}
|
||||
|
||||
// Try to use system locale.
|
||||
QLocale sysLocale = QLocale(QLocale::system().name());// Use Locale from name because Qt has a bug where it didn't use the QLocale::language (aka : translator.language != lolcale.language) on Mac.
|
||||
// Try to use system locale.
|
||||
//#ifdef Q_OS_MACOS
|
||||
// Use this workaround if there is still an issue about detecting wrong language from system on Mac. Qt doesn't use the current system language on QLocale::system(). So we need to get it from user settings and overwrite its Locale.
|
||||
// QSettings settings;
|
||||
// QString preferredLanguage = settings.value("AppleLanguages").toStringList().first();
|
||||
// QStringList qtLocale = QLocale::system().name().split('_');
|
||||
// if(qtLocale[0] != preferredLanguage){
|
||||
// qInfo() << "Override Qt language from " << qtLocale[0] << " to the preferred language : " << preferredLanguage;
|
||||
// qtLocale[0] = preferredLanguage;
|
||||
// }
|
||||
// QLocale sysLocale = QLocale(qtLocale.join('_'));
|
||||
//#else
|
||||
QLocale sysLocale(QLocale::system().name());// Use Locale from name because Qt has a bug where it didn't use the QLocale::language (aka : translator.language != locale.language) on Mac.
|
||||
//#endif
|
||||
if (installLocale(*this, *mTranslator, sysLocale)) {
|
||||
mLocale = sysLocale.name();
|
||||
mLocale = sysLocale;
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -878,7 +890,7 @@ void App::setConfigLocale (const QString &locale) {
|
|||
emit configLocaleChanged(locale);
|
||||
}
|
||||
|
||||
QString App::getLocale () const {
|
||||
QLocale App::getLocale () const {
|
||||
return mLocale;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ class App : public SingleApplication {
|
|||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(QString configLocale READ getConfigLocale WRITE setConfigLocale NOTIFY configLocaleChanged)
|
||||
Q_PROPERTY(QString locale READ getLocale CONSTANT)
|
||||
Q_PROPERTY(QLocale locale READ getLocale CONSTANT)
|
||||
Q_PROPERTY(QVariantList availableLocales READ getAvailableLocales CONSTANT)
|
||||
Q_PROPERTY(QString qtVersion READ getQtVersion CONSTANT)
|
||||
|
||||
|
|
@ -143,7 +143,7 @@ private:
|
|||
QString getConfigLocale () const;
|
||||
void setConfigLocale (const QString &locale);
|
||||
|
||||
QString getLocale () const;
|
||||
QLocale getLocale () const;
|
||||
|
||||
QVariantList getAvailableLocales () const {
|
||||
return mAvailableLocales;
|
||||
|
|
@ -171,7 +171,7 @@ private:
|
|||
}
|
||||
|
||||
QVariantList mAvailableLocales;
|
||||
QString mLocale;
|
||||
QLocale mLocale;
|
||||
|
||||
bool mAutoStart = false;
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import QtQuick.Layouts 1.3
|
|||
|
||||
import Common 1.0
|
||||
import Common.Styles 1.0
|
||||
import Linphone 1.0
|
||||
import Units 1.0
|
||||
|
||||
import 'qrc:/ui/scripts/Utils/utils.js' as Utils
|
||||
|
|
@ -35,7 +36,7 @@ Item{
|
|||
Layout.fillWidth: true
|
||||
Layout.alignment: Qt.AlignCenter
|
||||
horizontalAlignment: Qt.AlignCenter
|
||||
text: new Date(monthList.currentYear, monthList.currentMonth, 15).toLocaleString(Qt.locale(), 'MMMM yyyy')// 15 because of timezones that can change the date for localeString
|
||||
text: new Date(monthList.currentYear, monthList.currentMonth, 15).toLocaleString(App.locale, 'MMMM yyyy')// 15 because of timezones that can change the date for localeString
|
||||
color: DatePickerStyle.title.color
|
||||
font.pointSize: DatePickerStyle.title.pointSize
|
||||
font.capitalization: Font.Capitalize
|
||||
|
|
@ -142,7 +143,7 @@ Item{
|
|||
text: {
|
||||
if(cellItem.day < 0){
|
||||
// Magic date to set day names in this order : 'S', 'M', 'T', 'W', 'T', 'F', 'S' in Locale
|
||||
return Utils.exactDate(new Date(2000,9,index+1)).toLocaleString(Qt.locale(), 'ddd')[0].toUpperCase()
|
||||
return Utils.exactDate(new Date(2000,9,index+1)).toLocaleString(App.locale, 'ddd')[0].toUpperCase()
|
||||
}else if(cellItem.cellDate.getMonth() == month && (!hideOldDates || new Date(year, month, cellItem.date+1) >= new Date())) // new Date use time too
|
||||
return cellItem.date
|
||||
else
|
||||
|
|
|
|||
|
|
@ -156,12 +156,7 @@ Rectangle {
|
|||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
|
||||
|
||||
// Cast section to integer because Qt converts the
|
||||
// sectionDate in string!!!
|
||||
text: new Date(section).toLocaleDateString(
|
||||
Qt.locale(App.locale)
|
||||
)
|
||||
text: new Date(section).toLocaleDateString(App.locale)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -97,15 +97,12 @@ Rectangle {
|
|||
font {
|
||||
bold: true
|
||||
pointSize: HistoryStyle.sectionHeading.text.pointSize
|
||||
capitalization: Font.Capitalize
|
||||
}
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
|
||||
// Cast section to integer because Qt converts the
|
||||
// sectionDate in string!!!
|
||||
text: new Date(section).toLocaleDateString(
|
||||
Qt.locale(App.locale)
|
||||
)
|
||||
text: new Date(section).toLocaleDateString(App.locale)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -270,7 +270,7 @@ DialogPlus {
|
|||
Layout.fillHeight: true
|
||||
Layout.margins: 10
|
||||
columns: 4
|
||||
property var locale: Qt.locale()
|
||||
property var locale: App.locale
|
||||
property date currentDate: new Date()
|
||||
property int cellWidth: (parent.width-15-20)/columns
|
||||
|
||||
|
|
|
|||
|
|
@ -139,11 +139,7 @@ Item{
|
|||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
|
||||
// Cast section to integer because Qt converts the
|
||||
// sectionDate in string!!!
|
||||
text: new Date(section).toLocaleDateString(
|
||||
Qt.locale(App.locale)
|
||||
)
|
||||
text: new Date(section).toLocaleDateString(App.locale)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue