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

cyou-i18n

v1.1.5

Published

cyou tool form matriks2 project

Downloads

19

Readme

cyou-i18n

matriks2 seed 工程的国际化小工具

##Introduction 就目前国际化方案, 我们的国际化工作流程有两个步骤:

###1. 提取字符串 从 *.js(代码源文件) 提取到 /extra/i18n/zh-CN/x.js(翻译资源文件)

####From

	let configs = {
		title: '百度一下,你就知道'
	}

####To

/* eslint-disable */
var lang = {
    '百度一下,你就知道': '百度一下,你就知道',
    '百度两下,你就知道': '百度两下,你就知道',
    '百度三下,你就知道': '百度三下,你就知道',
    ...
};
lang;

###2. 字符串 key 重命名 翻译资源文件 中的字符串键值对的 key, 必须按照 前端国际化字符串命名规范 全部重命名

####To

/* eslint-disable */
var lang = {
	// good
    'xPage_title_baidu_one': '百度一下,你就知道',
    // good
    'yPage_title_baidu_two': '百度两下,你就知道',
    // bad
    'BaiDu.标题1': '百度三下,你就知道',
    ...
};
lang;

并且使用 _i(key) 替换 代码源文件 中的字符串 ####To

	let configs = {
		title: _i('xPage_title_baidu_one')
	}

##Installation npm install -g cyou-i18n

##Usage

  1. 使用 cyou-i18n-step-one 命令处理某个路径,生成中间文件
  2. 手动修改中间文件
  3. 使用 cyou-i18n-step-two 命令修改代码源文件并生成翻译资源文件

step one

重要!!! step one 仅仅做提取字符串的工作, 不会&修改代码源文件

$ cyou-i18n-step-one ./target/src/frontend/Home/IndexPage/

会在路径 ./target/src/frontend/Home/IndexPage/ 中生成一个中间文件 *./target/src/frontend/Home/IndexPage/*CyouI18n_middle_result.json

{
  // 文件路径
  "/Users/zhangtingcen/myproject/NpmProject/CyouI18n/testing/Home/IndexPage/index.js":[
    {
    	 // 默认生成的 key (perfix + 文件路径后4层级 + 字符串序列)
        "defaultKey": "cyou_i18n_testing_home_indexpage_index.js_1",
        // 请输入符合命名规范的 key
        "targetKey": "",
        // 提取出来的字符串, 用于检查是否提取正确
        "chineseString": "校招三方",
        // 字符串所在行信息, 用于检查是否提取正确
        "lineInfo": {
            // 行号
            "lineNumber": 74,
            // 行
            "line": "                title: type === 'TP' ? '校招三方' : 'Offer拒绝',",
            // 替换后的模样
            "newLine": "                title: type === 'TP' ? _i('cyou_i18n_testing_home_indexpage_index.js_1') : _i('cyou_i18n_testing_home_indexpage_index.js_2'),"
        }
    },
    {
        "defaultKey": "cyou_i18n_testing_home_indexpage_index.js_2",
        "targetKey": "",
        "chineseString": "Offer拒绝",
        "lineInfo": {
            "lineNumber": 74,
            "line": "                title: type === 'TP' ? '校招三方' : 'Offer拒绝',",
            "newLine": "                title: type === 'TP' ? _i('cyou_i18n_testing_home_indexpage_index.js_1') : _i('cyou_i18n_testing_home_indexpage_index.js_2'),"
        }
    }
],

step two

重要!!! step two 会修改代码源文件, 请确保当前代码已提交, 且代码环境是干净的

$ cyou-i18n-step-two ./target/src/frontend/Home/IndexPage/

找到该目录下的中间文件 *./target/src/frontend/Home/IndexPage/*CyouI18n_middle_result.json, 并直接修改源文件

再该目录生成翻译资源文件 *./target/src/frontend/Home/IndexPage/*CyouI18n_result.js