baidu/amis

JS SDK 多语言不生效

Open

#4,939 opened on Jul 21, 2022

View on GitHub
 (4 comments) (0 reactions) (0 assignees)TypeScript (2,268 forks)batch import
dochelp wantedneed confirm

Repository metrics

Stars
 (15,576 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

描述问题:

当使用 JS SDK 时,在 JSON 配置中设置多语言不生效。

截图或视频:

CC61F51E-F65D-43CD-BA11-5944A1BD2759

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

  1. 将项目 https://github.com/aisuda/amis-admin.git 克隆到本地,切换到 master 分支;
  2. 设置项目的 locale 为 en-US;

index.html

let amisInstance = amis.embed(
  '#root',
  app,
  {
    location: history.location,
    locale: 'en-US', // 设置 locale
  }
)
  1. 更改 JSON schema 中的多语言配置;

pages/crud-new.json

{
  type: 'text',
  name: 'engine',
  required: true,
  inline: false,
  description: '',
  descriptionClassName: 'help-block',
  placeholder: '',
  addOn: null,
  label: '引擎',
  'en-US': {
    label: 'engine',  // locale 为 “en-US” 时应该匹配这个 label。
  },
}

上述用法参考 https://aisuda.bce.baidu.com/amis/zh-CN/docs/extend/i18n#json-%E9%85%8D%E7%BD%AE%E4%B8%AD%E8%AE%BE%E7%BD%AE%E5%A4%9A%E8%AF%AD%E8%A8%80

期望:

使用 JS SDK 可以正常使用多语言功能。

Contributor guide