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

@xnsk/i18n

v0.0.38

Published

先农数科-多语言插件

Downloads

43

Readme

先农数科多语言插件

基于 vue-i18n

安装

npm i @xnsk/i18n

使用

  1. 添加 webpack 插件
const XnskI18nPlugin = require('@xnsk/i18n')
...
plugins: [
  new XnskI18nPlugin({
    language: ['zh-CN', 'en-US'],
  }),
],
...

完整参数:

new XnskI18nPlugin({
  language: ['zh-CN', 'en-US'],
  outputDir: "public/lang",// 自定义存放目录
  groupCode: "",// 数据组code
  strict: false,// 是否开启严格模式,默认false。开启严格模式后,当页面中的编码在平台未配置或配置未发布时,将终止项目构建
}),
  1. 入口文件:
import XnskI18n from '@xnsk/i18n'
import zhCN from '../public/xnskI18nLanguageFiles/zh-CN'
import enUS from '../public/xnskI18nLanguageFiles/en-US'
let i18n = new XnskI18n({
  language: ['zh-CN', 'en-US'],
  message: {
    'zh-CN': zhCN,
    'en-US': enUS,
  },
})

** 翻译文本中有变量时,变量名固定为 code,code1,code2……。如: "最多上传{code}张图片"。"您选择了{code}件商品,共${code1}元,请在{code2}分钟内支付"。

返回实例为VueI18n实例,具有原实例方法和属性,如切换语言

i18n.locale = 'en_EN';

pc 端双语

添加了两个方法

$ot:获取所有语种翻译结果,Object 格式 如:$ot('Samplingperson'),返回:{ "zh-CN": "采样人", "ti-CN": "མ་དཔེ་འཚོལ་མཁན་།" }

$at:获取所有语种翻译结果,Array 格式,顺序为初始化 XnskI18n 参数 language 数组顺序 如:$ot('Samplingperson'),返回:[ "采样人", "མ་དཔེ་འཚོལ་མཁན་།" ]

由于远程文件有跨域,如需本地调试需要添加代理:

devServer: {
    ...
    proxy: {
     ...
      '/xnskI18n': {
        target: 'https://xnsk-base.obs.cn-north-4.myhuaweicloud.com',
        changeOrigin: true,
        pathRewrite: { '^/xnskI18n': '' },
      },
    },
  },