Skip to content

Commit 5671c0f

Browse files
authored
Merge pull request #8766 from ethereum/i18n-update-docs
Update i18n docs
2 parents 56b33ab + 22bb85f commit 5671c0f

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

docs/best-practices.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Markdown will be translated as whole pages of content, so no specific action is
5252

5353
- _tl;dr Each individual JSON entry should be a complete phrase by itself_
5454

55-
- This is done using the `Translation` component. However there is an alternative method for regular JS: `gatsby-theme-i18n` with `/src/utils/translations.ts`
55+
- This is done using the `Translation` component. However there is an alternative method for regular JS: using the `t` function from `gatsby-plugin-react-i18next`
5656

5757
- **Method one: `<Translation />` component (preferred if only needed in JSX)**
5858

@@ -63,19 +63,18 @@ Markdown will be translated as whole pages of content, so no specific action is
6363
;<Translation id="language-json-key" />
6464
```
6565

66-
- **Method two: `translateMessageId()`**
66+
- **Method two: `t()`**
6767

6868
```tsx
69-
import { useIntl } from "react-intl"
70-
import { translateMessageId } from "src/utils/translations"
69+
import { useTranslation } from "gatsby-plugin-react-i18next"
7170
7271
// Utilize anywhere in JS using
73-
const intl = useIntl()
74-
translateMessageId("language-json-key", intl)
72+
const { t } = useTranslation()
73+
t("language-json-key")
7574
```
7675

7776
```tsx
78-
const siteTitle = translateMessageId("site-title", intl)
77+
const siteTitle = t("site-title")
7978
```
8079

8180
## React Hooks

0 commit comments

Comments
 (0)