From 18ffe1d14866a35c7d4c2ff903ce38775578b556 Mon Sep 17 00:00:00 2001 From: ljje <1370314186@qq.com> Date: Wed, 14 Aug 2024 19:18:23 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20[Issues:=20#IAJKTZ]=20=E6=96=B0?= =?UTF-8?q?=E5=A2=9Ereact-native-localization-settings=E6=8C=87=E5=AF=BC?= =?UTF-8?q?=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- zh-cn/react-native-localization-settings.md | 235 ++++++++++++++++++++ 1 file changed, 235 insertions(+) create mode 100644 zh-cn/react-native-localization-settings.md diff --git a/zh-cn/react-native-localization-settings.md b/zh-cn/react-native-localization-settings.md new file mode 100644 index 00000000..ebe05cf3 --- /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")} +