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

extract-character-cli

v0.2.3-bate

Published

一个小型文本抽取工具,用于跟踪代码中的字符变量,并替换成相应的调用方法,来实现多语化。抽取完成后需要使用 `extract-character-lang-utils` 在项目中完成多语部署。 ## Usage ### 安装 ```sh npm install extract-character-cli -g ``` 或工程中安装

Downloads

3

Readme

extract-character-cli

一个小型文本抽取工具,用于跟踪代码中的字符变量,并替换成相应的调用方法,来实现多语化。抽取完成后需要使用 extract-character-lang-utils 在项目中完成多语部署。

Usage

安装

    npm install extract-character-cli -g

或工程中安装

    npm install extract-character-cli -D

使用

工程根目录增加配置文件extract.config.js

module.exports = {
    "source": "./src", //源码路径,可配置多个单独路径
    //或者
    "source": ["./src", ".utils"], 
    "sourceOutput": "./back",//修改后的代码导出路径,若设置为 "" 则默认修改源码,若配置为 false 则不会导出修改后的代码,只会导出多语文件
    "output": "./lang", // 多语文件导出路径
    "fileName": "lang.json", // 多语文件名称
    "local": "./local"//本地多语文件,会根据字符内容匹配代码中的字符,若本地多语文件中已存在该字符则会直接使用该文件中的id
}

生成多语

    ech --config ./extract.config.js

若工程局部安装则需要先配置 scripts 命令

{
  //package.json
  ...
  "scripts": {
    "ech": "ech --config extract.config.js",
  },
  ...
}

然后工程目录中使用 npm 启动命令

npm run ech

回滚

在0.2.0版本中增加了回滚机制主要用于回滚错乱的抽取代码。使用方式和提取过程一样使用extract.config.js配置文件,参数含义相同。

  ech --rollback extract.config.js

回滚会将原替换的echlang调用过程替换为原来的字符,便于重新提取。

Others

构建产物

├── lang 
    ├── lang-local.info # 抽取的多语信息记录,主要记录抽取位置、id以及统计等
    └── lang.json       # 抽取的多语文件,由 id 和 defaultMessage 组成
//lang-local.info
{
  "添加成功": {
    "id": "js.lang.massage.2", 
    "defaultMessage": "添加成功",
    "items": [ //被抽取的文件汇总和关键代码行
      {
        "filePath": "/src/model.js",
        "line": 155
      }
    ]
}
...
//lang.json
{
  "js.lang.massage.1": "添加成功",
  "js.lang.massage.2": "修改成功",
  ...
}

部署使用

详情查看