Skip to content

Commit

Permalink
docs: Use function as a sample of lazy string-only translation
Browse files Browse the repository at this point in the history
  • Loading branch information
orangain committed Feb 23, 2021
1 parent 4fa1c5e commit 0eec517
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions docs/tutorials/react-patterns.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand All @@ -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
-------------------------
Expand Down

0 comments on commit 0eec517

Please sign in to comment.