@openshift-assisted/locales 2.8.2-cim
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -0
- package/lib/en/translation.json +796 -0
- package/lib/ja/translation.json +794 -0
- package/lib/ko/translation.json +794 -0
- package/lib/zh/translation.json +794 -0
- package/package.json +33 -0
package/README.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Assisted Installer locales library
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@openshift-assisted/locales)
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
`yarn add @openshift-assisted/locales`
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
Internationalization is implemented with [i18next](https://www.i18next.com/) and
|
|
12
|
+
[react-i18next](https://react.i18next.com/). The i18n namespace must be declared at build-time in an
|
|
13
|
+
environment variable called: `TRANSLATION_NAMESPACE` in order to avoid naming conflicts.
|
|
14
|
+
|
|
15
|
+
- Environment variables:
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
TRANSLATION_NAMESPACE: required, name of translation namespace (by default is 'translation')
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
- We create the wrapper src/common/hooks/use-translation-wrapper.ts that use the `useTranslation`
|
|
22
|
+
hook with our namespace.
|
|
23
|
+
|
|
24
|
+
- Use in our components :
|
|
25
|
+
|
|
26
|
+
```tsx
|
|
27
|
+
import { useTranslation } from 'common/hooks/use-translation-wrapper';
|
|
28
|
+
const { t } = useTranslation();
|
|
29
|
+
|
|
30
|
+
<Button key="submit" onClick={submitForm}>
|
|
31
|
+
{t('ai:Generate Discovery ISO')}
|
|
32
|
+
</Button>;
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Add 'ai:' prefix to all strings.
|
|
36
|
+
|
|
37
|
+
- Running `yarn i18n` updates the JSON files in the `locales` folder when adding or changing
|
|
38
|
+
messages.
|