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

    getLocale function documentation

    The getLocale function allows you to detect the locale from a given string, such as a URL or path.

    Usage

    import { getLocale } from "intlayer";
    
    const locale = getLocale("/fr/about");
    
    // Output: 'fr'

    Parameters

    Parameter Type Description
    path string The path or string from which to extract the locale.

    Returns

    The detected locale, or the default locale if none is detected.