baidu/amis

JS SDK 多语言不生效

Open

#4939 aperta il 21 lug 2022

Vedi su GitHub
 (4 commenti) (0 reazioni) (0 assegnatari)TypeScript (2268 fork)batch import
dochelp wantedneed confirm

Metriche repository

Star
 (15.576 star)
Metriche merge PR
 (Nessuna PR mergiata in 30 g)

Descrizione

描述问题:

当使用 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 可以正常使用多语言功能。

Guida contributor