diff --git a/linphone-app/cmake_builder/linphone_package/macos/Info.plist.in b/linphone-app/cmake_builder/linphone_package/macos/Info.plist.in index 464c91eab..e36a72d02 100644 --- a/linphone-app/cmake_builder/linphone_package/macos/Info.plist.in +++ b/linphone-app/cmake_builder/linphone_package/macos/Info.plist.in @@ -4,6 +4,8 @@ CFBundleDevelopmentRegion English + CFBundleAllowMixedLocalizations + CFBundleName @APPLICATION_NAME@ CFBundleDisplayName diff --git a/linphone-app/src/app/App.cpp b/linphone-app/src/app/App.cpp index 6d700825e..3b081f057 100644 --- a/linphone-app/src/app/App.cpp +++ b/linphone-app/src/app/App.cpp @@ -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 &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; } diff --git a/linphone-app/src/app/App.hpp b/linphone-app/src/app/App.hpp index 142d1a237..7075c98ec 100644 --- a/linphone-app/src/app/App.hpp +++ b/linphone-app/src/app/App.hpp @@ -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; diff --git a/linphone-app/ui/modules/Common/Picker/DatePicker.qml b/linphone-app/ui/modules/Common/Picker/DatePicker.qml index 0d816ac55..6185067a2 100644 --- a/linphone-app/ui/modules/Common/Picker/DatePicker.qml +++ b/linphone-app/ui/modules/Common/Picker/DatePicker.qml @@ -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 diff --git a/linphone-app/ui/modules/Linphone/Chat/Chat.qml b/linphone-app/ui/modules/Linphone/Chat/Chat.qml index 21df29ebc..1726da736 100644 --- a/linphone-app/ui/modules/Linphone/Chat/Chat.qml +++ b/linphone-app/ui/modules/Linphone/Chat/Chat.qml @@ -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) } } } diff --git a/linphone-app/ui/modules/Linphone/History/History.qml b/linphone-app/ui/modules/Linphone/History/History.qml index adadda725..46c4a8663 100644 --- a/linphone-app/ui/modules/Linphone/History/History.qml +++ b/linphone-app/ui/modules/Linphone/History/History.qml @@ -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) } } } diff --git a/linphone-app/ui/views/App/Dialog/NewConference.qml b/linphone-app/ui/views/App/Dialog/NewConference.qml index 94c3c652b..93ae199e3 100644 --- a/linphone-app/ui/views/App/Dialog/NewConference.qml +++ b/linphone-app/ui/views/App/Dialog/NewConference.qml @@ -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 diff --git a/linphone-app/ui/views/App/Main/Conferences.qml b/linphone-app/ui/views/App/Main/Conferences.qml index cfb17e8c2..9df4c5472 100644 --- a/linphone-app/ui/views/App/Main/Conferences.qml +++ b/linphone-app/ui/views/App/Main/Conferences.qml @@ -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) } } }