You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* update dependencies and unit tests to work with React 16
* fix broken links in docs
* add enhanced type definitions for single and multiple translation data
Copy file name to clipboardExpand all lines: docs/api/action-creators.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,8 +16,8 @@ name | Type | Default | Description
16
16
defaultLanguage | string | languages[0] | The language code for the language you'd like to set as the defualt.
17
17
renderInnerHtml | boolean | true | Controls whether HTML in your translations will be rendered or returned as a plain string.
18
18
showMissingTranslationMsg | boolean | true | Controls whether missing translation message will be rendered when translation is undefined.
19
-
missingTranslationCallback | function | undefined | A function that will be called when attempting to get an undefined translation. See [Handle missing translations](../features/#handle-missing-translations) for details.
20
-
translationTransform | function | undefined | A transformation function that will be applied to translation data. See [Custom data format](../formatting-translation-data#custom-data-format) for details.
19
+
missingTranslationCallback | function | undefined | A function that will be called when attempting to get an undefined translation. See [Handle missing translations](/features/#handle-missing-translations) for details.
20
+
translationTransform | function | undefined | A transformation function that will be applied to translation data. See [Custom data format](/formatting-translation-data#custom-data-format) for details.
Dispatch this action to add translation data for multiple languages from a json file, or vanilla JS to your redux store. Please see [formatting transaltion data](../formatting-translation-data#multiple-language-format) to ensure your data is in the proper format.
76
+
Dispatch this action to add translation data for multiple languages from a json file, or vanilla JS to your redux store. Please see [formatting transaltion data](/formatting-translation-data#multiple-language-format) to ensure your data is in the proper format.
77
77
78
78
** Arguments **
79
79
80
80
name | Type | Description
81
81
--------- | ----------| ------------
82
-
data | json \| object | Translation data in the [required format](../formatting-translation-data#multiple-language-format)
82
+
data | json \| object | Translation data in the [required format](/formatting-translation-data#multiple-language-format)
Dispatch this action to add translation data for a single language from a json file, or vanilla JS to your redux store. Please see [formatting transaltion data](../formatting-translation-data#single-language-format) to ensure your data is in the proper format.
103
+
Dispatch this action to add translation data for a single language from a json file, or vanilla JS to your redux store. Please see [formatting transaltion data](/formatting-translation-data#single-language-format) to ensure your data is in the proper format.
104
104
105
105
** Arguments **
106
106
107
107
name | Type | Description
108
108
--------- | ----------| ------------
109
-
data | json \| object | Translation data in the [required format](../formatting-translation-data#single-language-format)
109
+
data | json \| object | Translation data in the [required format](/formatting-translation-data#single-language-format)
110
110
language | string | The language code this translation data belongs to
Copy file name to clipboardExpand all lines: docs/api/higher-order-component.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
<divclass="admonition important">
4
4
<pclass="first admonition-title">Important</p>
5
-
<pclass="last">if your component is already using <ahref="https://github.com/reactjs/react-redux/blob/master/docs/api.md#connectmapstatetoprops-mapdispatchtoprops-mergeprops-options"target="_blank">connect</a> then you should use the <ahref="../selectors/#gettranslatestate">getTranslate</a>, and <ahref="../selectors#getactivelanguagestate">getActiveLanguage</a> selectors instead of <code>localize</code>.</p>
5
+
<pclass="last">if your component is already using <ahref="https://github.com/reactjs/react-redux/blob/master/docs/api.md#connectmapstatetoprops-mapdispatchtoprops-mergeprops-options"target="_blank">connect</a> then you should use the <ahref="/selectors/#gettranslatestate">getTranslate</a>, and <ahref="/selectors#getactivelanguagestate">getActiveLanguage</a> selectors instead of <code>localize</code>.</p>
6
6
</div>
7
7
8
8
If you have a component that just needs access to translations, and nothing else then you can use the `localize` higher-order function. When you pass your Component to localize it will automatically add [translate](selectors.md#translatekey-string-string-data) and `currentLanguage` to props.
Copy file name to clipboardExpand all lines: docs/api/selectors.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -36,7 +36,7 @@ name | Type | Description
36
36
--------- | ----------| ------------
37
37
key | string \| string [] | Pass a single key or multiple keys from your translation data.
38
38
[data] | object | Optional data to be used in your localized strings for [variable replacement]().
39
-
[options]| object | Optional local override for `renderInnerHtml` option passed to the [initialize](../action-creators/#initializelanguages-options) action creator.
39
+
[options]| object | Optional local override for `renderInnerHtml` option passed to the [initialize](/action-creators/#initializelanguages-options) action creator.
Copy file name to clipboardExpand all lines: docs/features.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
## Pass multiple translations to components
2
2
3
3
To avoid connecting every single component that needs translations you should instead pass translations down to child components.
4
-
To retrieve multiple translations using [translate](../api/selectors#translatekey-string-string-data) pass an array of translation keys instead of a single key. This will return an object with translated strings mapped to translation keys.
4
+
To retrieve multiple translations using [translate](/api/selectors#translatekey-string-string-data) pass an array of translation keys instead of a single key. This will return an object with translated strings mapped to translation keys.
5
5
6
6
Since `translate` returns an object we can use the object spread operator to pass the translations as props for the `<Article>` component.
7
7
@@ -49,7 +49,7 @@ Insert dynamic content into your translation strings by inserting placeholders w
49
49
}
50
50
```
51
51
52
-
Then pass in the data you want to swap in for placeholders to the [translate](../api/selectors#translatekey-string-string-data) function.
52
+
Then pass in the data you want to swap in for placeholders to the [translate](/api/selectors#translatekey-string-string-data) function.
@@ -81,7 +81,7 @@ Include HTML in your translation strings and it will be rendered in your compone
81
81
82
82
### Handle custom translation data
83
83
84
-
Does react-localize-redux's supported translation data formats not work for you? That's ok - there is a way for you to use your own custom trnaslation data format. See [Formatting Transltion Data - Custom data format](../formatting-translation-data/#custom-data-format) for full documentation.
84
+
Does react-localize-redux's supported translation data formats not work for you? That's ok - there is a way for you to use your own custom trnaslation data format. See [Formatting Transltion Data - Custom data format](/formatting-translation-data/#custom-data-format) for full documentation.
85
85
86
86
87
87
@@ -134,7 +134,7 @@ Does react-localize-redux's supported translation data formats not work for you?
134
134
135
135
## Handle missing translations
136
136
137
-
If you need a way to detect missing translations you can set the [missingTranslationCallback](../api/action-creators/#initialize-options) option. When set this callback will be triggered anytime the [translate](../api/selectors/#translatekey-string-string-data-options) function detects an `undefined` translation.
137
+
If you need a way to detect missing translations you can set the [missingTranslationCallback](/api/action-creators/#initialize-options) option. When set this callback will be triggered anytime the [translate](/api/selectors/#translatekey-string-string-data-options) function detects an `undefined` translation.
Copy file name to clipboardExpand all lines: docs/formatting-translation-data.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,12 +2,12 @@ The translation data for you application will either come from json or vanilla J
2
2
3
3
## Multiple language format
4
4
5
-
> Use **[addTranslation](../api/action-creators#addtranslationdata)** to add data in this format.
5
+
> Use **[addTranslation](/api/action-creators#addtranslationdata)** to add data in this format.
6
6
7
7
The data is an object where the property name is your translation key, and the value is an array of translations. The translation key is used to identify the translation, and the value is an array that enforces the following...
8
8
9
9
* Includes a translation for each language your app supports.
10
-
* The order of the translation strings in the array matters! The order **MUST** follow the order of the languages array passed to [setLanguages]([addTranslationForLanguage](../api/action-creators#addtranslationforlanguagedata-language)).
10
+
* The order of the translation strings in the array matters! The order **MUST** follow the order of the languages array passed to [setLanguages]([addTranslationForLanguage](/api/action-creators#addtranslationforlanguagedata-language)).
11
11
12
12
Assuming your application has dispatched `setLanguages('en', 'fr', 'es')`:
13
13
@@ -34,7 +34,7 @@ Assuming your application has dispatched `setLanguages('en', 'fr', 'es')`:
34
34
35
35
## Single language format
36
36
37
-
> Use **[addTranslationForLanguage](../api/action-creators#addtranslationforlanguagedata-language)** to add data in this format.
37
+
> Use **[addTranslationForLanguage](/api/action-creators#addtranslationforlanguagedata-language)** to add data in this format.
38
38
39
39
The data is an object where the property name is your translation key, and the value is the translation for the language. With the single language format you would dispatch `addTranslationForLanguage` for each language you support.
40
40
@@ -71,19 +71,19 @@ Assuming your application `setLanguages('en', 'fr', 'es')`:
71
71
72
72
## Custom data format
73
73
74
-
If you cannot use the supported data formats there is a way to instruct react-localize-redux on how to handle your custom data. To do this you must pass the [translationTransform](../api/action-creators#initialize-options) option when dispatching the [intialize](../api/action-creators#initializelanguages-options) action, which takes a function in the following format:
74
+
If you cannot use the supported data formats there is a way to instruct react-localize-redux on how to handle your custom data. To do this you must pass the [translationTransform](/api/action-creators#initialize-options) option when dispatching the [intialize](/api/action-creators#initializelanguages-options) action, which takes a function in the following format:
This function is responsible for taking your custom data, and transforming it into the format required by react-localize-redux. You are responsible for writing the transformation logic, but after that the function will be run automatically whenever dispatching [addTranslation](../api/action-creators#addtranslationdata).
82
+
This function is responsible for taking your custom data, and transforming it into the format required by react-localize-redux. You are responsible for writing the transformation logic, but after that the function will be run automatically whenever dispatching [addTranslation](/api/action-creators#addtranslationdata).
83
83
84
84
<divclass="admonition note">
85
85
<pclass="first admonition-title">Note</p>
86
-
<pclass="last">The transformation function will not be run if you use the <code><ahref="../api/action-creators/#addtranslationforlanguagedata-language">addTranslationForLanguage</a></code> action.</p>
86
+
<pclass="last">The transformation function will not be run if you use the <code><ahref="/api/action-creators/#addtranslationforlanguagedata-language">addTranslationForLanguage</a></code> action.</p>
Now when you dispatch the [intialize](../api/action-creators#initializelanguages-options) action make sure you set the [translationTransform](../api/action-creators#initialize-options) option equal to the `transformFunction`. Now anytime you dispatch the [addTranslation](../api/action-creators#addtranslationdata) action the `transformFunction` will run on the translation data you are adding.
136
+
Now when you dispatch the [intialize](/api/action-creators#initializelanguages-options) action make sure you set the [translationTransform](/api/action-creators#initialize-options) option equal to the `transformFunction`. Now anytime you dispatch the [addTranslation](/api/action-creators#addtranslationdata) action the `transformFunction` will run on the translation data you are adding.
Typically you will store your translation data in json files, but the data can also be a vanilla JS object.
55
55
56
-
In order to add translation data to your application there are two action creators available - [addTranslation](../api/action-creators#addtranslationdata) and [addTranslationForLanguage](../api/action-creators#addtranslationforlanguagedata-language). Which one you use will depend on which format your translation data is in - see [formatting transaltion data]() for more information.
56
+
In order to add translation data to your application there are two action creators available - [addTranslation](/api/action-creators#addtranslationdata) and [addTranslationForLanguage](/api/action-creators#addtranslationforlanguagedata-language). Which one you use will depend on which format your translation data is in - see [formatting transaltion data]() for more information.
If you have a component that is already using [connect](https://github.com/reactjs/react-redux/blob/master/docs/api.md#connectmapstatetoprops-mapdispatchtoprops-mergeprops-options) use [getTranslate](../api/selectors#gettranslatestate) in your `mapStateToProps` to add the [translate](../api/selectors#translatekey-string-string-data) function to your component's props.
104
+
If you have a component that is already using [connect](https://github.com/reactjs/react-redux/blob/master/docs/api.md#connectmapstatetoprops-mapdispatchtoprops-mergeprops-options) use [getTranslate](/api/selectors#gettranslatestate) in your `mapStateToProps` to add the [translate](/api/selectors#translatekey-string-string-data) function to your component's props.
@@ -121,11 +121,11 @@ const mapStateToProps = state => ({
121
121
exportdefaultconnect(mapStateToProps)(Greeting);
122
122
```
123
123
124
-
For components where you only need access to [translate](../api/selectors#translatekey-string-string-data) and `currentLanguage` you can use [localize](../api/higher-order-component#localizecomponent-reducername). This will automatically connect your component with the `translate` function and `currentLanguage` prop.
124
+
For components where you only need access to [translate](/api/selectors#translatekey-string-string-data) and `currentLanguage` you can use [localize](/api/higher-order-component#localizecomponent-reducername). This will automatically connect your component with the `translate` function and `currentLanguage` prop.
125
125
126
126
<divclass="admonition warning">
127
127
<pclass="first admonition-title">Warning</p>
128
-
<pclass="last">Components that use <strong>localize</strong> still use <ahref="https://github.com/reactjs/react-redux/blob/master/docs/api.md#connectmapstatetoprops-mapdispatchtoprops-mergeprops-options"target="_blank">connect</a> behind the scenes, which means you will want to avoid overusing <strong>localize</strong>. Instead <ahref="../features#pass-multiple-translations-to-components">pass multiple translations to components</a> when possible.</p>
128
+
<pclass="last">Components that use <strong>localize</strong> still use <ahref="https://github.com/reactjs/react-redux/blob/master/docs/api.md#connectmapstatetoprops-mapdispatchtoprops-mergeprops-options"target="_blank">connect</a> behind the scenes, which means you will want to avoid overusing <strong>localize</strong>. Instead <ahref="/features#pass-multiple-translations-to-components">pass multiple translations to components</a> when possible.</p>
0 commit comments