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

    vue-intlayer 包

    vue-intlayer 包提供将 Intlayer 集成到 Vue 应用的必要工具。它包含一个 Vue 插件和用于处理多语言内容的 composables(组合式函数)。

    安装

    bash
    npm install vue-intlayer
    

    导出

    插件

    导入:

    tsx
    import "vue-intlayer";
    
    函数说明
    installIntlayer在你的应用中安装 Intlayer 的 Vue 插件。

    组合式函数 (Composables)

    导入:

    tsx
    import "vue-intlayer";
    
    组合函数说明相关文档
    useIntlayer基于 useDictionary,但注入来自生成声明的经过优化的字典版本。-
    useDictionary处理类似字典的对象(key、content)。它会处理 t() 翻译、枚举等。-
    useDictionaryAsyncuseDictionary 相同,但处理异步字典。-
    useDictionaryDynamicuseDictionary 相同,但处理动态字典。-
    useLocale返回当前 locale 以及用于设置它的函数。-
    usePathname返回当前路径名(pathname)作为 ComputedRef<string>,并已移除 locale 片段。对 popstate 具有响应式。usePathname
    useRewriteURL客户端 composable,用于管理 URL 重写。如果存在本地化的重写规则,会自动更新 URL。useRewriteURL
    useIntl返回当前 locale 的 Intl 对象。-
    useLoadDynamic用于加载动态字典的 composable。-

    函数

    导入:

    tsx
    import "vue-intlayer";
    
    函数描述
    getDictionary处理类似字典的对象(key,content)。它会处理 t() 翻译、枚举等。
    getIntlayer基于 getDictionary,但会注入来自生成声明的字典的优化版本。

    Markdown

    导入:

    tsx
    import "vue-intlayer/markdown";
    
    函数描述
    installIntlayerMarkdownVue 插件,用于在你的应用中安装 Intlayer Markdown。