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 history"v5.5.1029/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
Documentation: getTranslationContent Function in intlayer
Description
The getTranslationContent function retrieves the content corresponding to a specific locale from a set of customisable language content. If the specified locale is not found, it defaults to returning the content for the default locale configured in the project.
The getTranslationContent function retrieves the content corresponding to a specific locale from a set of customisable language content. If the specified locale is not found, it defaults to returning the content for the default locale configured in the project.
Parameters
languageContent: CustomizableLanguageContent<Content>- Description: An object containing translations for various locales. Each key represents a locale, and its value is the corresponding content.
- Type:
CustomizableLanguageContent<Content>Contentcan be any type, defaulting tostring.
locale: Locales- Description: The locale for which content is to be retrieved.
- Type:
Locales
Returns
- Type:
Content - Description: The content corresponding to the specified locale. If the locale is not found, the content of the default locale is returned.
Example Usage
Basic Usage
Missing Locale:
Using Custom Content Types:
Using Custom Content Types:
Edge Cases
- Locale Not Found:
- When the
localeis not found in thelanguageContent, the function returns the content for the default locale.
- When the
- Incomplete Language Content:
- If a locale is partially defined, the function does not merge contents. It strictly retrieves the value of the specified locale or falls back to the default.
- TypeScript Enforcement:
- If the locales in
languageContentdo not match the project configuration, TypeScript will enforce all required locales to be defined, ensuring the content is complete and type-safe.
- If the locales in