zoukankan      html  css  js  c++  java
  • [React Intl] Render Content with Placeholders using react-intl FormattedMessage

    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'
        }
      },
  • 相关阅读:
    python os模块
    python time、datetime模块
    python 导入模块、包
    python json、pickle
    python 装饰器
    python 生成器、迭代器
    python 内置函数
    python 函数的参数
    python 编码解码
    python 文件读写、shutil模块
  • 原文地址:https://www.cnblogs.com/Answer1215/p/7252321.html
Copyright © 2011-2022 走看看