From 4709c938dba72b69a91b584bfe34010fec9e2d43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Fri, 21 Oct 2022 15:00:29 +0200 Subject: [PATCH] Apple: Add CFBundleAllowMixedLocalizations=YES to Info.plist files We currently don't have any machinery for qmake or CMake to map translations declared via TRANSLATIONS += or qt_add_translations to the Info.plist CFBundleLocalizations key. This results in macOS and iOS falling back to the development region, CFBundleDevelopmentRegion, as the only supported localization of the app, which is in most cases set to 'en'. Unfortunately this doesn't work well with the behavior of iOS 11+ and macOS 10.13+ where the OS will set the locale of the app to the best match between the app's supported localizations and the user's preferred language. https://developer.apple.com/library/archive/qa/qa1828/ Since we only support a single localization, the development region, the locale always ends up as 'en_', which after QTBUG-104930 is also reflected in the QLocale's uiLanguages(), resulting in the QTranslator machinery always picking English translation for the app. As long as we don't explicitly declare CFBundleLocalizations we need to opt out of the system's behavior of finding the best match between the app's declared localizations and the user's preferences, which we can do via the CFBundleAllowMixedLocalizations key. Fixes: QTBUG-63324 Pick-to: 6.4 Change-Id: If7586d342148cbbb1d2a152cef039aad4448b13c Reviewed-by: Richard Moe Gustavsen --- cmake/ios/Info.plist.app.in | 2 ++ cmake/macos/MacOSXBundleInfo.plist.in | 2 ++ mkspecs/macx-clang/Info.plist.app | 2 ++ mkspecs/macx-ios-clang/Info.plist.app | 2 ++ mkspecs/macx-xcode/QtTest.plist | 2 ++ mkspecs/unsupported/macx-tvos-clang/Info.plist.app | 2 ++ mkspecs/unsupported/macx-watchos-clang/Info.plist.app | 2 ++ tests/manual/ios_assets/Info.ios.cmake.plist | 2 ++ 8 files changed, 16 insertions(+) diff --git a/cmake/ios/Info.plist.app.in b/cmake/ios/Info.plist.app.in index abaf3418db5..2f138282130 100644 --- a/cmake/ios/Info.plist.app.in +++ b/cmake/ios/Info.plist.app.in @@ -31,6 +31,8 @@ CFBundleDevelopmentRegion $(DEVELOPMENT_LANGUAGE) + CFBundleAllowMixedLocalizations + LSRequiresIPhoneOS diff --git a/cmake/macos/MacOSXBundleInfo.plist.in b/cmake/macos/MacOSXBundleInfo.plist.in index 75de15ab50f..c7915216551 100644 --- a/cmake/macos/MacOSXBundleInfo.plist.in +++ b/cmake/macos/MacOSXBundleInfo.plist.in @@ -30,6 +30,8 @@ CFBundleDevelopmentRegion en + CFBundleAllowMixedLocalizations + NSPrincipalClass NSApplication diff --git a/mkspecs/macx-clang/Info.plist.app b/mkspecs/macx-clang/Info.plist.app index 9aca41b6dd9..e37d8975f85 100644 --- a/mkspecs/macx-clang/Info.plist.app +++ b/mkspecs/macx-clang/Info.plist.app @@ -22,5 +22,7 @@ CFBundleDevelopmentRegion en + CFBundleAllowMixedLocalizations + diff --git a/mkspecs/macx-ios-clang/Info.plist.app b/mkspecs/macx-ios-clang/Info.plist.app index 76b5bc1b2ad..56c1e1900c4 100644 --- a/mkspecs/macx-ios-clang/Info.plist.app +++ b/mkspecs/macx-ios-clang/Info.plist.app @@ -37,6 +37,8 @@ CFBundleDevelopmentRegion $(DEVELOPMENT_LANGUAGE) + CFBundleAllowMixedLocalizations + UISupportedInterfaceOrientations diff --git a/mkspecs/macx-xcode/QtTest.plist b/mkspecs/macx-xcode/QtTest.plist index 41dddb1a535..9ee08217efb 100644 --- a/mkspecs/macx-xcode/QtTest.plist +++ b/mkspecs/macx-xcode/QtTest.plist @@ -4,6 +4,8 @@ CFBundleDevelopmentRegion en + CFBundleAllowMixedLocalizations + CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier diff --git a/mkspecs/unsupported/macx-tvos-clang/Info.plist.app b/mkspecs/unsupported/macx-tvos-clang/Info.plist.app index b9b67fe41e9..e94aeb5b929 100644 --- a/mkspecs/unsupported/macx-tvos-clang/Info.plist.app +++ b/mkspecs/unsupported/macx-tvos-clang/Info.plist.app @@ -4,6 +4,8 @@ CFBundleDevelopmentRegion en + CFBundleAllowMixedLocalizations + CFBundleDisplayName ${PRODUCT_NAME} CFBundleExecutable diff --git a/mkspecs/unsupported/macx-watchos-clang/Info.plist.app b/mkspecs/unsupported/macx-watchos-clang/Info.plist.app index 5ac0ef78a08..72c2af30b1c 100644 --- a/mkspecs/unsupported/macx-watchos-clang/Info.plist.app +++ b/mkspecs/unsupported/macx-watchos-clang/Info.plist.app @@ -4,6 +4,8 @@ CFBundleDevelopmentRegion en + CFBundleAllowMixedLocalizations + CFBundleDisplayName ${PRODUCT_NAME} CFBundleExecutable diff --git a/tests/manual/ios_assets/Info.ios.cmake.plist b/tests/manual/ios_assets/Info.ios.cmake.plist index 3bb6f562ee5..2b2bb695226 100644 --- a/tests/manual/ios_assets/Info.ios.cmake.plist +++ b/tests/manual/ios_assets/Info.ios.cmake.plist @@ -34,6 +34,8 @@ CFBundleDevelopmentRegion en + CFBundleAllowMixedLocalizations + LSRequiresIPhoneOS