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

@dvsantd/translator

v0.9.0

Published

将文件中的中文词条分析导出到词条映射文件,并重构代码引用映射,快速将版本国际化

Downloads

3

Readme

Translator — 国际化? 仅需对表翻译,就那么简单!

一、安装

tnpm install @dvsantd/translator -g

二、配置

  • 执行translator init,在当前目录生成配置文件:translator.config.json
  • 创建模版文件夹 refs ,根据需要创建模版文件,模版内容空,比如:

|-refs/
        |-en.map
        |-jp.map
  • 修改配置文件 translator.config.json ,正确设置字段 src 、 dest 、 refs 的值

{    
        // 源码目录,必配
        "src":"" ,

        // 输出目录,必配
        "dest":"",

        // 模版目录,必配
        "refs":""
}

四、执行

translator

程序会将 src 目录下的文件处理后,输出到 dest 目录。并将扫描出来的中文串更新至模版文件

六、翻译

  • 逐句翻译模版

中文<=>english
  • 录入部分或者完整对照后,再次执行

translator

七、引用

根据当前语言环境,引用重构后的JS资源即可

八、其他


  • Grunt 任务配置
// 安装插件
tnpm install grunt-qc-translator --save
// Gruntfile 配置
module.exports = function(grunt){
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        translator: {
            console: {
                "src": "dest",
                "dest": "build",
                "refs": "refs",
                "exclude":"^\\.|node_modules|express|location.js",
                "copy":true
            }
        }
    })
    grunt.loadNpmTasks('grunt-qc-translator')
    grunt.registerTask('build', ['translator'])
}
  • 扫描代码中的中文
translator scan
  • 其他配置(有默认值)

{   
        // 包含目录,支持数组和字符串
        "includes": "",
        // 排除目录
        "exclude":"^\\.|node_modules|express",
        // 排除多个文件
        "excludes": [
            "jquery.js"
        ],
        // 仅处理指定后缀名的文件
        "resolve":".js,.php,.html,.htm,.css,.ini",    
        // 模版映射符
        "rsplit":"<=>",  
        // 变量占位符                                
        "placeholder":"(__)",
        // 忽略的字符串
        "ignore":"^\t(.+)\t$",
        // 是否COPY源码到dest目录
        "copy":true,
        // 标识词典未使用,可选
        "nousage": false
}
  • demo

      + 新建或选择一个空的目录,在目录下执行:
    
      ```bash
      translator test
    
      ```
      + 进入test目录,执行
    
      ```bash
      translator
    
      ```
    
      + 打开test/index.html,查看翻译后的页面呈现