From 3c0cb20a9b394127ab230a2a651cf6c5b695efc3 Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Fri, 24 May 2024 18:13:09 +0530 Subject: [PATCH] [mob] Use custom assetPickerTextDelegate to use en as default --- .../gallery/hooks/add_photos_sheet.dart | 41 ++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/mobile/lib/ui/viewer/gallery/hooks/add_photos_sheet.dart b/mobile/lib/ui/viewer/gallery/hooks/add_photos_sheet.dart index 0ccdc93e1..aeeadc198 100644 --- a/mobile/lib/ui/viewer/gallery/hooks/add_photos_sheet.dart +++ b/mobile/lib/ui/viewer/gallery/hooks/add_photos_sheet.dart @@ -167,7 +167,13 @@ class AddPhotosPhotoWidget extends StatelessWidget { Future _onPickFromDeviceClicked(BuildContext context) async { try { - final List? result = await AssetPicker.pickAssets(context); + final assetPickerTextDelegate = await _getAssetPickerTextDelegate(); + final List? result = await AssetPicker.pickAssets( + context, + pickerConfig: AssetPickerConfig( + textDelegate: assetPickerTextDelegate, + ), + ); if (result != null && result.isNotEmpty) { final ca = CollectionActions( CollectionsService.instance, @@ -204,6 +210,39 @@ class AddPhotosPhotoWidget extends StatelessWidget { } } } + + // _getAssetPickerTextDelegate returns the text delegate for the asset picker + // This custom method is required to enforce English as the default fallback + // instead of Chinese. + Future _getAssetPickerTextDelegate() async { + final Locale locale = await getLocale(); + switch (locale.languageCode.toLowerCase()) { + case "en": + return const EnglishAssetPickerTextDelegate(); + case "he": + return const HebrewAssetPickerTextDelegate(); + case "de": + return const GermanAssetPickerTextDelegate(); + case "ru": + return const RussianAssetPickerTextDelegate(); + case "ja": + return const JapaneseAssetPickerTextDelegate(); + case "ar": + return const ArabicAssetPickerTextDelegate(); + case "fr": + return const FrenchAssetPickerTextDelegate(); + case "vi": + return const VietnameseAssetPickerTextDelegate(); + case "tr": + return const TurkishAssetPickerTextDelegate(); + case "ko": + return const KoreanAssetPickerTextDelegate(); + case "zh": + return const AssetPickerTextDelegate(); + default: + return const EnglishAssetPickerTextDelegate(); + } + } } class DelayedGallery extends StatefulWidget {