Ask your question and get a summary of the document by referencing this page and the AI provider of your choice
This doc is out of date, the base version has been updated on 23 August 2025.
Go to English docVersion History
- "Initial writing of `useI18n` hook documentation"v6.0.029/06/2025
The content of this page was translated using an AI.
See the last version of the original content in EnglishIf 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 Integration: useI18n Hook Documentation
This section provides detailed guidance on how to use the useI18n hook within React applications, enabling efficient content localisation.
Importing useI18n in React
The useI18n hook can be imported and integrated into React applications according to the context as follows:
Client Components:
Server Components:
Parameters
This hook accepts two parameters:
namespace: A dictionary namespace to scope the translation keys.locale(optional): The desired locale. If not specified, the context's locale will be used as default.
Dictionary
All dictionary keys must be declared within content declaration files to enhance type safety and prevent errors. Configuration instructions can be found here.
Usage Examples in React
Examples of using the useI18n hook within React components:
Attribute Handling
When localising attributes, access the translation values appropriately:
Additional Resources
- Intlayer Visual Editor: For a more intuitive content management experience, refer to the visual editor documentation here.
This section specifically covers the integration of the useI18n hook in React applications, simplifying the localisation process and ensuring content consistency across different locales.