alibaba / x-render

🚴‍♀️ 阿里 - 很易用的中后台「表单 / 表格 / 图表」解决方案
https://xrender.fun
6.98k stars 988 forks source link

有国际化支持吗? #1537

Closed ThiefTMBadBad closed 1 month ago

ThiefTMBadBad commented 1 month ago

如题

Hemyhcy commented 1 month ago

可以结合umi的国际化插件一起使用实现国际化,比如:

import React from 'react';
import FormRender, { useForm } from 'form-render';
import { useIntl } from '@umijs/max';

export default () => {
  const form = useForm();
  const intl =useIntl();

  const schema={
  type: 'object',
  properties: {
    input: {
      title: intl.formatMessage({
          id: 'test',
        }),,
      type: 'string',
      widget: 'input'
    },
    select: {
      title: '下拉框',
      type: 'string',
      widget: 'select',
      props: {
        options: [
          { label: '早', value: 'a' },
          { label: '中', value: 'b' },
          { label: '晚', value: 'c' }
        ]
      }
    }
  }
};

  const onFinish = (formData) => {
    console.log('formData:', formData);
  };

  return (
    <FormRender 
      form={form} 
      schema={schema} 
      onFinish={onFinish} 
      maxWidth={60} 
      footer={true}
    />
  );
}

zh-CN.ts

export default {
  test: "输入框",
};