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

    getLocale 函数文档

    getLocale 函数允许你从给定的字符串(例如 URL 或路径)中检测 locale。

    用法

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

    参数

    | --------- | -------- | ---------------------------------------------- |

    path string 要从中提取 locale 的路径或字符串。
    path string 用于从中提取区域设置的路径或字符串。

    返回值

    检测到的区域设置;如果未检测到任何区域设置,则返回默认区域设置。