【问题标题】:Flutter and translated buttons for showAboutDialogshowAboutDialog 的颤振和翻译按钮
【发布时间】:2020-06-06 14:59:40
【问题描述】:

我有一个按钮可以显示有关我的应用的信息,该应用运行良好:

onTap: () async {
                PackageInfo packageInfo = await PackageInfo.fromPlatform();
                return showAboutDialog(
                  context: context,
                  applicationName: translate('title'),
                  applicationVersion: packageInfo.version,
                  children: [
                    Image(
                      image: AssetImage('assets/images/brand/icon.jpg'),
                      height: 100,
                    ),
                  ],
                );
              },

问题是“查看许可证”和“关闭”按钮不是实时翻译的。我需要刷新整个应用程序才能翻译它们: (检查语言是否已更新,但按钮仍然不是英文)

这是改变语言的代码:

 onChanged: (String newLang) async {
                  // update dropdown language
                  _language = newLang;
                  // update app language
                  changeLocale(context, newLang);
                  // save language
                  final options = json.decode(_prefs.get('options'));
                  options["language"] = newLang;
                  _prefs.setString('options', json.encode(options));
                  Provider.of<MyRents>(context, listen: false)
                      .updateLanguage(newLang);
                },

【问题讨论】:

    标签: flutter flutter-dependencies


    【解决方案1】:

    showAboutDialog() 方法将始终以系统语言显示两个按钮(对您来说,这似乎是西班牙语)。如果您想要不同的行为,则必须开发一个自定义对话框

    【讨论】:

    • 我认为可以翻译这部分。谢谢你告诉我
    猜你喜欢
    • 1970-01-01
    • 2020-12-29
    • 2020-05-26
    • 1970-01-01
    • 1970-01-01
    • 2020-04-23
    • 1970-01-01
    • 2021-11-24
    • 2018-11-23
    相关资源
    最近更新 更多