このページとあなたの好きなAIアシスタントを使ってドキュメントを要約します
バージョン履歴
- "react-intlayer の完全な API(フック、ユーティリティ、format/html/markdown サブパス)を再エクスポートし、React Native アプリが react-native-intlayer のみに依存できるようにした"v9.0.02026/6/25
- "すべてのエクスポートに関するドキュメントを統一"v8.0.02026/1/21
このページのコンテンツはAIを使用して翻訳されました。
英語の元のコンテンツの最新バージョンを見るIf you have an idea for improving this documentation, please feel free to contribute by submitting a pull request on GitHub.
GitHub link to the documentationCopy doc Markdown to clipboard
react-native-intlayer パッケージ
react-native-intlayer パッケージは、Intlayer を React Native アプリケーションに統合するために必要なツールを提供します。React Native 対応の IntlayerProvider を備えた react-intlayer の完全な API(フックとユーティリティ)を再エクスポートし、React Native に必要なポリフィルと Metro 設定も含みます。
React Native アプリでは、react-native-intlayerからすべてをインポートしてください。react-intlayerを直接インストールまたはインポートする必要はありません。
インストール
コードをクリップボードにコピー
npm install react-native-intlayerエクスポート
プロバイダー
テーブルをモーダルで開き、すべてのデータを明確に表示
| コンポーネント | 説明 |
|---|---|
IntlayerProvider | アプリケーションをラップし、Intlayer コンテキストを提供するプロバイダーコンポーネント。必要なポリフィルを自動的に適用します。 |
コードをクリップボードにコピー
import { IntlayerProvider } from "react-native-intlayer";フックとユーティリティ
これらは react-intlayer から再エクスポートされているため、react-native-intlayer から直接インポートできます:
テーブルをモーダルで開き、すべてのデータを明確に表示
| エクスポート | 説明 |
|---|---|
useIntlayer | 辞書キーのローカライズされたコンテンツにアクセス。 |
useLocale | 現在のロケールを読み取り、変更する。 |
useDictionary, useDictionaryAsync, useDictionaryDynamic, useLoadDynamic | さまざまな方法で辞書コンテンツを読み込む。 |
useI18n | i18next 互換フック。 |
t | インライン翻訳ヘルパー。 |
getIntlayer, getDictionary | 命令型コンテンツゲッター。 |
localeCookie, localeInStorage, setLocaleCookie, setLocaleInStorage, useLocaleCookie, useLocaleStorage | ロケール永続化ヘルパー。 |
コードをクリップボードにコピー
import { useIntlayer, useLocale, t } from "react-native-intlayer";ポリフィル
テーブルをモーダルで開き、すべてのデータを明確に表示
| 関数 | 説明 |
|---|---|
intlayerPolyfill | React Native が Intlayer をサポートするために必要なポリフィルを適用する関数。 |
コードをクリップボードにコピー
import { intlayerPolyfill } from "react-native-intlayer";ポリフィルはIntlayerProviderをインポートすると自動的に適用されます。プロバイダーがマウントされる前にポリフィルが必要な場合のみ、intlayerPolyfillを手動で呼び出してください。
フォーマッター
数値、日付、その他の Intl ベースのフォーマットフックは /format サブパスから利用できます:
コードをクリップボードにコピー
import { useNumber, useDate } from "react-native-intlayer/format";Markdown と HTML のレンダリング
コードをクリップボードにコピー
import { MarkdownProvider } from "react-native-intlayer/markdown";import { HTMLProvider } from "react-native-intlayer/html";Metro の設定
react-native-intlayer パッケージは、Intlayer が React Native 上で正しく動作するようにするための Metro 設定ユーティリティを提供します。
テーブルをモーダルで開き、すべてのデータを明確に表示
| 関数 | 説明 |
|---|---|
configMetroIntlayer | Intlayer を準備し、Metro 設定をマージする非同期関数。 |
configMetroIntlayerSync | Intlayer のリソースを準備せずに Metro 設定をマージする同期関数。 |
exclusionList | バンドルからコンテンツファイルを除外するために、Metro の blockList 用の RegExp パターンを作成します。 |
コードをクリップボードにコピー
import { configMetroIntlayer } from "react-native-intlayer/metro";