|
@@ -0,0 +1,74 @@
|
|
1
|
+# Tracim internationalization
|
|
2
|
+
|
|
3
|
+## How to for Frontend part
|
|
4
|
+
|
|
5
|
+In each frontend repo (frontend, frontend_app_..., frontend_lib), there is a folder i18next.scanner that holds every translation files in JSON.
|
|
6
|
+
|
|
7
|
+___
|
|
8
|
+
|
|
9
|
+### I have found a translation error, how do I fix it ?
|
|
10
|
+
|
|
11
|
+**If the error is in any language other than english:**
|
|
12
|
+
|
|
13
|
+a) you can edit the values of the json files.
|
|
14
|
+
|
|
15
|
+b) Then commit/push your changes
|
|
16
|
+
|
|
17
|
+**If the error is in en.json:**
|
|
18
|
+
|
|
19
|
+1) You must find the key in the according .jsx file of that same repo.
|
|
20
|
+
|
|
21
|
+2) Fix the error
|
|
22
|
+
|
|
23
|
+3) Rebuild the translation files with:
|
|
24
|
+
|
|
25
|
+`npm run build-translation`
|
|
26
|
+
|
|
27
|
+This will add your new key in the translation files and remove the old one.
|
|
28
|
+
|
|
29
|
+4) Add translations for your new key in other .json files.
|
|
30
|
+
|
|
31
|
+5) commit/push your changes
|
|
32
|
+
|
|
33
|
+___
|
|
34
|
+
|
|
35
|
+### I have found an untranslated key in a language, how do I fix it ?
|
|
36
|
+
|
|
37
|
+It means you have found an english text even though you have selected another language.
|
|
38
|
+
|
|
39
|
+Do task a) and b) in the according .json file, in folder i18next.scanner.
|
|
40
|
+
|
|
41
|
+___
|
|
42
|
+
|
|
43
|
+### I have found an untranslated key in a language but the key does not appear in the .json file.
|
|
44
|
+
|
|
45
|
+Do step 3).
|
|
46
|
+
|
|
47
|
+If the key still isn't in the .json file, it means the text in the .jsx file does not implement the translation process.
|
|
48
|
+
|
|
49
|
+So you must:
|
|
50
|
+
|
|
51
|
+I) Find the according .jsx file that have your untranslated key
|
|
52
|
+
|
|
53
|
+II) wrap your untranslated key in the translation function `t`:
|
|
54
|
+
|
|
55
|
+Exemple: `<div>My untranslated key</div>` will become `<div>{this.props.t('My untranslated key')}</div>`
|
|
56
|
+
|
|
57
|
+III) Check that `t` in available in your component, meanings your component must be wraped in the `translate()` higher order function
|
|
58
|
+
|
|
59
|
+``` javascript
|
|
60
|
+import React from 'react'
|
|
61
|
+import { translate } from 'react-i18next'
|
|
62
|
+
|
|
63
|
+class MyComponent extends React.Component {
|
|
64
|
+ render () {
|
|
65
|
+ return (<div>{this.props.t('My untranslated key')}</div>)
|
|
66
|
+ }
|
|
67
|
+}
|
|
68
|
+
|
|
69
|
+export default translate()(MyComponent)
|
|
70
|
+```
|
|
71
|
+
|
|
72
|
+IV) You can destruct `t` from `this.props` in the `render()` like it is done in most components.
|
|
73
|
+
|
|
74
|
+V) Do steps 3), 4), 5)
|