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

i18n-ast-auto

v0.0.1

Published

auto i18n

Readme

i18n-ast-auto

基于 AST 的国际化解决方案、自动提取和替换国际化词典工具

功能

  • 支持 include exclude 配置按需替换
  • 支持@i18n-ignore 忽略文案
  • vue 自动引入 vue-i18n
  • vue 自动声明 t 函数 const { t } = useI18n()
  • vue 自动转化 vue 语法
  • vue 支持 setup 语法糖
  • js 自动引入国际化相关函数
  • js 自定义调用方式
  • js 自动转化 js 语法

效果

i18n scan

scan

i18n replace

replace

使用

1、在根目录放置配置文件

// i18n.config.js

module.exports = {
  output: {
    flat: true,
    localeOutput: 'playground/locales/lang',
    rootPath: 'playground',
    overlap: 'playground',
    writeMode: 'overwrite',
  },
  include: ['playground/test.vue'],
  logLevel: 5,
  // include: ['playground/**/*.{js,vue}'],
  // include: ['playground/**/*.{js,vue}'],
  exclude: ['playground/output'],
  transform: {
    keyMode: 'FILEPATH',
    locales: [],
    displayName: 'TEXT',
    import: [
      {
        importVar: 'useI18n ',
        importPath: 'vue-i18n',
        defaultExport: false,
        userVar: {
          script: 't',
          template: '$t',
        },
        useing: 'const { t } = useI18n()',
        effect: '.vue',
      },
      {
        importVar: 'i18n',
        importPath: '@/i18n',
        defaultExport: true,
        userVar: 'i18n.global.t',
        useing: 'const { t } = useI18n()',
        effect: '.js',
      },
    ],
  },
};

2、全局安装

pnpm add i18n-ast-auto -g

3、运行 i18n scan 扫描

i18n scan

4、去 .i18n/keyMap.json 修改 locale key

i18n scan 命令运行后会自动生成.i18n/keyMap.json 文件记录中文映射关系,你可以通过修改 displayName 改变替换后的 key

5、开始替换

i18n replace

运行 i18n replace 开始替换,该命令会基于 keyMap 替换相关文件,并转化语法,已经转换后的文件会记录在.i18n/skipFile.json 不会二次替换

支持

  • 目前仅支持 vue3 与 js

常见问题

需要手动修改的场景

1、vue 语法现在不支持中文出现在 props 与 defineComponent 外中

需要注意的情况,可能不符合预期

1、嵌套复杂的三元表达式可能不符合预期

2、在 js 文件中拼接字符串中出现 html 标记,当前会自动转移 html 字符