# General Translation React SDKs (gt-react, gt-next, gt-react-native): React Native
URL: https://generaltranslation.com/zh/docs/react/react-native.mdx
Docs index: https://generaltranslation.com/llms.txt
Description: 了解 General Translation 在 React Native 中的特有设置，包括初始化、Provider 组件、polyfills 和故障排除。

`gt-react-native` 将 General Translation 带到了 React Native 应用中，包括 Expo 和原生 React Native CLI。它与 React 生态中的其他部分共用同一个 [`<T>`](/docs/react/reference/components/t) 组件、钩子和 variable components，但在设置上有一些 React Native 特有的区别：你需要在模块级进行初始化，Provider 组件 会自行加载翻译，而 Babel 插件则会补上 React Native 缺失的 `Intl` polyfills。

如果你刚开始使用，请先阅读 [React Native Quickstart](/docs/react/react-native-quickstart)。通用的[指南](/docs/react/guides/configuring)和[Reference](/docs/react/reference/config)涵盖了各框架中相同的用法；此处的页面则专门介绍 React Native 独有的设置。

<Callout type="warn">
  **警告：** `gt-react-native` 仍处于实验阶段，可能并不适用于所有项目。它包含原生模块，因此不支持 Expo Go——你需要使用 development build。
</Callout>

## React Native 特有的内容 [#overview]

* **模块级设置。** 你只需在应用的入口文件中调用一次 [`initializeGT`](/docs/react/reference/config#initialize)，而 [`<GTProvider>`](/docs/react/reference/components/gt-provider) 会在内部加载翻译，无需传入 `locale` 和 `translations` 属性。参见 [设置](/docs/react/react-native/setup)。
* **polyfill 插件。** `gt-react-native/plugin` 会注入 React Native 运行时默认不包含的 `@formatjs` `Intl` polyfill。参见 [插件](/docs/react/react-native/plugin)。
* **原生和 Metro 诊断。** 开发构建、已链接的原生模块、Babel 区域设置数据和生成的翻译文件可能会分别出错。参见 [React Native 故障排除](/docs/react/react-native/troubleshooting)。

此外，React Native 也没有预置的 [`<LocaleSelector>`](/docs/react/reference/components/locale-selector) 组件——请改用 [`useLocaleSelector`](/docs/react/reference/hooks/use-locale-selector) 钩子来构建语言切换器。

## 页面 [#pages]

| 页面                                                            | 描述                                                                  |
| ------------------------------------------------------------- | ------------------------------------------------------------------- |
| [设置](/docs/react/react-native/setup)                          | 在 Expo 和原生 React Native 应用中初始化 General Translation，并添加 Provider 组件。 |
| [插件](/docs/react/react-native/plugin)                         | `gt-react-native/plugin` Babel 插件，用于提供 `Intl` polyfill。             |
| [React Native 故障排除](/docs/react/react-native/troubleshooting) | 诊断原生模块、polyfill、区域设置和生成文件相关故障。                                      |

## Sitemap

See the full [sitemap](https://generaltranslation.com/sitemap.md) for all pages.
