amis icon indicating copy to clipboard operation
amis copied to clipboard

设置国际化后 API 响应Toast适配还是中文的”系统消息“

Open KodyFeng opened this issue 5 years ago • 3 comments

描述问题:

当我 在props 里设置 locale为en-US后 Toast还是会有”系统消息“字样,我看了下en-US里面是有这个关键字的翻译的。 尝试手动注册也无法生效

  amisLib.registerLocale('en-US', {
      'Alert.info': 'Tips'
  });

截图或视频:

issue2.gif

如何复现(请务必完整填写下面内容):

  1. 你是如何使用 amis 的?

sdk

  1. 粘贴有问题的完整 amis schema 代码:
 <script type="text/javascript">
        (function () {
            let amisLib = amisRequire('amis');
            amisLib.registerLocale('en-US', {
                'Form.submit': '送信',
                'Alert.info': 'Tips'
            });
            let amis = amisRequire('amis/embed');

            // 通过替换下面这个配置来生成不同页面
            let amisJSON = {
                "type": "page",
                "body": [
                    {
                        "type": "form",
                        "title": "Form",
                        "controls": [
                            {
                                "label": "11111",
                                "type": "text",
                                "name": "text"
                            }
                        ],
                        "api": {
                            "method": "post",
                            "url": "https://www.fastmock.site/mock/15e43e8698790fe68e49d5a266563a12/p1-hdhc/notifyUser",
                            "adaptor": "payload.status = 0;\r\npayload.msg = \"hahaha\";\r\nreturn payload;"
                        },
                        "messages": {
                            "fetchFailed": "00",
                            "saveSuccess": "1",
                            "saveFailed": "22"
                        }
                    }
                ]
            }

            let amisScoped = amis.embed('#root', amisJSON, { locale: 'en-US' });
        })();
    </script>

KodyFeng avatar Jun 09 '21 02:06 KodyFeng

原来是embed.tsx @@182行代码中写死了常量并非取自i18n文件。 @nwind @2betop

notify: (type: string, msg: string) =>
  toast[type]
     //? toast[type](msg, type === 'error' ? '系统错误' : '系统消息')
    ? toast[type](msg, type === 'error' ? 'System Error' : 'System Tips')
    : console.warn('[Notify]', type, msg),
alert,

KodyFeng avatar Jun 09 '21 05:06 KodyFeng

某个版本中修复了,具体忘了

nwind avatar Sep 13 '21 11:09 nwind

Duplicate of #2422

RickCole21 avatar Sep 13 '21 11:09 RickCole21