Learn how to use react-intl to set dynamic values into your language messages. We’ll also learn how to pass in those values by using a values prop in the react-intl FormattedMessage component.

We'll also take a look at how to pass values with markup and still get all the benefits of translation.

Pass the 'values' porp to the FormattedMessage:

          <h3>
<FormattedMessage id="detail.author" values={{
author: book.author
}} />
</h3>

For translations:

  'en-US': {
detail: {
author: 'by {author}'
}
},

It also supports pass in markdown as param:

              <p>
<FormattedMessage id="detail.userRating" values={{
name: <strong>{review.name}</strong>,
rating: review.rating
}}/><br />
{new Date(review.date).toLocaleDateString()}
</p>
  'en-US': {
detail: {
userRating: '{name} rated it: {rating} out of 5'
}
},

[React Intl] Render Content with Placeholders using react-intl FormattedMessage的更多相关文章

  1. [React Intl] Render Content Based on a Number using react-intl FormattedMessage (plural)

    Using the react-intl FormattedMessage component, we’ll learn how to render content conditionally in ...

  2. [React Intl] Render Content with Markup Using react-intl FormattedHTMLMessage

    In this lesson, we’ll use the react-intl FormattedHTMLMessage component to display text with dynamic ...

  3. react之——render prop

    在react “从上至下的数据流原则” 背景下,常规的消息传递机制就是通过prop属性,把父级数据传递给子级,这样一种数据流通模式决定了——数据的接收方子组件要被”硬植入“进数据的数据的给予方父组件, ...

  4. [React] Render Text Only Components in React 16

    In this session we create a comment component to explore how to create components that only render t ...

  5. react解析: render的FiberRoot(三)

    react解析: render的FiberRoot(三) 感谢 yck: 剖析 React 源码解析,本篇文章是在读完他的文章的基础上,将他的文章进行拆解和加工,加入我自己的一下理解和例子,便于大家理 ...

  6. React components render order All In One

    React components render order All In One components render order / components lifecycle DOM tree ren ...

  7. React中render Props模式

    React组件复用 React组件复用的方式有两种: 1.render Props模式 2.高阶组件HOC 上面说的这两种方式并不是新的APi. 而是利用Raect自身的编码特点,演化而来的固定编码写 ...

  8. [React Intl] Use Webpack to Conditionally Include an Intl Polyfill for Older Browsers

    Some browsers, such as Safari < 10 & IE < 11, do not support the JavaScript Internationali ...

  9. React躬行记(13)——React Router

    在网络工程中,路由能保证信息从源地址传输到正确地目的地址,避免在互联网中迷失方向.而前端应用中的路由,其功能与之类似,也是保证信息的准确性,只不过来源变成URL,目的地变成HTML页面. 在传统的前端 ...

随机推荐

  1. 新浪新闻按keyword抓取实例

    import urllib2 import requests #import MySQLdb import webbrowser import string import re from Beauti ...

  2. 改动UINavigationBar (导航栏)上NavigationBarItem 的字体大小和颜色的用法

    //创建一个左边button UIBarButtonItem *leftButton = [[UIBarButtonItem alloc] initWithTitle:@"<" ...

  3. 如何实现对网站页面访问量的统计(javaweb和php)

    如何实现对网站页面访问量的统计(javaweb和php) 一.总结 一句话总结:其实很简单啦,每访问一次那个页面对应的index函数(控制器中的那个函数)访问次数就加1就可以了. 1.javaweb中 ...

  4. C# 使用 X.509 v.3 证书的方法。

    C# 使用 X.509 v.3 证书的方法. public static void Main()    { // The path to the certificate.        string ...

  5. LuoguP3254 圆桌问题(最大流)

    题目描述 假设有来自m 个不同单位的代表参加一次国际会议.每个单位的代表数分别为ri (i =1,2,……,m). 会议餐厅共有n 张餐桌,每张餐桌可容纳ci (i =1,2,……,n)个代表就餐. ...

  6. python3 import Crypto 失败的解决办法 (AES对称加密使用 模块)

    # 先导入所需要的包 pip3 install Crypto # 再安装pycrypto pip3 install pycrypto from Crypto.Cipher import AES # 就 ...

  7. 洛谷 P1911 L国的战斗之排兵布阵

    P1911 L国的战斗之排兵布阵 题目背景 L国即将与I国发动战争!! 题目描述 L国的指挥官想让他的每一个军营都呈现出国徽形——“L”形(方向无所谓).当然,他的指挥营除外(这叫做个性),他想不出该 ...

  8. spark internal - 作业调度

    作者:刘旭晖 Raymond 转载请注明出处 Email:colorant at 163.com BLOG:http://blog.csdn.net/colorant/ 在Spark中作业调度的相关类 ...

  9. 洛谷P1316 丢瓶盖

    题目描述 陶陶是个贪玩的孩子,他在地上丢了A个瓶盖,为了简化问题,我们可以当作这A个瓶盖丢在一条直线上,现在他想从这些瓶盖里找出B个,使得距离最近的2个距离最大,他想知道,最大可以到多少呢? 输入输出 ...

  10. Codefroces 760 B. Frodo and pillows

    B. Frodo and pillows time limit per test 1 second memory limit per test 256 megabytes input standard ...