From 0eec517ba7697890c1d739b775807ee764d0befb Mon Sep 17 00:00:00 2001 From: orangain Date: Tue, 23 Feb 2021 12:17:23 +0900 Subject: [PATCH] docs: Use function as a sample of lazy string-only translation --- docs/tutorials/react-patterns.rst | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/docs/tutorials/react-patterns.rst b/docs/tutorials/react-patterns.rst index 8b487ff14..b48811ce9 100644 --- a/docs/tutorials/react-patterns.rst +++ b/docs/tutorials/react-patterns.rst @@ -169,10 +169,11 @@ passing it to :jsxmacro:`Trans` as its ``id`` prop: } Or to render the message descriptor as a string-only translation, just pass it to -the :js:meth:`I18n._` method as usual: +the :js:meth:`I18n._` method: .. code-block:: jsx + import { i18n } from '@lingui/core' import { t } from "@lingui/macro" const favoriteColors = [ @@ -182,9 +183,11 @@ the :js:meth:`I18n._` method as usual: t`Green`, ] - const translatedColorNames = favoriteColors.map( - color => i18n._(color) - ) + export function getTranslatedColorNames() { + return favoriteColors.map( + color => i18n._(color) + ) + } Passing messages as props -------------------------