Skip to content

[BUG] Picker shows Chinese text for Preview/Confirm button when app locale is unsupported #710

@MarufHassanPietech

Description

@MarufHassanPietech

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:

  1. Set app locale to an unsupported language for the picker (e.g., Locale('hi')).
  2. Open the picker using AssetPicker.pickAssets without specifying textDelegate.
  3. Observe the UI labels for “Preview” and “Confirm”.
  4. They appear in Chinese.

Expected behavior

  • When the current app Locale is 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 Locale to AssetPickerTextDelegate.

Screenshots (If contains)

  • Unsupported locale shows Chinese.
Image
  • English locale shows English.
Image

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 fallbackTextDelegate on AssetPickerConfig.
  • Or expose a static mapping hook from Locale to AssetPickerTextDelegate to support all type of languages.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions