Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Fix: fallback to device locale on language only match

Neeraj Guptac0fd71a66838
diff --git a/mobile/lib/l10n/l10n.dart b/mobile/lib/l10n/l10n.dart
index ab8f9e2cc4..09ad1d5d06 100644
--- a/mobile/lib/l10n/l10n.dart
+++ b/mobile/lib/l10n/l10n.dart
@@ -34,18 +34,22 @@ Locale? autoDetectedLocale;
Locale localResolutionCallBack(deviceLocales, supportedLocales) {
_onDeviceLocales = deviceLocales;
- debugPrint("onDeviceLocales: ${_onDeviceLocales.toString()}");
+ Locale? firstLangeuageMatch;
for (Locale deviceLocale in deviceLocales) {
for (Locale supportedLocale in appSupportedLocales) {
if (supportedLocale == deviceLocale) {
autoDetectedLocale = supportedLocale;
return supportedLocale;
- } else if (supportedLocale.languageCode == deviceLocale.languageCode) {
- autoDetectedLocale = supportedLocale;
- return supportedLocale;
+ }
+ if (firstLangeuageMatch == null &&
+ supportedLocale.languageCode == deviceLocale.languageCode) {
+ firstLangeuageMatch = deviceLocale;
}
}
}
+ if (firstLangeuageMatch != null) {
+ autoDetectedLocale = firstLangeuageMatch;
+ }
return autoDetectedLocale ?? const Locale('en');
}
diff --git a/mobile/lib/ui/settings/language_picker.dart b/mobile/lib/ui/settings/language_picker.dart
index 86d9a9a674..009150afb9 100644
--- a/mobile/lib/ui/settings/language_picker.dart
+++ b/mobile/lib/ui/settings/language_picker.dart
@@ -98,11 +98,21 @@ class _ItemsWidgetState extends State<ItemsWidget> {
@override
Widget build(BuildContext context) {
items.clear();
+ bool foundMatch = false;
for (Locale locale in widget.supportedLocales) {
+ if (currentLocale == locale) {
+ foundMatch = true;
+ }
items.add(
_menuItemForPicker(locale),
);
}
+ if (!foundMatch && kDebugMode) {
+ items.insert(
+ 0,
+ Text("(i) Locale : ${currentLocale.toString()}"),
+ );
+ }
items = addSeparators(
items,
DividerWidget(