@@ -73,56 +73,81 @@ class SomeComponent extends React.Component<Props> {
73
73
export default withTranslation (SomeComponent )
74
74
```
75
75
76
- ## Translation Method t(path, params)
76
+ ## Auto update functions
77
77
78
- Params | Type | Description
79
- ------ | ------ | ------------------------------------------------------------------------------------
80
- path | string | translation path that identifies the text
81
- params | object | {'param': 'value', ...} each param will be set on the string in its correct location
78
+ ### useTranslation(basePath)
79
+
80
+ React hook that returns the t function
81
+
82
+ Params | Type | Description | Required
83
+ ---- | ---- | ---- | ----
84
+ basePath | string | translation base path used to identify all the next requested translations | no
85
+
86
+ ### withTranslation(component, basePath)
87
+
88
+ HOC that injects the translation function into the component
89
+
90
+ Params | Type | Description | Required
91
+ ---- | ---- | ---- | ----
92
+ component | React Component | React component that requires the translation function | yes
93
+ basePath | string | translation base path used to identify all the next requested translations | no
94
+
95
+ ## Translation Method
96
+
97
+ t(path, params)
98
+
99
+ Returns the translation for the requested path
100
+
101
+ Params | Type | Description | Required
102
+ ---- | ---- | ---- | ----
103
+ path | string | translation path that identifies the text | yes
104
+ params | object | {'param': 'value', ...} each parameter will be set on the string in its correct location | no
82
105
83
106
## Exported Methods
84
107
85
108
### setDefaultTranslations(translations)
86
109
87
110
Sets the translations
88
111
89
- Params | Type | Description
90
- ------------ | ------ | ------------------------ ----
91
- translations | object | {'key': 'translations', ...}
112
+ Params | Type | Description | Required
113
+ ---- | ---- | ---- | ----
114
+ translations | object | {'key': 'translations', ...} | yes
92
115
93
116
### setTranslations(translations)
94
117
95
118
Same as setDefaultTranslations, but this will update all components using translations
96
119
97
- Params | Type | Description
98
- ------------ | ------ | ------------------------ ----
99
- translations | object | {'key': 'translations', ...}
120
+ Params | Type | Description | Required
121
+ ---- | ---- | ---- | ----
122
+ translations | object | {'key': 'translations', ...} | yes
100
123
101
124
### setDefaultLanguage(key)
102
125
103
126
Sets the default application language
104
127
105
- Params | Type | Description
106
- ------ | ------ | ----------------------------------------- ----
107
- key | string | translation key, in this example 'en' or 'pt'
128
+ Params | Type | Description | Required
129
+ ---- | ---- | ---- | ----
130
+ key | string | translation key, in this example 'en' or 'pt' | yes
108
131
109
132
### setLanguage(key)
110
133
111
134
Same as setDefaultLanguage, but this will update all components using translations
112
135
113
- Params | Type | Description
114
- ------ | ------ | ----------------------------------------- ----
115
- key | string | translation key, in this example 'en' or 'pt'
136
+ Params | Type | Description | Required
137
+ ---- | ---- | ---- | ----
138
+ key | string | translation key, in this example 'en' or 'pt' | yes
116
139
117
140
### getLanguage()
118
141
119
142
Returns the current selected language
120
143
121
144
### t(key, params)
122
145
123
- Get text function, will return the translated string
146
+ t(path, params)
147
+
148
+ Returns the translation for the requested path
124
149
125
- Params | Type | Description
126
- ------ | ------ | -------------------------------------------------------------------------------- ----
127
- key | string | translation key that identifies the text
128
- params | object | {'param': 'value', ...} each param will be set on the string in its correct location
150
+ Params | Type | Description | Required
151
+ ---- | ---- | ---- | ----
152
+ path | string | translation path that identifies the text | yes
153
+ params | object | {'param': 'value', ...} each parameter will be set on the string in its correct location | no
0 commit comments