npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

vite-plugin-tolgee-i18n

v0.1.15

Published

Vite plugin for Tolgee translation integration with i18n inspector devtools

Readme

vite-plugin-tolgee-i18n

中文 | English

npm version Vue Vite License

一体化的 Vue 3 + Tolgee 国际化解决方案,团队协作翻译零冲突。

⚠️ Vue 3 Only — 本插件当前仅支持 Vue 3(依赖 vue >=3.3vue-i18n >=9)。React 和 Vue 2 支持已在计划中。

安装

pnpm add vite-plugin-tolgee-i18n -D

Requires: Vue >=3.3, vue-i18n >=9, Vite >=4

快速开始

注册插件

// vite.config.ts
import { defineConfig } from 'vite';
import { tolgeePlugin } from 'vite-plugin-tolgee-i18n';
import process from 'node:process';

export default defineConfig({
    plugins: [
        tolgeePlugin({
            apiUrl: process.env.TOLGEE_API_URL,
            apiKey: process.env.TOLGEE_API_KEY,
            locales: {
                zh: 'locales/zh-CN.ts',
                en: 'locales/en.ts',
            },
            syncToCache: true,
        }),
    ],
});

syncToCache: true 将远程翻译写入 .cache/(gitignored),源文件永不修改,多人协作零冲突。

创建 i18n 实例

// main.ts
import { createApp } from 'vue';
import { createI18nWithTolgee } from 'vite-plugin-tolgee-i18n';
import { setupI18nInspector } from 'vite-plugin-tolgee-i18n/client';
import zhCN from './locales/zh-CN';
import App from './App.vue';

const app = createApp(App);

const i18n = await createI18nWithTolgee(app, {
    apiUrl: import.meta.env.VITE_APP_TOLGEE_API_URL,
    apiKey: import.meta.env.VITE_TOGGLE_SECRET,
    locale: 'zh-CN',
    messages: zhCN,
    enableRuntimeMerge: import.meta.env.DEV,
});

if (import.meta.env.DEV) {
    setupI18nInspector(app, i18n, {
        apiUrl: import.meta.env.VITE_APP_TOLGEE_API_URL,
        apiKey: import.meta.env.VITE_TOGGLE_SECRET,
        theme: 'dark',
        locale: 'zh-CN',
        localeLoader: lang => import(`./locales/${lang}.ts`).then(m => m.default),
    });
}

app.mount('#app');

切换语言

import { switchLocaleWithTolgee } from 'vite-plugin-tolgee-i18n';

async function changeLocale(locale: string) {
    const langModule = await import(`./locales/${locale}.ts`);
    await switchLocaleWithTolgee(i18n, locale, langModule.default, {
        apiUrl: import.meta.env.VITE_APP_TOLGEE_API_URL,
        apiKey: import.meta.env.VITE_TOGGLE_SECRET,
        enableRuntimeMerge: import.meta.env.DEV,
    });
}

使用流程

  1. 页面右下角点击「文」按钮进入编辑模式 点击按钮 输入toggle secret
  2. 按住 Alt 悬停文案 → 查看 i18n key 和中英文翻译 修改文案
  3. 按住 Alt 点击文案 → 弹出编辑框,修改后保存 → 即时推送到 Tolgee
  4. 刷新页面,Tolgee 新翻译自动生效

API 参考

Vite 插件

| 参数 | 类型 | 必填 | 默认值 | 说明 | | ------------- | ------------------------ | ---- | ------------------------------------------------- | ----------------------------------------- | | apiUrl | string | ✅ | - | Tolgee API 地址 | | apiKey | string | ✅ | - | Tolgee API Key | | locales | Record<string, string> | ❌ | { zh: 'locales/zh-CN.ts', en: 'locales/en.ts' } | locale 文件路径映射 | | syncToCache | boolean | ❌ | false | 启用时同步 Tolgee 到 .cache/ 并实时合并 |

客户端 API

| 导出 | 导入路径 | 说明 | | --------------------------------------------------------- | -------------------------------- | ------------------------------ | | setupI18nInspector(app, i18n, options) | vite-plugin-tolgee-i18n/client | 挂载 Inspector 开发工具 | | createI18nWithTolgee(app, options) | vite-plugin-tolgee-i18n | 创建含 Tolgee 集成的 i18n 实例 | | switchLocaleWithTolgee(i18n, locale, messages, options) | vite-plugin-tolgee-i18n | 切换语言并合并 Tolgee 翻译 | | fetchTolgeeTranslations(apiUrl, apiKey, lang) | vite-plugin-tolgee-i18n | 拉取 Tolgee 翻译 | | mergeTranslations(base, overrides) | vite-plugin-tolgee-i18n | 深度合并翻译 |

InspectorSetupOptions

| 参数 | 类型 | 必填 | 默认值 | 说明 | | -------------- | ---------------------------------------- | ---- | --------- | ------------------ | | apiUrl | string | ✅ | - | Tolgee API 地址 | | apiKey | string | ✅ | - | Tolgee API Key | | theme | 'dark' \| 'light' | ❌ | 'dark' | Inspector 主题 | | locale | 'zh-CN' \| 'en' | ❌ | 'zh-CN' | Inspector 界面语言 | | style | InspectorStyleOptions | ❌ | - | UI 样式覆盖 | | localeLoader | (lang) => Promise<Record<string, any>> | ❌ | - | 语言包加载函数 |

类型导出

import type {
    TolgeePluginOptions,
    InspectorOptions,
    InspectorStyleOptions,
    InspectorTheme,
    InspectorLocale,
    InspectorSetupOptions,
    LocaleLoader,
    CreateI18nOptions,
} from 'vite-plugin-tolgee-i18n';

环境变量

VITE_APP_TOLGEE_API_URL=https://tolgee.your-domain.com
VITE_TOGGLE_SECRET=your-project-api-key

License

MIT


GitHub: github.com/forever-chen/vite-plugin-tolgee-i18n — ⭐ Star & contribute welcome!

Issues: github.com/forever-chen/vite-plugin-tolgee-i18n/issues — Bug reports & feature requests