-
-
Couldn't load subscription status.
- Fork 503
Closed
Labels
e: localizationsImprovements to localizations.Improvements to localizations.s: enhancementNew feature or request.New feature or request.
Description
Describe the bug
When the app’s current Locale is set to a language unsupported by wechat_assets_picker (e.g., Hindi hi, Bengali bn, Malayalam ml), the picker UI falls back to Chinese. Buttons like “Preview” and “Confirm” appear in Chinese instead of a neutral/default language (e.g., English) or the selected app language.
How to reproduce
Minimal example:
import 'package:flutter/material.dart';
import 'package:wechat_assets_picker/wechat_assets_picker.dart';
class ReproPage extends StatelessWidget {
const ReproPage({super.key});
@override
Widget build(BuildContext context) {
// Ensure app locale is an unsupported one, e.g., Locale('hi') in MaterialApp.
return Scaffold(
body: Center(
child: ElevatedButton(
onPressed: () async {
await AssetPicker.pickAssets(
context,
pickerConfig: const AssetPickerConfig(
requestType: RequestType.image,
maxAssets: 1,
// No textDelegate provided on purpose to show the fallback behavior
),
);
},
child: const Text('Open Picker'),
),
),
);
}
}And in your MaterialApp (or WidgetsApp):
MaterialApp(
// Set an unsupported locale for the picker (e.g., Hindi)
locale: const Locale('hi'),
home: const ReproPage(),
);Steps to reproduce the behavior:
- Set app locale to an unsupported language for the picker (e.g.,
Locale('hi')). - Open the picker using
AssetPicker.pickAssetswithout specifyingtextDelegate. - Observe the UI labels for “Preview” and “Confirm”.
- They appear in Chinese.
Expected behavior
- When the current app
Localeis unsupported by the picker, the picker should not default to Chinese. - Preferable behaviors:
- Fall back to English automatically if language unsupported; or
- Provide a configuration hook (e.g.,
fallbackTextDelegate) to define the fallback; or - Offer a mapping callback from
LocaletoAssetPickerTextDelegate.
Screenshots (If contains)
- Unsupported locale shows Chinese.
- English locale shows English.
Version information
- Device: iPhone 16
- OS: 18.2
- Package Version:
wechat_assets_picker: 9.5.1 - Flutter Version: 3.32.1
Additional context
- Current docs mention: picker obtains locale from
BuildContext, otherwise defaults to Chinese. This creates a confusing UX for apps with locales not covered by the picker. - A workaround is to force English:
pickerConfig: const AssetPickerConfig( requestType: RequestType.image, maxAssets: 1, textDelegate: EnglishAssetPickerTextDelegate(), )
- However, this requires app-side conditionals and does not scale when developers expect a reasonable default fallback or support for different languages
Proposed solutions
- Change default fallback to
EnglishAssetPickerTextDelegate. - Or add
fallbackTextDelegateonAssetPickerConfig. - Or expose a static mapping hook from
LocaletoAssetPickerTextDelegateto support all type of languages.
Metadata
Metadata
Assignees
Labels
e: localizationsImprovements to localizations.Improvements to localizations.s: enhancementNew feature or request.New feature or request.