अपने प्रश्न को पूछें और दस्तावेज़ का सारांश प्राप्त करें, इस पृष्ठ और आपके चुने हुए 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 Intl से Intlayer में माइग्रेट करें
यदि आपकी React एप्लिकेशन react-intl (FormatJS) का उपयोग करती है, तो Intlayer में संक्रमण करना आसान है। हमारी compat layer निर्बाध रूप से ICU MessageFormat और सभी मौजूदा Formatted* घटकों को संभालता है।
क्या करें
अपने प्रोजेक्ट में इनिशियलाइजेशन कमांड चलाकर शुरू करें:
कोड को क्लिपबोर्ड पर कॉपी करें
npx intlayer initफिर, अपने कॉन्फ़िगरेशन में Intlayer Vite या Next.js प्लगइन सेट अप करें। यह प्लगइन react-intl imports को @intlayer/react-intl में रीडायरेक्ट करने के लिए बिल्ड-टाइम aliases इंजेक्ट करता है।
कोड को क्लिपबोर्ड पर कॉपी करें
import { defineConfig } from "vite";import react from "@vitejs/plugin-react";import reactIntlVitePlugin from "@intlayer/react-intl/plugin";export default defineConfig({ plugins: [react(), reactIntlVitePlugin()],});यह हुड के नीचे क्या करता है
bundler plugin react-intl को @intlayer/react-intl में alias करता है। बड़ी JSON फाइलों को मैन्युअल रूप से पार्स करने और अपने ऐप को IntlProvider में लपेटने के बजाय, Intlayer plugin स्टैटिकली keys को निकालता है और runtime पर Intlayer dictionaries का उपयोग करता है।
हुड के नीचे:
- ICU MessageFormat: Intlayer
resolveMessage(..., 'icu')resolver का उपयोग करता है जो ICU pluralization, selection, date/number formatting, और rich text tags को नेटिवली पूरी तरह support करता है। - Method & JSX callers:
intl.formatMessage({ id: 'a.b' })और<FormattedMessage id="a.b">को Intlayer compiler plugins (@intlayer/babel/@intlayer/swc) द्वारा identify किया जाता है, flat dotted keys को convert करके ताकि पहला segment सही तरीके से Intlayer dictionary key को resolve करे। - Formatters:
<FormattedNumber>,<FormattedDate>, आदिIntlका उपयोग करके nativecore/formattersमें bridge करते हैं।