Skip to content

Commit 29afd25

Browse files
jamuhlgitbook-bot
authored andcommitted
GitBook: No commit message
1 parent c84e74b commit 29afd25

31 files changed

+247
-396
lines changed
201 KB
Loading
33.4 KB
Loading

Diff for: .gitbook/assets/title width.jpg

1.58 MB
Loading

Diff for: README.md

+8-9
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ The module provides multiple components eg. to assert that needed translations g
1212

1313
react-i18next is optimally suited for **server-side rendering**. It provides extra extension point to work with next.js, for e.g. [Learn more](legacy-v9/serverside-rendering.md).
1414

15-
As react-i18next depends on [i18next](http://i18next.com) you can use it in any other UI framework and on the server-side \(node.js, .net, ...\) too. Like the React philosophy - just:
15+
As react-i18next depends on [i18next](http://i18next.com) you can use it in any other UI framework and on the server-side (node.js, .net, ...) too. Like the React philosophy - just:
1616

1717
> **Learn once - translate everywhere**.
1818
1919
{% hint style="success" %}
20-
[Here](https://dev.to/adrai/how-to-properly-internationalize-a-react-application-using-i18next-3hdb) you'll find a simple tutorial on how to best use react-i18next.
21-
Some basics of i18next and some cool possibilities on how to optimize your localization workflow.[
22-
![](.gitbook/assets/title-width.jpg)](https://dev.to/adrai/how-to-properly-internationalize-a-react-application-using-i18next-3hdb)
20+
[Here](https://dev.to/adrai/how-to-properly-internationalize-a-react-application-using-i18next-3hdb) you'll find a simple tutorial on how to best use react-i18next.\
21+
Some basics of i18next and some cool possibilities on how to optimize your localization workflow.[\
22+
![](<.gitbook/assets/title width.jpg>)](https://dev.to/adrai/how-to-properly-internationalize-a-react-application-using-i18next-3hdb)
2323
{% endhint %}
2424

2525
## What does my code look like
@@ -50,15 +50,14 @@ If you prefer not using semantic keys but text - [that's also possible](https://
5050

5151
## On top: [Localization as a service](https://locize.com)
5252

53-
i18next supports translation management tools such as [locize.com](http://locize.com/?utm_source=react_i18next_com&utm_medium=gitbook).
53+
i18next supports translation management tools such as [locize.com](http://locize.com).
5454

5555
{% hint style="success" %}
56-
[Here](https://github.com/locize/react-tutorial) you can find a step by step guide, which will unleash the full power of i18next in combination with locize.
57-
See how your developer experience with this localization workflow [could look like](https://youtu.be/osScyaGMVqo).
58-
There's also the possibility to have an [even more focused developer experience](https://youtu.be/VfxBpSXarlU), with the help of the [auto-machinetranslation workflow](https://docs.locize.com/whats-inside/auto-machine-translation) and the use of the save missing keys functionality, new keys not only gets added to locize automatically, while developing the app, but are also [automatically translated](https://youtu.be/VfxBpSXarlU) into the target languages using machine translation \(like [Google Translate](https://cloud.google.com/translate)\).
56+
[Here](https://github.com/locize/react-tutorial) you can find a step by step guide, which will unleash the full power of i18next in combination with locize.\
57+
See how your developer experience with this localization workflow [could look like](https://youtu.be/osScyaGMVqo).\
58+
There's also the possibility to have an [even more focused developer experience](https://youtu.be/VfxBpSXarlU), with the help of the [auto-machinetranslation workflow](https://docs.locize.com/whats-inside/auto-machine-translation) and the use of the save missing keys functionality, new keys not only gets added to locize automatically, while developing the app, but are also [automatically translated](https://youtu.be/VfxBpSXarlU) into the target languages using machine translation (like [Google Translate](https://cloud.google.com/translate)).
5959
{% endhint %}
6060

6161
![](.gitbook/assets/general-locize-screen.png)
6262

6363
[Learn more about the enterprise offering](https://www.i18next.com/for-enterprises.html)
64-

Diff for: getting-started.md

+5-6
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ You will get the t function by using the [useTranslation](latest/usetranslation-
5656

5757
### JSX tree
5858

59-
Sometimes you might want to include html formatting or components like links into your translations. \(Always try to get the best result for your translators - the final string to translate should be a complete sentence\).
59+
Sometimes you might want to include html formatting or components like links into your translations. (Always try to get the best result for your translators - the final string to translate should be a complete sentence).
6060

6161
**Before:** Your react code would have looked something like:
6262

@@ -124,7 +124,7 @@ ReactDOM.render(
124124

125125
#### RESULT:
126126

127-
![Preview of content](.gitbook/assets/screen-shot-2018-09-30-at-16.58.18.png)
127+
![Preview of content](<.gitbook/assets/Screen Shot 2018-09-30 at 16.58.18.png>)
128128

129129
{% hint style="info" %}
130130
This sample while very simple does come with some [drawbacks](guides/the-drawbacks-of-other-i18n-solutions.md) to getting the full potential from using react-i18next you should read the extended [step by step guide](latest/using-with-hooks.md).
@@ -133,8 +133,7 @@ This sample while very simple does come with some [drawbacks](guides/the-drawbac
133133
### Do you like to read a more complete step by step tutorial?
134134

135135
{% hint style="success" %}
136-
[Here](https://dev.to/adrai/how-to-properly-internationalize-a-react-application-using-i18next-3hdb) you'll find a simple tutorial on how to best use react-i18next.
137-
Some basics of i18next and some cool possibilities on how to optimize your localization workflow.[
138-
![](.gitbook/assets/title-width.jpg)](https://dev.to/adrai/how-to-properly-internationalize-a-react-application-using-i18next-3hdb)
136+
[Here](https://dev.to/adrai/how-to-properly-internationalize-a-react-application-using-i18next-3hdb) you'll find a simple tutorial on how to best use react-i18next.\
137+
Some basics of i18next and some cool possibilities on how to optimize your localization workflow.[\
138+
![](<.gitbook/assets/title width.jpg>)](https://dev.to/adrai/how-to-properly-internationalize-a-react-application-using-i18next-3hdb)
139139
{% endhint %}
140-

Diff for: guides/multiple-translation-files.md

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
# Multiple Translation Files
22

3-
One of the advantages of react-i18next is based on i18next it supports the separation of translations into multiple files - which are called namespaces in i18next context -&gt; as you're accessing keys from a namespace defining that as a prefix:
3+
One of the advantages of react-i18next is based on i18next it supports the separation of translations into multiple files - which are called namespaces in i18next context -> as you're accessing keys from a namespace defining that as a prefix:
44

55
So while this takes the translation from the defined default namespace:
66

77
```javascript
88
i18next.t('look.deep');
99
```
1010

11-
This will lookup the key in a namespace \(file\) called common.json:
11+
This will lookup the key in a namespace (file) called common.json:
1212

1313
```javascript
14-
i18next.t('common:look.deep');
14+
i18next.t('common:look.deep');
15+
// better use the ns option:
16+
i18next.t('look.deep', { ns: 'common' })
1517
```
1618

1719
In order to use multiple namespaces/translation files, you need to specify it when calling [`useTranslation`](https://react.i18next.com/latest/usetranslation-hook) :
@@ -42,27 +44,25 @@ In i18next you got a lot of options to add translations on init, in your code ca
4244

4345
With react-i18next you can use any of the components passing down the `t` function to your components to load namespaces:
4446

45-
* [useTranslation \(hook\)](../latest/usetranslation-hook.md)
46-
* [withTranslation \(HOC\)](../latest/withtranslation-hoc.md)
47-
* [Translation \(render prop\)](../latest/translation-render-prop.md)
47+
* [useTranslation (hook)](../latest/usetranslation-hook.md)
48+
* [withTranslation (HOC)](../latest/withtranslation-hoc.md)
49+
* [Translation (render prop)](../latest/translation-render-prop.md)
4850

4951
All take arguments to define which namespaces to load and will Suspense rendering until those got loaded.
5052

51-
So you do not need to load all translations upfront enabling you to create huge react based applications without slowing down loading of the first page cause all translations need to be loaded upfront \(hello other i18n implementations\).
53+
So you do not need to load all translations upfront enabling you to create huge react based applications without slowing down loading of the first page cause all translations need to be loaded upfront (hello other i18n implementations).
5254

5355
## Manage your translations with a management GUI
5456

55-
### \*\*\*\*[**locize**](https://locize.com) is the perfect translation management tool for your [**i18next**](https://www.i18next.com) project
57+
### ****[**locize**](https://locize.com) is the perfect translation management tool for your [**i18next**](https://www.i18next.com) project
5658

57-
#### ➡️ [i18next](https://www.i18next.com/) + [locize](https://locize.com/) = [true continuous localization](https://locize.com/how-it-works.html#continouslocalization)
59+
#### ➡️ [i18next](https://www.i18next.com) + [locize](https://locize.com) = [true continuous localization](https://locize.com/how-it-works.html#continouslocalization)
5860

59-
[Here](https://github.com/locize/react-tutorial) you can find a step by step guide, which will unleash the full power of i18next in combination with locize.
60-
See how your developer experience with this localization workflow [could look like](https://youtu.be/osScyaGMVqo).
61-
There's also the possibility to have an [even more focused developer experience](https://youtu.be/VfxBpSXarlU), with the help of the [auto-machinetranslation workflow](https://docs.locize.com/whats-inside/auto-machine-translation) and the use of the save missing keys functionality, new keys not only gets added to locize automatically, while developing the app, but are also [automatically translated](https://youtu.be/VfxBpSXarlU) into the target languages using machine translation \(like [Google Translate](https://cloud.google.com/translate)\).
61+
[Here](https://github.com/locize/react-tutorial) you can find a step by step guide, which will unleash the full power of i18next in combination with locize.\
62+
See how your developer experience with this localization workflow [could look like](https://youtu.be/osScyaGMVqo).\
63+
There's also the possibility to have an [even more focused developer experience](https://youtu.be/VfxBpSXarlU), with the help of the [auto-machinetranslation workflow](https://docs.locize.com/whats-inside/auto-machine-translation) and the use of the save missing keys functionality, new keys not only gets added to locize automatically, while developing the app, but are also [automatically translated](https://youtu.be/VfxBpSXarlU) into the target languages using machine translation (like [Google Translate](https://cloud.google.com/translate)).
6264

6365
{% embed url="https://youtu.be/osScyaGMVqo" %}
6466

6567
{% embed url="https://youtu.be/VfxBpSXarlU" %}
6668

67-
68-

Diff for: guides/quick-start.md

+4-5
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ Check out this basic [react example](https://github.com/i18next/react-i18next/tr
1919
#### Do you like to read a more complete step by step tutorial?
2020

2121
{% hint style="success" %}
22-
[Here](https://dev.to/adrai/how-to-properly-internationalize-a-react-application-using-i18next-3hdb) you'll find a simple tutorial on how to best use react-i18next.
23-
Some basics of i18next and some cool possibilities on how to optimize your localization workflow.[
24-
![](../.gitbook/assets/title-width.jpg)](https://dev.to/adrai/how-to-properly-internationalize-a-react-application-using-i18next-3hdb)
22+
[Here](https://dev.to/adrai/how-to-properly-internationalize-a-react-application-using-i18next-3hdb) you'll find a simple tutorial on how to best use react-i18next.\
23+
Some basics of i18next and some cool possibilities on how to optimize your localization workflow.[\
24+
![](<../.gitbook/assets/title width.jpg>)](https://dev.to/adrai/how-to-properly-internationalize-a-react-application-using-i18next-3hdb)
2525
{% endhint %}
2626

2727
## Configure i18next
@@ -179,6 +179,5 @@ Prefer having code to checkout? Directly dive into our examples:
179179

180180
> **Would you like to visually check the progress state of your translations?**
181181
>
182-
> _Try_ [_translation-check_](https://github.com/locize/translation-check)_, it shows an overview of your translations in a nice UI. Check which keys are not yet translated._
182+
> _Try_ [_translation-check_](https://github.com/locize/translation-check)_, it shows an overview of your translations in a nice UI. Check which keys are not yet translated._\
183183
> [![](../.gitbook/assets/preview.jpg) ](https://github.com/locize/translation-check)
184-

Diff for: guides/the-drawbacks-of-other-i18n-solutions.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,8 @@ Let's take following content:
9797

9898
In most frameworks you will end having to split this into multiple translation strings. But for your translators it would make sense to have this as one sentence to translate like eg.:
9999

100-
```text
100+
```
101101
Hello <1>{name}</1>, you have <3>{count} unread message(s)</3>.
102102
```
103103

104104
You can do this using the [Trans component](../latest/trans-component.md).
105-

Diff for: latest/i18next-instance.md

+8-9
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,13 @@ export default i18n;
4343

4444
All additional options for react in init options:
4545

46-
| options | default | description |
47-
| :--- | :--- | :--- |
48-
| bindI18n | 'languageChanged' | which events trigger a rerender, can be set to false or string of events separated by "" |
49-
| bindI18nStore | '' | define which events on [resourceStore](https://www.i18next.com/overview/api#store-events) should trigger a rerender |
50-
| transEmptyNodeValue | '' | how to treat failed lookups in Trans component |
51-
| transSupportBasicHtmlNodes | true | convert eg. `<br/>` found in translations to a react component of type br [See Trans component](trans-component.md#using-for-simple-html-elements-in-translations-v-10-4-0) |
52-
| transKeepBasicHtmlNodesFor | \['br', 'strong', 'i', 'p'\] | Which nodes not to convert in defaultValue generation in the Trans component. [See Trans component](trans-component.md#using-for-simple-html-elements-in-translations-v-10-4-0) |
53-
| useSuspense | true | If using Suspense or not |
46+
| options | default | description |
47+
| -------------------------- | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
48+
| bindI18n | 'languageChanged' | <p>which events trigger a rerender, can be set to false or string of events <br> separated by ""</p> |
49+
| bindI18nStore | '' | define which events on [resourceStore](https://www.i18next.com/overview/api#store-events) should trigger a rerender |
50+
| transEmptyNodeValue | '' | how to treat failed lookups in Trans component |
51+
| transSupportBasicHtmlNodes | true | <p>convert eg. <code>&#x3C;br/></code> found in translations to a react component of type br <br> <a href="trans-component.md#using-for-simple-html-elements-in-translations-v-10-4-0">See Trans component</a></p> |
52+
| transKeepBasicHtmlNodesFor | \['br', 'strong', 'i', 'p'] | <p>Which nodes not to convert in defaultValue generation in the Trans component. <br> <a href="trans-component.md#using-for-simple-html-elements-in-translations-v-10-4-0">See Trans component</a></p> |
53+
| useSuspense | true | If using Suspense or not |
5454

5555
For more initialization options have look at the [docs](https://www.i18next.com/configuration-options.html).
56-

Diff for: latest/i18nextprovider.md

+4-5
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,10 @@ import App from './App';
1616

1717
## When to use?
1818

19-
You will only need to use the provider in scenarios for SSR \(ServerSideRendering\) or if you need to support multiple i18next instances - eg. if you provide a component library.
19+
You will only need to use the provider in scenarios for SSR (ServerSideRendering) or if you need to support multiple i18next instances - eg. if you provide a component library.
2020

2121
## I18nextProvider props
2222

23-
| _**name**_ | **type \(**_**default\)**_ | _**description**_ |
24-
| :--- | :--- | :--- |
25-
| **i18n** | object \(undefined\) | pass i18next instance the provider will pass it down to translation components by context |
26-
23+
| _**name**_ | **type (**_**default)**_ | _**description**_ |
24+
| ---------- | ------------------------ | ----------------------------------------------------------------------------------------- |
25+
| **i18n** | object (undefined) | pass i18next instance the provider will pass it down to translation components by context |

Diff for: latest/migrating-v9-to-v10.md

+12-13
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export function MyComponent() {
2121

2222
## Components without replacement
2323

24-
The Interpolation component \(which was marked as deprecated for a long time and replaced by the Trans Component\) was removed finally. You will need to replace it with the Trans Component.
24+
The Interpolation component (which was marked as deprecated for a long time and replaced by the Trans Component) was removed finally. You will need to replace it with the Trans Component.
2525

2626
## Migration
2727

@@ -56,15 +56,14 @@ The `I18nextProvider` no longer provides as many properties as before. Make the
5656
}
5757
```
5858

59-
## Components v9 -&gt; v10
60-
61-
| Type | &lt;= v7 \(v8\) | v9 \(v8\) | v10 |
62-
| :--- | :--- | :--- | :--- |
63-
| hook | | - | useTranslation |
64-
| HOC | translate | withNamespaces | withTranslation |
65-
| render prop | I18n | NamespacesConsumer | Translation |
66-
| i18next plugin | reactI18nextModule | reactI18nextModule | initReactI18next |
67-
| Provider | I18nextProvider | I18nextProvider | I18nextProvider |
68-
| Complex Translation | Trans | Trans | Trans |
69-
| Interpolations | Interpolate | Interpolate | Trans |
70-
59+
## Components v9 -> v10
60+
61+
| Type | <= v7 (v8) | v9 (v8) | v10 |
62+
| ------------------- | ------------------ | ------------------ | ---------------- |
63+
| hook | | - | useTranslation |
64+
| HOC | translate | withNamespaces | withTranslation |
65+
| render prop | I18n | NamespacesConsumer | Translation |
66+
| i18next plugin | reactI18nextModule | reactI18nextModule | initReactI18next |
67+
| Provider | I18nextProvider | I18nextProvider | I18nextProvider |
68+
| Complex Translation | Trans | Trans | Trans |
69+
| Interpolations | Interpolate | Interpolate | Trans |

0 commit comments

Comments
 (0)