Skip to content

Commit c3d1216

Browse files
committed
[NDH-296] Use i18next as a frontend content / translation helper
1 parent 4e97571 commit c3d1216

File tree

14 files changed

+383
-164
lines changed

14 files changed

+383
-164
lines changed

frontend/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,26 @@ If we find this approach to be insufficient, we will assess additional API endpo
2020
- `assets/` contains static assets
2121
- `components/` contains custom components
2222
- `hooks/` contains custom hook implementations
23+
- `i18n/en/` contains translation / static content definition files
24+
25+
### Static Content
26+
27+
Any static content which appears on a page as part of a React HTML or other component tag should be stored in the appropriate `src/i18/**/*.json` source file and accessed via the [react-i18next](https://react.i18next.com/) `t()` function. This allows us to isolate content from behavior and will allow for easier translation in the future, should the need arise.
28+
29+
We recommend using the `useTranslation` hook to access the `t()` function. For example:
30+
31+
```tsx
32+
const MyComponent = () => {
33+
const { t } = useTranslation()
34+
35+
return (
36+
<div className="ds-u-display--flex">
37+
<p>{t("component.disclaimer")}</p>
38+
<p><a href="#">{t("component.link")}</a></p>
39+
</div>
40+
)
41+
}
42+
```
2343

2444
## Local Development
2545

0 commit comments

Comments
 (0)