amis
amis copied to clipboard
设置国际化后 API 响应Toast适配还是中文的”系统消息“
描述问题:
当我 在props 里设置 locale为en-US后 Toast还是会有”系统消息“字样,我看了下en-US里面是有这个关键字的翻译的。 尝试手动注册也无法生效
amisLib.registerLocale('en-US', {
'Alert.info': 'Tips'
});
截图或视频:

如何复现(请务必完整填写下面内容):
- 你是如何使用 amis 的?
sdk
- 粘贴有问题的完整
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>
原来是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,
某个版本中修复了,具体忘了
Duplicate of #2422