अपने प्रश्न को पूछें और दस्तावेज़ का सारांश प्राप्त करें, इस पृष्ठ और आपके चुने हुए AI प्रदाता का उपयोग करके
संस्करण इतिहास
- "Initial documentation"v9.4.023/8/2026
इस पृष्ठ की सामग्री एक AI द्वारा अनुवादित की गई है।
अंग्रेजी में मूल सामग्री के अंतिम संस्करण देखेंअगर आपके पास इस दस्तावेज़ को सुधारने के लिए कोई विचार है, तो कृपया GitHub पर एक पुल अनुरोध सबमिट करके योगदान देने में संकोच न करें।
दस्तावेज़ के लिए GitHub लिंकदस्तावेज़ का Markdown को क्लिपबोर्ड पर कॉपी करें
Documentation: getDictionary Function in intlayer
Description
The getDictionary function interprets a dictionary object you pass yourself and returns its resolved content for a given locale. It walks the content in a single pass and applies each interpreter plugin as needed, resolving t() translations, enumerations, conditions, insertions, nesting, markdown, HTML and file nodes.
Unlike getIntlayer, which looks a dictionary up by key in the generated registry, getDictionary takes the dictionary itself. That makes it the right tool for content built at runtime, fetched from an API or a CMS, or declared inline in a test.
Key Features:
- Works with any object following the dictionary structure (
{ key, content }) - Also accepts a qualified dictionary group (collections, variants) together with a selector
- Fully typed: the returned object mirrors the
contentyou passed - Accepts custom interpreter plugins
Function Signature
कोड को क्लिपबोर्ड पर कॉपी करें
Parameters
dictionary: Dictionary | QualifiedDictionaryGroup- Description: The dictionary (or qualified dictionary group) to interpret.
- Type:
Dictionary | QualifiedDictionaryGroup - Required: Yes
localeOrSelector: LocalesValues | DictionarySelector- Description: The locale to interpret the content with, or a selector object (
{ item },{ variant }, optionally withlocale). See dynamic dictionaries. - Type:
LocalesValues | DictionarySelector - Required: No (Optional) — defaults to the configured
defaultLocale.
- Description: The locale to interpret the content with, or a selector object (
plugins: Plugins[]- Description: An array of node transformers defining how recognized nodes are interpreted. If omitted, the default set of interpreter plugins is used.
- Type:
Plugins[] - Required: No (Optional)
Returns
- Type: The interpreted content of the dictionary.
- Description: The
contentyou passed, with every Intlayer node resolved for the requested locale. For a collection group without anitemselector, an ordered array of interpreted entries is returned;nullis returned when the selector targets nothing.
Example Usage
Basic Usage
कोड को क्लिपबोर्ड पर कॉपी करें
import { getDictionary, t } from "intlayer";
const content = getDictionary(
{
key: "my_key",
content: {
greeting: t({
en: "Hello",
fr: "Bonjour",
}),
},
},
"fr"
);
console.log(content.greeting); // "Bonjour"
Interpreting content fetched at runtime
कोड को क्लिपबोर्ड पर कॉपी करें
With a selector
कोड को क्लिपबोर्ड पर कॉपी करें
Related Functions
getIntlayer: Same interpretation, but the dictionary is looked up by key in the generated registry.getDictionaryAsync: Counterpart for per-locale loader maps.useDictionary: The React hook equivalent, reading the locale from the provider.
TypeScript
कोड को क्लिपबोर्ड पर कॉपी करें