File tree 1 file changed +38
-1
lines changed
1 file changed +38
-1
lines changed Original file line number Diff line number Diff line change @@ -70,7 +70,7 @@ For Production:
70
70
- [ ] Redux-saga
71
71
- [x] Jest
72
72
- [x] Axios
73
- - [x] I18n [ Not completed ]
73
+ - [x] I18n
74
74
- [x] React-router
75
75
- [x] Alias
76
76
- [x] Hot reload
@@ -139,6 +139,43 @@ For Production:
139
139
140
140
_- You should use [BEM ](http: // getbem.com/) to write css without conflict_
141
141
142
+ - Using i18n
143
+
144
+ - Create new json file at ` src/locales/resources/<file-name/>.json`
145
+ - Add content follow this format into json file
146
+ ` ` ` javascript
147
+ {
148
+ "en": {
149
+ "name": "Name"
150
+ },
151
+ "vi": {
152
+ "name": "Tên"
153
+ }
154
+ }
155
+ ` ` `
156
+ - update ` src/locales/resources/index.ts` like this:
157
+
158
+ ` ` ` javascript
159
+ /*
160
+ * you can use other name instead ` user`
161
+ * this name will be used as path to key
162
+ */
163
+ import user from './<file-name/>.json
164
+
165
+ const mergeResource: IResource = {
166
+ ..., // others json
167
+ user
168
+ };
169
+ ` ` `
170
+
171
+ - Now inside any where, you can access to key like this:
172
+
173
+ ` ` ` javascript
174
+ const { t } = useTranslation()
175
+
176
+ t('user.name') will be render "Name" for ` en` and "Tên" for ` vi`
177
+ ` ` `
178
+
142
179
-- -
143
180
144
181
## Tips
You can’t perform that action at this time.
0 commit comments