अपने प्रश्न को पूछें और दस्तावेज़ का सारांश प्राप्त करें, इस पृष्ठ और आपके चुने हुए AI प्रदाता का उपयोग करके
संस्करण इतिहास
- "Init history"v9.0.013/6/2026
इस पृष्ठ की सामग्री एक 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-i18next से Intlayer में माइग्रेट करें
एक संपूर्ण और विस्तृत चरण-दर-चरण ट्यूटोरियल के लिए, कृपया हमारी पूर्ण react-i18next माइग्रेशन गाइड देखें।
Intlayer के compat adapter का उपयोग करके आप अपने स्रोत कोड आयातों में कोई बदलाव किए बिना react-i18next से माइग्रेट कर सकते हैं।
क्या करना है
प्रोजेक्ट को शुरू करने के लिए, निम्नलिखित चलाएँ:
कोड को क्लिपबोर्ड पर कॉपी करें
npx intlayer initशुरुआत के दौरान, Intlayer @intlayer/react-i18next को इंस्टॉल करेगा और intlayer.config.ts बनाएगा। आपके bundler (जैसे Vite) में, Intlayer plugin लागू करें:
कोड को क्लिपबोर्ड पर कॉपी करें
import { defineConfig } from "vite";import react from "@vitejs/plugin-react";import { reactI18nextVitePlugin } from "@intlayer/react-i18next/plugin";export default defineConfig({ plugins: [react(), reactI18nextVitePlugin()],});यह हुड के अंदर क्या करता है
reactI18nextVitePlugin कोर vite-intlayer प्लगइन को रैप करता है और react-i18next और i18next के लिए resolve aliases को inject करता है, जिन्हें @intlayer/react-i18next और @intlayer/i18next में रीडायरेक्ट किया जाता है।
हुड के अंदर:
useTranslation&withTranslation: Intlayer के native hooks का उपयोग करने के लिए फिर से लिखा गया है, जो आपके डिक्शनरी keys के लिए स्वचालित TypeScript completion देता है। यह namespaces को seamlessly support करता है (जैसेt('namespace:key')).- Plurals & Context: i18next के suffix-based pluralization (
key_one,key_other) को nativeIntl.PluralRulesऔर context suffixes (key_male) का उपयोग करके हैंडल करता है। <Trans>Component:componentsprop, object और array forms, और numbered tags<1>...</1>को support करने के लिए फिर से implement किया गया है जो सीधे आपके React nodes को map करते हैं।i18ninstance: Intlayer से keys को सीधे resolve करता है बिना बड़ी JSON files को fetch किए, जिससे significantly lower bundle sizes प्राप्त होते हैं।