Author:
    Creation:2026-01-21Last update:2026-01-21

    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

    bash
    npm install intlayer
    

    Exports

    Configuration

    Import:

    tsx
    import "intlayer";
    
    VariableTypeDescriptionRelated Doc
    configurationIntlayerConfigThe Intlayer configuration object.getConfiguration
    getConfiguration() => IntlayerConfigReturns the Intlayer configuration object. (Deprecated: Use configuration instead)getConfiguration
    localesLocales[]The list of all supported locales.-
    requiredLocalesLocales[]The list of all required locales.-
    defaultLocaleLocalesThe default locale.-

    Types

    Import:

    tsx
    import "intlayer";
    
    TypeDescription
    DictionaryThe dictionary type used to define a dictionary's structure.
    DeclarationContent(Deprecated) Use Dictionary<T> instead.
    IntlayerConfigThe type that defines the Intlayer configuration.
    ContentNodeA node within the dictionary content.
    LocaleThe type representing a locale.
    LocalesValuesThe possible values for a locale.
    StrictModeLocaleMapA map of locales with strict type-checking.

    Content Functions

    Import:

    tsx
    import "intlayer";
    
    FunctionTypeDescriptionRelated Doc
    t / getTranslationFunctionSelects content based on the current locale.translation
    enu / getEnumerationFunctionSelects content based on a quantity.enumeration
    cond / getConditionFunctionPicks content based on a boolean condition.condition
    genderFunctionPicks content based on a gender.gender
    insertFunctionInserts values into a content string.insertion
    nest / getNestingFunctionNests another dictionary.nesting
    mdFunctionProcesses Markdown content.markdown
    htmlFunctionProcesses HTML content.html
    fileFunctionHandles file content.file
    getDictionaryFunctionProcesses objects that resemble dictionaries (key, content). It processes t() translations, enumerations, etc.-
    getIntlayerFunctionBased on getDictionary, but injects an optimised version of the dictionary from the generated declaration.-

    Localisation Utilities

    Import:

    tsx
    import "intlayer";
    
    FunctionTypeDescriptionRelated documentation
    getLocaleFunctionDetects the locale from a string or a path.getLocale
    getLocaleLangFunctionGets the language component of a locale.getLocaleLang
    getLocaleNameFunctionGets the display name for a locale.getLocaleName
    getLocalizedPathFunctionResolves a canonical path to a localized one.getLocalizedPath
    getCanonicalPathFunctionResolves a localized path to its canonical form.getCanonicalPath
    getLocalizedUrlFunctionGenerates a localized URL.getLocalizedUrl
    getMultilingualUrlsFunctionGenerates URLs for all supported locales.getMultilingualUrls
    getPathWithoutLocaleFunctionRemoves the locale prefix from a path.getPathWithoutLocale
    getPrefixFunctionRetrieves the locale prefix from a path.getPrefix
    comparePathsFunctionCompares two paths ignoring the locale.comparePaths
    normalizePathFunctionNormalizes a path to a locale-agnostic one.comparePaths
    getHTMLTextDirFunctionRetrieves the text direction (LTR/RTL).getHTMLTextDir
    validatePrefixFunctionValidates a locale prefix.validatePrefix

    Browser Utilities

    Import:

    tsx
    import "intlayer";
    
    FunctionTypeDescription
    getBrowserLocaleFunctionDetects the browser's preferred locale.
    getCookieFunctionRetrieves a cookie value.
    getLocaleFromStorageFunctionRetrieves the locale from storage.
    setLocaleInStorageFunctionSaves the locale to storage.

    Formatters

    Import:

    tsx
    import "intlayer";
    
    FunctionDescription
    numberFormats a number.
    currencyFormats a currency value.
    percentageFormats a percentage.
    compactFormats a number in compact form.
    dateFormats a date.
    relativeTimeFormats relative time.
    unitsFormats a value with units.
    IntlThe standard Intl object.