Giter Site home page Giter Site logo

Comments (2)

cwtuan avatar cwtuan commented on June 2, 2024
  1. Use react-intl-universal-extract to extract default message to your locale files.
intl.get('welcome.message', { name }).d(<span>hello, <span style="color:blue">{name}</span></span>)
  1. Binding event: https://github.com/alibaba/react-intl-universal#2-how-to-bind-event-handlers-to-an-internationalized-message

from react-intl-universal.

xuoutput avatar xuoutput commented on June 2, 2024

我试一下, 遇到问题,

另外绑定 事件 https://github.com/alibaba/react-intl-universal#2-how-to-bind-event-handlers-to-an-internationalized-message

import {Button} from 'antd';
export default function Hello() {

const name = <Button onClick={() => console.log('111')}>world</Button>;
return <div>
{intl.getHTML('welcome.message', { name })}
</div>
}

看着依旧不能在 name 中设置, (对 Button 设置事件), 而是整个div 监听事件了.

补充下之前的 demo

比如有这么一句话和翻译
不能作为一个个 单词拆开翻译, 而是作为一整句话翻译

  • 名字这里是一个自定义 React 组件, 而不是简单的 HTML 标签
  • 名字这里有监听事件
hello, Tom
Tom 你好

代码

import {Button} from 'antd';
export default function Hello() {

const name = <Button onClick={() => console.log('111')}>Tom</Button>;
return <div>
{intl.getHTML('welcome.message', { name })}
</div>
}

json

// 英文
{
  "welcome.message": "hello, {name}",
}

//中文
{
  "welcome.message": "{name} 你好"
}

from react-intl-universal.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.