Comments (2)
- 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>)
- Binding event: https://github.com/alibaba/react-intl-universal#2-how-to-bind-event-handlers-to-an-internationalized-message
from react-intl-universal.
我试一下, 遇到问题,
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)
- Option to getHTML() without creating outer <span> HOT 1
- Uncaught ReferenceError: global is not defined HOT 2
- [Template] Issue Template
- [Template] Pull Request Template HOT 1
- {days, plural, zero {# يوم} one {# يوم} two {# أيام} few {# أيام} many {# يوم} other {# يوم}} 这种应该怎么写 HOT 1
- 请问最新版本能完全兼容1.3.4版本吗? HOT 1
- getHTML实际返回 React.Element 类型 但是typings 中定义的返回string类型
- intl.getHTML不兼容ts
- Is there any examples with Nextjs HOT 3
- Performance problems of get method HOT 2
- intl type hints
- 在使用 react-intl-universal-extract 时遇到 has no default message HOT 1
- The problems in the example
- cache HOT 1
- Typescript moduleResolution Bundler does not work properly in combination with strict true HOT 1
- Need for output locale key to UI
- Nextjs: Overusing intl.init() function HOT 5
- 关于如何动态加载多语言文件
- The options.locale may be readonly Module
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-intl-universal.