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

@lx-frontend/babel-plugin-auto-i18n

v1.0.8

Published

babel plugin for auto i18n

Downloads

1

Readme

babel-plugin-auto-i18n

配置项及使用方式

插件目前有以下配置项:

| 配置项 | 说明 | 类型 | 是否必填 | 默认值 | | --- | --- | --- | --- | --- | | i18nUrl | i18N的入口文件路径 | string | 必填 | '' | | configUrl | 语言配置文件的路径,基准路径为当前项目根目录 | string | 必填 | '' | | mode | 0: 黑名单模式,文件头带/i18n-disable/关闭自动国际化处理1: 白名单模式,文件头带/i18n-enable/才开启自动国际化处理 | int | 非必填 | 0 | | enableLog | 是否开启日志输出(日志文件名为auto-i18N.log) | boolean | 非必填 | true |

使用举例

安装

:::info npm -i babel-plugin-lx-auto-i18n -D :::

配置

babel.config.json配置如下,其他类型的babel配置文件类似

module.exports = {
  presets: [
    xxx
  ],
  plugins: [
    [
      '@lx-frontend/auto-i18n', {
        'i18nUrl': 'src/config/i18n/index.js',
        'configUrl': './template/i18n/lang/cn.js',
        'mode': 1
      }
    ]
  ]
}

以下使用场景均支持自动i18n转换

function App() {
  const title = '立新车市';
  const desc = `立新二手车`;
  // 这是一段注释
  const desc2 = /*i18n-disable*/`温馨提示`;
  const desc3 = `预计${title}月${desc}日${desc2}分结束`;
  const desc4 = `更新报价${1+1}发卡设计费`;

  return (
    <div
      className="app"
      title={"立新车市"}
      color="立新二手车"
      desc={`预计${title}月${desc}日${desc2}分结束`}
      desc4={`更新报价${1 + 1}发卡设计费`}
    >
      <img src={Logo} />
      <h1>{`预计${title}月${desc}日${desc2}分结束`}</h1>
      <p>立新二手车 {desc}</p>
      <p>立新二手车</p>
      <div>
        {
            /*i18n-disable*/'中文'
        }
      </div>
    </div>
  );
}

注意事项

  1. 在写中文时,请确保本地国际化配置文件中有对应的kv配置。
  2. 模板字符串支持分段国际化,比如更新报价${desc}发卡设计费,'更新报价{0}发卡设计费'在配置文件中无对应kv,但是'更新报价'在配置文件中有对应kv,则会对'更新报价'单独做国际化处理。
  3. 若想单独对某个字符串禁用自动国际化,则在该字符串前面添加/i18n-disable/即可。比如/i18n-disable/'中文'。

后续计划

后续有如下计划

:::info

  • 国际化配置文件的自动维护机制 :::