अपने प्रश्न को पूछें और दस्तावेज़ का सारांश प्राप्त करें, इस पृष्ठ और आपके चुने हुए AI प्रदाता का उपयोग करके
यह दस्तावेज़ पुराना है, आधार संस्करण को इस तिथि पर अपडेट किया गया है 23 अगस्त 2025.
अंग्रेजी दस्तावेज़ पर जाएँसंस्करण इतिहास
- "प्रारंभिक इतिहास"v5.5.1029/6/2025
इस पृष्ठ की सामग्री एक AI द्वारा अनुवादित की गई है।
अंग्रेजी में मूल सामग्री के अंतिम संस्करण देखेंअगर आपके पास इस दस्तावेज़ को सुधारने के लिए कोई विचार है, तो कृपया GitHub पर एक पुल अनुरोध सबमिट करके योगदान देने में संकोच न करें।
दस्तावेज़ के लिए GitHub लिंकदस्तावेज़ का Markdown को क्लिपबोर्ड पर कॉपी करें
एनेमरेशन / बहुवचन रूप
एनेमरेशन कैसे काम करता है
Intlayer में, एनेमरेशन enu फ़ंक्शन के माध्यम से प्राप्त किया जाता है, जो विशिष्ट कुंजियों को उनके संबंधित सामग्री से मैप करता है। ये कुंजियाँ संख्यात्मक मान, रेंज, या कस्टम पहचानकर्ता हो सकती हैं। जब React Intlayer या Next Intlayer के साथ उपयोग किया जाता है, तो एप्लिकेशन की लोकल और परिभाषित नियमों के आधार पर उपयुक्त सामग्री स्वचालित रूप से चुनी जाती है।
एनेमरेशन सेटअप करना
अपने Intlayer प्रोजेक्ट में एनेमरेशन सेटअप करने के लिए, आपको एक कंटेंट मॉड्यूल बनाना होगा जिसमें एनेमरेशन परिभाषाएँ शामिल हों। यहाँ कारों की संख्या के लिए एक सरल एनेमरेशन का उदाहरण दिया गया है:
कोड को क्लिपबोर्ड पर कॉपी करें
import { enu, type Dictionary } from "intlayer";
const carEnumeration = {
key: "car_count",
content: {
numberOfCar: enu({
"<-1": "माइनस एक कार से कम",
"-1": "माइनस एक कार",
"0": "कोई कार नहीं",
"1": "एक कार",
">5": "कुछ कारें",
">19": "कई कारें",
"fallback": "फॉलबैक मान", // वैकल्पिक
}),
},
} satisfies Dictionary;
export default carEnumeration;
इस उदाहरण में, enu विभिन्न स्थितियों को विशिष्ट सामग्री से मैप करता है। जब इसे एक React घटक में उपयोग किया जाता है, तो Intlayer दिए गए चर के आधार पर स्वचालित रूप से उपयुक्त सामग्री चुन सकता है।
Intlayer एनेमरेशन में घोषणा का क्रम महत्वपूर्ण होता है। पहली मान्य घोषणा को चुना जाएगा। यदि कई स्थितियां लागू होती हैं, तो सुनिश्चित करें कि वे सही क्रम में हैं ताकि अप्रत्याशित व्यवहार से बचा जा सके।
यदि कोई फॉलबैक घोषित नहीं किया गया है, तो यदि कोई कुंजी मेल नहीं खाती है, तो फ़ंक्शन undefined लौटाएगा।
React Intlayer के साथ एनेमरेशन का उपयोग करना
To use enumeration in a React component, you can leverage the useIntlayer hook from the react-intlayer package. This hook retrieves the correct content based on the specified ID. Here's an example of how to use it:
कोड को क्लिपबोर्ड पर कॉपी करें
import type { FC } from "react";
import { useIntlayer } from "react-intlayer";
const CarComponent: FC = () => {
const { numberOfCar } = useIntlayer("car_count");
return (
<div>
<p>
{
numberOfCar(0) // Output: No cars
}
</p>
<p>
{
numberOfCar(6) // Output: Some cars
}
</p>
<p>
{
numberOfCar(20) // Output: Many cars
}
</p>
<p>
{
numberOfCar(0.01) // Output: Fallback value
}
</p>
</div>
);
};
To use enumeration in Next.js Client Components, retrieve it via the useIntlayer hook. Here's an example:
कोड को क्लिपबोर्ड पर कॉपी करें
"use client";
import type { FC } from "react";
import { useIntlayer } from "next-intlayer";
const CarComponent: FC = () => {
const { numberOfCar } = useIntlayer("car_count");
return (
<div>
<p>{numberOfCar(6)}</p>
</div>
);
};
export default CarComponent;
To use enumeration in Vue components, retrieve it via the useIntlayer hook. Here's an example:
कोड को क्लिपबोर्ड पर कॉपी करें
To use enumeration in Svelte components, retrieve it via the useIntlayer hook. The store is accessed with $. Here's an example:
कोड को क्लिपबोर्ड पर कॉपी करें
To use enumeration in Preact components, retrieve it via the useIntlayer hook. Here's an example:
कोड को क्लिपबोर्ड पर कॉपी करें
import type { FC } from "preact";
import { useIntlayer } from "preact-intlayer";
const CarComponent: FC = () => {
const { numberOfCar } = useIntlayer("car_count");
return (
<div>
<p>{numberOfCar(6)}</p>
</div>
);
};
export default CarComponent;
To use enumeration in SolidJS components, retrieve it via the useIntlayer hook. Here's an example:
कोड को क्लिपबोर्ड पर कॉपी करें
import type { Component } from "solid-js";
import { useIntlayer } from "solid-intlayer";
const CarComponent: Component = () => {
const { numberOfCar } = useIntlayer("car_count");
return (
<div>
<p>{numberOfCar(6)}</p>
</div>
);
};
export default CarComponent;
To use enumeration in Angular components, retrieve it via the useIntlayer hook. Here's an example:
कोड को क्लिपबोर्ड पर कॉपी करें
To use enumeration with vanilla-intlayer, retrieve it via the useIntlayer hook. Here's an example:
कोड को क्लिपबोर्ड पर कॉपी करें
import { installIntlayer, useIntlayer } from "vanilla-intlayer";
installIntlayer();
const content = useIntlayer("car_count").onChange((newContent) => {
document.getElementById("cars")!.textContent = newContent.numberOfCar(6);
});
// Initial render
document.getElementById("cars")!.textContent = content.numberOfCar(6);
अतिरिक्त संसाधन
कॉन्फ़िगरेशन और उपयोग के बारे में अधिक विस्तृत जानकारी के लिए, निम्नलिखित संसाधनों को देखें:
ये संसाधन विभिन्न वातावरणों और विभिन्न फ्रेमवर्क के साथ Intlayer की सेटअप और उपयोग के बारे में और अधिक जानकारी प्रदान करते हैं।
Using Ordinal Enumeration
To use this in a React component, call the enumeration with the last digit of the number to get the correct suffix, then pass the full count as the insertion value:
कोड को क्लिपबोर्ड पर कॉपी करें
import type { FC } from "react";
import { useIntlayer } from "react-intlayer";
const RankingComponent: FC<{ count: number }> = ({ count }) => {
const { ordinal } = useIntlayer("ranking_component");
// Get the last digit to determine the correct suffix
const lastDigit = Math.abs(count) % 10;
return (
<div>
<p>
{
ordinal(lastDigit)({ count }) // e.g., "5th place" for count=5
}
</p>
</div>
);
};
To use this in Next.js Client Components, call the enumeration with the last digit of the number to get the correct suffix, then pass the full count as the insertion value:
कोड को क्लिपबोर्ड पर कॉपी करें
"use client";
import type { FC } from "react";
import { useIntlayer } from "next-intlayer";
const RankingComponent: FC<{ count: number }> = ({ count }) => {
const { ordinal } = useIntlayer("ranking_component");
const lastDigit = Math.abs(count) % 10;
return (
<div>
<p>{ordinal(lastDigit)({ count })}</p>
</div>
);
};
export default RankingComponent;
To use this in Vue components, call the enumeration with the last digit of the number to get the correct suffix, then pass the full count as the insertion value:
कोड को क्लिपबोर्ड पर कॉपी करें
To use this in Svelte components, call the enumeration with the last digit of the number to get the correct suffix, then pass the full count as the insertion value:
कोड को क्लिपबोर्ड पर कॉपी करें
To use this in Preact components, call the enumeration with the last digit of the number to get the correct suffix, then pass the full count as the insertion value:
कोड को क्लिपबोर्ड पर कॉपी करें
import type { FC } from "preact";
import { useIntlayer } from "preact-intlayer";
const RankingComponent: FC<{ count: number }> = ({ count }) => {
const { ordinal } = useIntlayer("ranking_component");
const lastDigit = Math.abs(count) % 10;
return (
<div>
<p>{ordinal(lastDigit)({ count })}</p>
</div>
);
};
export default RankingComponent;
To use this in SolidJS components, call the enumeration with the last digit of the number to get the correct suffix, then pass the full count as the insertion value:
कोड को क्लिपबोर्ड पर कॉपी करें
import type { Component } from "solid-js";
import { useIntlayer } from "solid-intlayer";
const RankingComponent: Component<{ count: number }> = (props) => {
const { ordinal } = useIntlayer("ranking_component");
return (
<div>
<p>{ordinal(Math.abs(props.count) % 10)({ count: props.count })}</p>
</div>
);
};
export default RankingComponent;
To use this in Angular components, call the enumeration with the last digit of the number to get the correct suffix, then pass the full count as the insertion value:
कोड को क्लिपबोर्ड पर कॉपी करें
To use this with vanilla-intlayer, call the enumeration with the last digit of the number to get the correct suffix, then pass the full count as the insertion value:
कोड को क्लिपबोर्ड पर कॉपी करें
import { installIntlayer, useIntlayer } from "vanilla-intlayer";
installIntlayer();
const content = useIntlayer("ranking_component");
const lastDigit = Math.abs(5) % 10;
document.getElementById("ranking")!.textContent = content.ordinal(lastDigit)({
count: 5,
});
Additional Resources
For more detailed information on configuration and usage, refer to the following resources:
These resources provide further insights into the setup and usage of Intlayer in different environments and with various frameworks.
