flutter / flutter

Flutter makes it easy and fast to build beautiful apps for mobile and beyond
https://flutter.dev
BSD 3-Clause "New" or "Revised" License
164.2k stars 27.09k forks source link

How to localize `PlatformProvidedMenuItem`? #120097

Open mgenware opened 1 year ago

mgenware commented 1 year ago

The constructor of PlatformProvidedMenuItem doesn't expose the label property, which is declared as final.

// The only constructor of `PlatformProvidedMenuItem`.
  const PlatformProvidedMenuItem({
    required this.type,
    this.enabled = true,
  }) : super(label: ''); 

I have a "View" menu in macOS defined like this:

      PlatformMenu(
        // Localized menu name "View"
        label: ls.viewMenu,
        menus: [
          PlatformMenuItemGroup(
            members: [
              if (PlatformProvidedMenuItem.hasMenu(
                  PlatformProvidedMenuItemType.toggleFullScreen))
                // Again, no way to localized this.
                const PlatformProvidedMenuItem(
                    type: PlatformProvidedMenuItemType.toggleFullScreen),
            ],
          ),
        ],
      )

Here's the screenshot in Chinese:

image

Flutter doctor:

[✓] Flutter (Channel stable, 3.7.1, on macOS 13.2 22D49 darwin-arm64, locale
    zh-Hans-CN)
[✗] Android toolchain - develop for Android devices
    ✗ Unable to locate Android SDK.
      Install Android Studio from:
      https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK
      components.
      (or visit https://flutter.dev/docs/get-started/install/macos#android-setup
      for detailed instructions).
      If the Android SDK has been installed to a custom location, please use
      `flutter config --android-sdk` to update to that location.

[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
[✓] Chrome - develop for the web
[!] Android Studio (not installed)
[✓] VS Code (version 1.75.0)
[✓] Connected device (2 available)
[✓] HTTP Host Availability
darshankawar commented 1 year ago

Thanks for the report. I tried to look for related info on how to localize it, but couldn't find a way. I am going ahead and keeping this issue open for team's attention and thoughts.

gspencergoog commented 1 year ago

PlatformProvidedMenuItem should be using the localization provided by macOS, so if the system is set to Chinese, it should provide Chinese menus. Is this a request for customizing the localization, or a bug report that it isn't localizing them?

mgenware commented 1 year ago

@gspencergoog , iirc, xcode macOS app template also doesn't come with localized menus. But you can edit them in interface builder. So this is a bug report that PlatformProvidedMenuItem cannot be localized (it's basically hardcoded in English).

flutter-triage-bot[bot] commented 2 months ago

The triaged-desktop label is irrelevant if there is no team-desktop label or fyi-desktop label.