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

sultana-inter

v1.0.10

Published

An auto-i18n tool, based on kiwi + google translate cn

Downloads

27

Readme

[-_@] sultana-inter

中文 | English

NPM

NPM version Downloads

🌎 自动国际化项目代码,基于kiwi+google国内翻译

😃 如何使用?

  1. 安装
npm install sultana-inter
  1. 在项目跟目录创建配置文件i18n.json,详细配置如下:
{
  "include": ["src/**/*.(ts*|js*)"],
  "exclude": ["**/i18n/**","**/test/*","**/*.test.*"],
  "importPath":"./src/i18n/language",
  "importFormat": {
    "ts":"import {i18n_lang_package,i18n_lang_format} from \"{{importPath}}\";",
    "js":"const {i18n_lang_package,i18n_lang_format} = reuqire(\"{{importPath}}\");",
    "html":"<script src=\"{{importPath}}/index.js\"></script>"
  },
  "translate":{
    "from":"zh",
    "to":"en"
  },
  "templateFunction":"i18n_lang_format",
  "templateObj":"i18n_lang_package",
  "exportPath": "./src/i18n/{{lang}}/{{filename}}.js",
  "ignoreComments": "@i18n-ignore",
  "excludeDirName":["components","pages","constants","containers","models","services","src"],
  "defaultDirName":"common"
}
  1. 执行翻译命令
su-inter -p /path/to/your/project/

📝 配置说明

  • include string[]

    包含的文件夹匹配符,符合micromatch语法。

    ["src/**/*.(ts*|js*)"]

  • exclude string[]

    排除的文件夹匹配符,符合micromatch语法。

    ["**/i18n/**","**/test/*"]

  • importPath string

    在代码中引用的路径或文件

    "./src/i18n/language"

  • importFormat

    • ts string *.ts*的文件引入模板,使用{{importPath}}作为配置项importPath的模板变量。

      "import {i18n_lang_package,i18n_lang_format} from \"{{importPath}}\";"

    • js string``*.js*文件的

      "const {i18n_lang_package,i18n_lang_format} = reuqire(\"{{importPath}}\");"

    • html string *.html文件的

      "<script src=\"{{importPath}}/index.js\"></script>"

  • translate

    • from string 翻译配置项,原语言。所有的语种格式都以谷歌翻译支持的语种为准。例 zh
    • to string 翻译配置项,翻译目标语言。要求同上。例 en
  • templateFunction string

    用作格式化的函数名,如配置"I18N.format" 将被编译成I18N.format(I18N.lang.xxx,{val1:xxx,val2:xxx}})

  • templateObj string

    使用时的语言包的变量名,如配置"I18N.lang" 将被编译成I18N.lang.xxx

  • exportPath string

    输出的语言目录,使用{{lang}}{{filename}}作为语言文件夹名和文件名。

    "./src/i18n/{{lang}}/{{filename}}.js"

  • ignoreComments string

    注释忽略标志,当配置"@i18n-ignore"时,遇到如下情况会忽略翻译:

    // @i18n-ignore
    const title="我和我的祖国"
  • excludeDirName string[]

    该工具使用文件夹名做exportPath的{{filename}}。配置该项可以在递归寻找文件夹时忽略配置的文本。

    ["components","models","services","src"]

  • defaultDirName string

    当没有合适的文件夹名做{{filename}}时,用该配置项代替。

    common

已知问题

&nbsp;会导致google翻译接口报错

💡 TODO

  • [ ] ignoreComments
  • [ ] importFomat html header