aymericzip/intlayer-skills / skills/intlayer-usage
intlayer-usage
VerifiedProvides general guidelines for using Intlayer in any project. Use when the user asks to "get started with Intlayer", "declare content files", or understand the "project structure" for internationalization.
references/packages_intlayer_getDictionary.md
View on GitHub---
createdAt: 2026-08-23
updatedAt: 2026-09-27
priority: 5
title: getDictionary Function Documentation | intlayer
description: "Use getDictionary to interpret a dictionary object you pass yourself and get its content for a locale, applying every content plugin."
keywords:
- getDictionary
- dictionary
- interpreter
- content
- Intlayer
- intlayer
- Internationalization
- Documentation
- JavaScript
- TypeScript
slugs:
- doc
- packages
- intlayer
- getDictionary
history:
- version: 9.4.0
date: 2026-08-23
changes: "Initial documentation"
author: aymericzip
---
# 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`](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/packages/intlayer/getIntlayer.md), 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.
- [`getIntlayer`](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/packages/intlayer/getIntlayer.md)
**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 `content` you passed
- Accepts custom interpreter plugins
## Function Signature
```typescript
getDictionary(
dictionary: Dictionary | QualifiedDictionaryGroup, // Required
localeOrSelector?: LocalesValues | DictionarySelector, // Optional
plugins?: Plugins[] // Optional
): DeepTransformContent<...>
```
## 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 with `locale`). See [dynamic dictionaries](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/dynamic_dictionaries/index.md).
- **Type**: `LocalesValues | DictionarySelector`
- **Required**: No (Optional), defaults to the configured `defaultLocale`.
- `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 `content` you passed, with every Intlayer node resolved for the requested locale. For a collection group without an `item` selector, an ordered array of interpreted entries is returned; `null` is returned when the selector targets nothing.
## Example Usage
### Basic Usage
```typescript codeFormat={["typescript", "esm", "commonjs"]}
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
```typescript
import { getDictionary, type Dictionary } from "intlayer";
const remoteDictionary: Dictionary = await fetch("/api/cms/banner").then(
(res) => res.json()
);
const banner = getDictionary(remoteDictionary, "fr");
```
### With a selector
```typescript
import { getDictionary } from "intlayer";
// A qualified dictionary group is resolved to a single entry…
const secondItem = getDictionary(blogPostGroup, { item: 2, locale: "fr" });
// …or to an ordered array when no `item` is given
const allItems = getDictionary(blogPostGroup, { locale: "fr" });
```
## Related Functions
- [`getIntlayer`](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/packages/intlayer/getIntlayer.md)
- [`getDictionaryAsync`](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/packages/intlayer/getDictionaryAsync.md)
- [`useDictionary`](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/packages/react-intlayer/useDictionary.md)
## TypeScript
```typescript
function getDictionary<
const T extends Dictionary | QualifiedDictionaryGroup,
const A extends LocalesValues | DictionarySelector = DeclaredLocales,
>(
dictionary: T,
localeOrSelector?: A,
plugins?: Plugins[]
): DeepTransformContent<
ResolveQualifiedDictionaryContent<T, A>,
IInterpreterPluginState,
ExtractSelectorLocale<A>
>;
```
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |