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 a path.

    Usage

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

    Parameters

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

    Returns

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