diff --git a/zh-cn/react-native-localization-settings.md b/zh-cn/react-native-localization-settings.md new file mode 100644 index 0000000000000000000000000000000000000000..ebe05cf3beedb3a44ba1d309aeb670c3f38d3247 --- /dev/null +++ b/zh-cn/react-native-localization-settings.md @@ -0,0 +1,235 @@ +> 模板版本:v0.2.2 + +

+

react-native-localization-settings

+

+

+ + Supported platforms + + + License + + +

+ +> [!TIP] [Github 地址](https://github.com/react-native-oh-library/react-native-localization-settings) + +## 安装与使用 + +请到三方库的 Releases 发布地址查看配套的版本信息:[@react-native-oh-tpl/react-native-localization-settings Releases](https://github.com/react-native-oh-library/react-native-localization-settings/releases),并下载适用版本的 tgz 包。 + +进入到工程目录并输入以下命令: + +> [!TIP] # 处替换为 tgz 包的路径 + + + +#### **npm** + +```bash +npm install @react-native-oh-tpl/react-native-localization-settings@file:# +``` + +#### **yarn** + +```bash +yarn add @react-native-oh-tpl/react-native-localization-settings@file:# +``` + + + +下面的代码展示了这个库的基本使用场景: + +> [!WARNING] 使用时 import 的库名不变。 + +```js +import * as React from "react"; +import { StyleSheet, View, Text, Button } from "react-native"; +import { ReactNativeLanguageDetector } from "react-native-localization-settings"; +import i18next from "i18next"; +import { initReactI18next, useTranslation } from "react-i18next"; + +i18next + .use(ReactNativeLanguageDetector) + .use(initReactI18next) + .init({ + resources: { + en: { + translation: { + key: "hello world in english", + }, + }, + pl: { + translation: { + key: "hello world in polish", + }, + }, + fr: { + translation: { + key: "hello world in french", + }, + }, + }, + fallbackLng: "en", + interpolation: { + escapeValue: false, + }, + compatibilityJSON: "v3", + }); + +export default function App() { + const { t } = useTranslation(); + + return ( + + {t("key")} +