Skip to content

Commit 891d7df

Browse files
authored
docs: minor improvements to RN docs (#1709)
1 parent 31e9105 commit 891d7df

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

website/docs/misc/resources.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010

1111
- [Let React speak your language](https://www.youtube.com/watch?v=soAEB7ltQPk) - by Tomáš Ehrlich
1212
- [Internationalization is a piece of cake](https://www.youtube.com/watch?v=vhUiL_wUAjo) - by Eli Schutze
13-
- [Localizing React Native apps talk from React Native EU 2022](https://www.youtube.com/live/uLicTDG5hSs?feature=share&t=7512)
13+
- [Localizing React Native apps talk from React Native EU 2022](https://www.youtube.com/live/uLicTDG5hSs?feature=share&t=7512) - by [Vojtech Novak](https://twitter.com/vonovak); covers RN but general i18n topics as well

website/docs/tutorials/react-native.md

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ If you're looking for a working solution, check out the [sources available here]
99
:::
1010

1111
:::caution Note
12-
This tutorial assumes you use Lingui 4.x and React Native >=0.71 or Expo >=48, with the Hermes JavaScript Engine.
12+
This tutorial assumes you use Lingui >= 4.2 and React Native >=0.71 or Expo >=48, with the Hermes JavaScript Engine.
1313

1414
`@lingui/core` depends on several apis exposed by the [`Intl` object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl). Support of the `Intl` object can vary across React Native and OS versions.
1515
If some `Intl` feature is not supported by your runtime, you can [polyfill it](https://formatjs.io/docs/polyfills).
@@ -23,14 +23,6 @@ React Native does not support all `Intl` features out of the box and we need to
2323

2424
Follow the polyfill installation instructions before proceeding further.
2525

26-
## Metro bundler support
27-
28-
Lingui packages make use of the `exports` keyword in `package.json`. Metro bundler versions < 0.76.2 (before React Native 0.72) do not support this feature.
29-
30-
There are two ways to make Metro understand the exports. With the first approach, make sure that (1) you're running metro 0.76.2 or newer (if necessary, use yarn resolutions or npm overrides) and (2) `unstable_enablePackageExports` is enabled in your `metro.config.js` file. See the [example](https://github.com/lingui/js-lingui/tree/main/examples/react-native/metro.config.js). Note that future versions of metro will have this option enabled by default so there will be no need to configure this.
31-
32-
Alternatively, you can [configure the resolver](https://github.com/lingui/js-lingui/issues/1633#issuecomment-1532243227).
33-
3426
## Example component
3527

3628
We're going to translate the following contrived example:
@@ -183,6 +175,8 @@ const showDeleteConfirmation = () => {
183175

184176
The last remaining piece of the puzzle is changing the active locale. The `i18n` object exposes [`i18n.loadAndActivate()`](/ref/core#i18n.loadAndActivate) for that. Call the method and the [`I18nProvider`](/docs/ref/react.md#i18nprovider) will re-render the translations. It all becomes clear when you take a look at the [final code](https://github.com/lingui/js-lingui/tree/main/examples/react-native/src/MainScreen.tsx#L29).
185177

178+
However, we don't recommend that you change the locale like this, as it can cause conflicts in how your app ui is localized. This is further [explained here](https://www.youtube.com/live/uLicTDG5hSs?feature=share&t=9088).
179+
186180
## Choosing the default locale
187181

188182
Lingui does not ship with functionality that would allow you to determine the best locale you should activate by default.
@@ -231,6 +225,7 @@ The important point here is that the sentence isn't broken into pieces but remai
231225

232226
## Further reading
233227

228+
- [Common i18n patterns in React](/docs/tutorials/react-patterns.md)
234229
- [`@lingui/react` reference documentation](/docs/ref/react.md)
235230
- [`@lingui/cli` reference documentation](/docs/ref/cli.md)
236231
- [Localizing React Native apps talk from React Native EU 2022](https://www.youtube.com/live/uLicTDG5hSs?feature=share&t=7512)

0 commit comments

Comments
 (0)