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

@i18next-plugin/vue

v1.0.3

Published

@i18next-plugin/vue plugin for extracting i18n keys/value from Vue SFC files

Readme

@i18next-plugin/vue

npm 版本 许可证 Vue 2.6+ Vue 3.x

English | 中文

i18next-cli 插件,用于从 Vue 单文件组件 (SFC) 中提取 i18n 翻译键。

特性

  • 完整 Vue 支持: 支持 Vue 2.6+ 和 Vue 3.x
  • 双模式解析: 自动处理 <script><template> 中的翻译调用
  • 多种语法: 支持 t() 函数、data-i18n 属性、动态绑定等
  • TypeScript 支持: 完整的类型定义
  • 高度可配置: 自定义函数名、属性名、文件模式等

安装

npm install @i18next-plugin/vue --save-dev

使用方法

基本配置

// i18next.config.js
import { defineConfig } from 'i18next-cli';
import i18nextVuePlugin from '@i18next-plugin/vue';

export default defineConfig({
	locales: ['en', 'zh', 'fr'],
	extract: {
		input: 'src/**/*.{vue,ts}',
		output: 'locales/{{language}}.json',
		defaultNS: 'translation',
	},
	plugins: [i18nextVuePlugin()],
});

完整配置

// i18next.config.js
import { defineConfig } from 'i18next-cli';
import i18nextVuePlugin from '@i18next-plugin/vue';

export default defineConfig({
	locales: ['en', 'zh'],
	extract: {
		input: 'src/**/*.{vue,ts,js}',
		output: 'locales/{{language}}/{{ns}}.json',
		defaultNS: 'common',
	},
	plugins: [
		i18nextVuePlugin({
			// 显式指定 Vue 版本 (2 | 3)
			vueVersion: 3,

			// 是否解析动态绑定属性 (`:attr`, `v-bind:attr`)
			vueBindAttr: true,

			// 翻译函数名列表
			functions: ['t', '$t'],

			// 命名空间函数名列表
			namespaceFunctions: ['useTranslation', 'withTranslation'],

			// HTML 属性名
			attr: 'data-i18n',

			// 选项属性名
			optionAttr: 'data-i18n-options',

			// 匹配的文件模式
			filePatterns: ['.vue', '.nvue'],
		}),
	],
});

支持的语法

模板语法

<template>
	<!-- data-i18n 属性 -->
	<h1 data-i18n="welcome.title">Welcome</h1>

	<!-- 多个键 (分号分隔) -->
	<p data-i18n="greeting;welcome.message"></p>

	<!-- 动态绑定 :attr -->
	<button :aria-label="t('button.submit')">Submit</button>

	<!-- v-bind:attr -->
	<input v-bind:placeholder="t('input.placeholder')" />

	<!-- v-on:click -->
	<button @click="t('button.click')">Click</button>
</template>

脚本语法

<script>
import { useTranslation } from 'vue-i18next';

export default {
	setup() {
		const { t } = useTranslation('namespace');

		return {
			// 简单键
			title: t('welcome.message'),

			// 带默认值
			greeting: t('greeting', 'Hello World'),

			// 带命名空间前缀
			namespaced: t('shared:key'),
		};
	},
};
</script>

API

选项

| 选项 | 类型 | 默认值 | 说明 | | -------------------- | --------------------------------- | --------------------------------------- | ---------------- | | vueVersion | 2 | 3 | undefined | undefined | 指定 Vue 版本 | | vueBindAttr | boolean | true | 是否解析动态绑定 | | functions | string[] | ['t', '$t'] | 翻译函数名 | | namespaceFunctions | string[] | ['useTranslation', 'withTranslation'] | 命名空间函数 | | attr | string | 'data-i18n' | i18n 属性名 | | optionAttr | string | 'data-i18n-options' | 选项属性名 | | filePatterns | string[] | ['.vue', '.nvue'] | 文件匹配模式 |

开发

安装依赖

npm install

构建

npm run build

测试

npm run test        # watch 模式
npm run test:run    # 单次运行
npm run test:coverage # 覆盖率报告

代码格式化

npm run format      # 格式化代码
npm run format:check # 检查格式化

许可证

MIT License