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 🙏

© 2024 – Pkg Stats / Ryan Hefner

xt-i18n

v0.0.9

Published

## Install

Downloads

444

Readme

xt-i18n

Install

使用 npm:

npm install --save-dev xt-i18n

or using yarn:

yarn add xt-i18n --dev

Use

需要转换的文件路径 输出的文件路径是必填的

  1. 在根目录下新建配置文件 i18n-ast.config.js
module.exports = () => ({
  entry: "需要转换的文件路径", // 必填
  output: "输出的文件路径", // 必填
   //排除的文件(类型是数组) 
  exclude: [], // 必填
  
  locales: 'zh_CN,pt_PT,en_US',// 必填
  // 输出和解析的excel 名称
  excelName: 'collect.xlsx',// 必填
  
  // 是否要开启自动翻译  // 可选
  // autoTranslate: {
  //   enable: true,
  //   name: "BaiduTranslate",
  //   i18nMapping: {
  //     'zh_CN': 'zh',
  //     'zh_HK': 'cht',
  //     'en_US': 'en',
  //   },
  // }

  //可以自定义随机字符串,第一个参数是翻译的文字, 不写的话默认是 hashId_pingying
  // randomFuc: (text) => `${filePath.split('/').pop()}-${Math.random()}`,
  
  // 解析excel的配置项(可选)
  // unpack: {
  //   excelName: 'collect.xlsx', // 如果这里指定了名字 则用这里的,否则用外面的excelName
  //   entry: "./u", // 解析的excel 的入口, 不写默认是外面配置项的output
  //   output: "./u", // 可选, 不写的话默认外面配置项的output,会覆盖原来的翻译文件
  // },
})
  1. 在package.json 中添加命令
  • 执行翻译命令
  xt-i18n --scan (简写-s)编译+写文件
  xt-i18n --packExcel (简写 -p)将翻译文件 转excel
  xt-i18n --unpackExcel (简写 -u)将最新的excel 反编译成 翻译文件

Todo List

  • [ ] 替换情况
    • js
      • [x] 对象中的中文字符串
      • [x] 方法中的中文传参
      • [x] 模板字符串(包含简单变量)
    • react
      • [x] react中的中文属性
      • [x] react中的中文内容
  • [x] excel
    • [x] 翻译词条文件转换为 excel
    • [x] excel 转换为翻译文件
  • [ ] 需替换情况收集
  • [ ] 判断是否引入模块,没有则自动引入
  • [ ] 替换方法可自定义
  • [x] 引入自动翻译,翻译简单词条(baidu翻译)
  • [ ] 替换后文件格式化(babel-generator还原的代码格式有很大的问题,由此引入 prettier 对生成的代码进行格式化)