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

meetfun-i18n-cli

v1.0.25

Published

A powerful CLI tool for automatic internationalization of Vue.js and JavaScript/TypeScript projects

Readme

MeetFun i18n CLI

A powerful CLI tool for automatic internationalization of Vue.js and JavaScript/TypeScript projects.

Features

  • 🚀 Automatic i18n conversion: Convert Chinese strings in Vue, JS and TS files to $t() format
  • 🔍 Preview mode: Analyze files without making actual changes
  • 📦 Support for multiple file types: Vue components, JavaScript and TypeScript files
  • ⚙️ Flexible configuration: Customizable options for different needs
  • 💻 Command-line interface: Easy to use in scripts or directly from the terminal
  • 📚 Programmatic API: Can be integrated into other Node.js applications
  • 🛠️ Vite plugin: Use as a Vite plugin during development

Installation

Global installation (for CLI use)

npm install -g meetfun-i18n-cli

Project installation (as a dependency)

npm install --save-dev meetfun-i18n-cli

Usage

CLI Usage

After global installation, you can use the meetfun-i18n command directly in the terminal.

Basic Commands

# Convert all files in the src directory
meetfun-i18n convert

# Convert specific directories
meetfun-i18n convert src/pages src/components

# Preview which files need conversion
meetfun-i18n preview

# Convert a single file
meetfun-i18n file src/components/Hello.vue

# Clean up backup files
meetfun-i18n clean

Options

-v, --verbose     # Output detailed log information
-b, --backup      # Backup original files
-m, --min <length> # Minimum Chinese character length to process
--dev-only        # Only run in development environment
--exclude <patterns> # Exclude file patterns, separated by commas

Project Integration

Add the following scripts to your package.json:

{
  "scripts": {
    "i18n:convert": "meetfun-i18n convert",
    "i18n:preview": "meetfun-i18n preview",
    "i18n:file": "meetfun-i18n file",
    "i18n:clean": "meetfun-i18n clean"
  }
}

Then run:

npm run i18n:convert src

Programmatic API

You can also use the library programmatically in your Node.js applications:

const { createConverter, convert, preview } = require('meetfun-i18n-cli')

// Create a converter instance with options
const converter = createConverter({
  verbose: true,
  backup: true,
  minChineseLength: 2
})

// Convert files
await converter.convertBatch(['src/pages', 'src/components'])

// Or use the shortcut functions
await convert(['src'], { verbose: true })
await preview(['src'])

Vite Plugin

You can use the tool as a Vite plugin during development:

// vite.config.js
const { createPlugin } = require('meetfun-i18n-cli')

module.exports = {
  plugins: [
    createPlugin({
      devOnly: true,
      verbose: true,
      exclude: [/node_modules/, /test/]
    })
  ]
}

How It Works

The tool scans your project files and automatically converts Chinese strings to internationalized format:

  • In Vue templates: Convert text and attributes to {{ $t('key') }} or :attr="$t('key')"
  • In script blocks: Convert string literals to $t('key') or this.$t('key')
  • Support for template strings with variables: Convert to $t('key', { variable })
  • Support for both Vue 2 Options API and Vue 3 Composition API

The conversion is based on simple text pattern matching. After conversion, you'll need to manually add the corresponding translations to your language files.

Ignore Comments

You can use special comments to prevent certain Chinese strings from being converted:

Using /*i18n-ignore*/ Comment

Place a /*i18n-ignore*/ comment before the code block you want to skip:

/*i18n-ignore*/
const message = '你好世界'
const title = "欢迎使用"

This will prevent the tool from converting these Chinese strings to $t() format.

Examples

In Vue Template:

<template>
  <div>
    <!-- Normal conversion -->
    <p>{{ text }}</p>
    
    <!--i18n-ignore-->
    <p>这段文字不会被转换</p>
  </div>
</template>

In JavaScript/TypeScript:

// Normal conversion
const greeting = '你好'

/*i18n-ignore*/
const debugMessage = '调试信息:这不会被转换'
const logMessage = '日志内容'

In Vue Script:

<script>
export default {
  data() {
    return {
      title: '这会被转换',
      /*i18n-ignore*/
      devNote: '开发备注:不转换'
    }
  }
}
</script>

Configuration Options

You can customize the behavior of the tool using these options:

  • enabled: Enable or disable the plugin (default: true)
  • verbose: Show detailed log information (default: false)
  • devOnly: Run only in development environment (default: false)
  • backup: Create backup files before modifying (default: false)
  • minChineseLength: Minimum length of Chinese strings to process (default: 2)
  • exclude: Array of regex patterns to exclude files from processing

Best Practices

  1. Always commit your code before running the conversion
  2. Use the preview mode first to see what will be changed
  3. Review the conversion results carefully
  4. Add the generated keys to your language files
  5. Test the internationalized application thoroughly

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT