Ask your question and get a summary of the document by referencing this page and the AI provider of your choice
Version History
- "Unified documentation for all exports"v8.0.021/01/2026
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
intlayer Package
The intlayer package is the core library of the Intlayer ecosystem. It provides the essential functions, types and utilities for managing multilingual content in JavaScript and TypeScript applications.
Installation
Exports
Configuration
Import:
Open the table in a modal to view all data content clearly
| Variable | Type | Description | Related Doc |
|---|---|---|---|
configuration | IntlayerConfig | The Intlayer configuration object. | getConfiguration |
getConfiguration | () => IntlayerConfig | Returns the Intlayer configuration object. (Deprecated: Use configuration instead) | getConfiguration |
locales | Locales[] | The list of all supported locales. | - |
requiredLocales | Locales[] | The list of all required locales. | - |
defaultLocale | Locales | The default locale. | - |
Types
Import:
Open the table in a modal to view all data content clearly
| Type | Description |
|---|---|
Dictionary | The dictionary type used to define a dictionary's structure. |
DeclarationContent | (Deprecated) Use Dictionary<T> instead. |
IntlayerConfig | The type that defines the Intlayer configuration. |
ContentNode | A node within the dictionary content. |
Locale | The type representing a locale. |
LocalesValues | The possible values for a locale. |
StrictModeLocaleMap | A map of locales with strict type-checking. |
Content Functions
Import:
Open the table in a modal to view all data content clearly
| Function | Type | Description | Related Doc |
|---|---|---|---|
t / getTranslation | Function | Selects content based on the current locale. | translation |
enu / getEnumeration | Function | Selects content based on a quantity. | enumeration |
cond / getCondition | Function | Picks content based on a boolean condition. | condition |
gender | Function | Picks content based on a gender. | gender |
insert | Function | Inserts values into a content string. | insertion |
nest / getNesting | Function | Nests another dictionary. | nesting |
md | Function | Processes Markdown content. | markdown |
html | Function | Processes HTML content. | html |
file | Function | Handles file content. | file |
getDictionary | Function | Processes objects that resemble dictionaries (key, content). It processes t() translations, enumerations, etc. | - |
getIntlayer | Function | Based on getDictionary, but injects an optimised version of the dictionary from the generated declaration. | - |
Localisation Utilities
Import:
Open the table in a modal to view all data content clearly
| Function | Type | Description | Related documentation |
|---|---|---|---|
getLocale | Function | Detects the locale from a string or a path. | getLocale |
getLocaleLang | Function | Gets the language component of a locale. | getLocaleLang |
getLocaleName | Function | Gets the display name for a locale. | getLocaleName |
getLocalizedPath | Function | Resolves a canonical path to a localized one. | getLocalizedPath |
getCanonicalPath | Function | Resolves a localized path to its canonical form. | getCanonicalPath |
getLocalizedUrl | Function | Generates a localized URL. | getLocalizedUrl |
getMultilingualUrls | Function | Generates URLs for all supported locales. | getMultilingualUrls |
getPathWithoutLocale | Function | Removes the locale prefix from a path. | getPathWithoutLocale |
getPrefix | Function | Retrieves the locale prefix from a path. | getPrefix |
getHTMLTextDir | Function | Retrieves the text direction (LTR/RTL). | getHTMLTextDir |
validatePrefix | Function | Validates a locale prefix. | validatePrefix |
Browser Utilities
Import:
Open the table in a modal to view all data content clearly
| Function | Type | Description |
|---|---|---|
getBrowserLocale | Function | Detects the browser's preferred locale. |
getCookie | Function | Retrieves a cookie value. |
getLocaleFromStorage | Function | Retrieves the locale from storage. |
setLocaleInStorage | Function | Saves the locale to storage. |
Formatters
Import:
Open the table in a modal to view all data content clearly
| Function | Description |
|---|---|
number | Formats a number. |
currency | Formats a currency value. |
percentage | Formats a percentage. |
compact | Formats a number in compact form. |
date | Formats a date. |
relativeTime | Formats relative time. |
units | Formats a value with units. |
Intl | The standard Intl object. |