...
A whole word/sentence is wrapped inside a react/HTML node.
Conventions
HTML values are kept out of the locale files
HTML values within translation key text can decrease readability.
Hard coded text is not used outside the locale files
Using hard coded text within the <Trans> component, means the text has to be maintained in two places. Therefore, we should avoid using hard coded text outside the locale JSON files for easy maintenance.
Links used in the home page are kept inside the homeConfig.ts file
This is for easy alteration, if links happen to change
Adding a link with the <Trans> component
Our plain sentence in our JSON file, without any markup:
...
Code Block | ||
---|---|---|
| ||
hello_msg: "Hello <linkToGoogle>amazing<linkToGoogle/> world" |
Adding a link without the <Trans> component
A link can be added to a whole sentence without the <Trans> component.
...