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

    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 the structure of a dictionary.
    DeclarationContent(Deprecated) Use Dictionary<T> instead.
    IntlayerConfigThe type defining the Intlayer configuration.
    ContentNodeA node in 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 / getTranslationFunctionPicks content based on the current locale.translation
    enu / getEnumerationFunctionPicks 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 look like dictionaries (key, content). It processes t() translations, enumerations, etc.getDictionary
    getDictionaryAsyncFunctionLoads a single locale chunk of a dictionary from a per-locale loader map, then processes it.getDictionaryAsync
    getIntlayerFunctionBased on getDictionary, but injects an optimized version of the dictionary from the generated declaration.getIntlayer
    getIntlayerAsyncFunctionAsync counterpart of getIntlayer, loading only the requested locale. For metadata, loaders, server functions.getIntlayerAsync

    Localization Utilities

    Import:

    tsx
    import "intlayer";
    
    FunctionTypeDescriptionRelated Doc
    getLocaleFunctionDetects the locale from a string or path.getLocale
    getLocaleLangFunctionGets the language part of a locale.getLocaleLang
    getLocaleNameFunctionGets the display name of a locale.getLocaleName
    getLocalizedPathFunctionResolves a canonical path to localized.getLocalizedPath
    getCanonicalPathFunctionResolves a localized path to canonical.getCanonicalPath
    getLocalizedUrlFunctionGenerates a localized URL.getLocalizedUrl
    getMultilingualUrlsFunctionGenerates URLs for all supported locales.getMultilingualUrls
    getPathWithoutLocaleFunctionRemoves the locale prefix from a path.getPathWithoutLocale
    getPrefixFunctionGets the locale prefix from a path.getPrefix
    comparePathsFunctionCompares two paths ignoring the locale.comparePaths
    normalizePathFunctionNormalizes a path to a locale-agnostic one.comparePaths
    getHTMLTextDirFunctionGets 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.