Creation:2026-09-19Last update:2026-09-19
Reference this doc to your favorite AI assistantChatGPTClaudeDeepSeekGoogle AI modeGeminiPerplexityMistralGrok
Ask your question and get a summary of the document by referencing this page and the AI provider of your choice
Version History
- "Init doc"v9.5.59/19/2026
Edit this doc
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
Copy doc Markdown to clipboard
useDictionary Hook Documentation
The useDictionary hook resolves an imported or inline dictionary object and returns its content for the current locale in Astro applications.
Unlike useIntlayer, which retrieves dictionaries by key from the global dictionary registry, useDictionary works directly with a dictionary object.
Usage
src/pages/index.astro
Copy code
Copy the code to the clipboard
You can also pass inline dictionaries defined with t():
src/components/Footer.astro
Copy code
Copy the code to the clipboard
Parameters
ts
Copy code
Copy the code to the clipboard
dictionary: A dictionary object or qualified dictionary group.localeOrSelector(optional): A specific locale or selector object ({ item },{ variant }, optionally withlocale).
Description
The hook performs the following tasks:
- Locale Detection: On the server, it obtains the locale from
Astro.locals.intlayer. In the browser, it uses the client-side store locale. - Content Processing: Resolves translations (
t()), enumerations, conditions, and nested structures according to the resolved locale. - Selectors: Applies any item or variant selectors provided in the arguments.
