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

vue-kilang

v1.0.0

Published

vue-kilang是一款以中文为第一语言的国际化插件,基于vue-i18n二次开发。对比vue-i18n,翻译操作更简洁,只需要导入挂载插件,并按下方教程编写,即可翻译

Downloads

2

Readme

说明

vue-kilang是一款以中文为第一语言的国际化插件,基于vue-i18n二次开发。对比vue-i18n,翻译操作更简洁,只需要导入挂载插件,并按下方教程编写,即可翻译。


支持框架

  • vue2.0
  • vue3.0

安装

  1. 先安装vue-i18n依赖
# npm方式安装
vue2: npm install vue-i18n@6 -s (vue-i18n该版本支持vue2,否则引入会报错)
vue3: npm install vue-i18n -s
  1. 安装vue-kilang
# npm方式安装
vue2: npm i vue-kilang
vue3: npm i vue3-kilang

快速上手

vue2:

main.js`引入vue-kilang库

// main.js
import Vue from 'vue'
import App from './App.vue'

import {kilang, i18n} from 'vue-kilang'; //引入vue-kilang
let data = {
  厉害: ['lihai', '厉害繁体'],
  游戏: ['youxi', '游戏繁体'],
  编程: ['biancheng', '编程繁体'],
  新闻: ['xin', '新闻繁体']
}
let lang = ['EN', 'ZNT']

Vue.use(kilang,{data,config:lang})

new Vue({
  i18n,   // 注入,不能缺少
  render: h => h(App),
}).$mount('#app')

vue3:

main.js`引入vue3-kilang库

// main.js
import { createApp } from 'vue'
import App from './App.vue'

import kilang from 'vue3-kilang'; //引入vue3-kilang
const  app= createApp(App)

let data = {
    厉害: ['lihai', '厉害繁体'],
    游戏: ['youxi', '游戏繁体'],
    编程: ['biancheng', '编程繁体'],
    新闻: ['xin', '新闻繁体']
}
// 无需配置中文,默认返回中文(标识ZN)  (需要与翻译的数据的value值语言对应的翻译index一致) 
let lang = ['EN', 'ZNT']

//data数据中的属性值必须是Array。data属性值数组的index = lang自定义语言配置项的数组index 

app.use(kilang,{data:data,config:lang})

vue使用use挂载插件时,需传入一个对象配置。 参数如上main实例: data是要传入的中文翻译及数据结构、config是传入需要配置的自定义 语言标识。



组件使用方法

vue2:

<template>
 <div id="app">
 <ul>
   <li>{{ $t("电影") }}</li>
   <li>{{ $t('新闻')}}</li>
   <li>{{ $t('热点')}}</li>
 </ul>
   <button @click="setLang('ZN')">切换中文</button>
   <button @click="setLang('EN')">切换英文</button>
 </div>
</template>

<script>

export default {
 methods:{
   setLang(type){
     this.$i18n.locale = type; //切换语言
   },
 },
}
</script>

vue3:

<script setup lang="ts">

import { getCurrentInstance } from "vue";
const { proxy } = getCurrentInstance();

//setLang设置语言(调用后会重新刷新渲染网页)
//getLang查看当前语言
const zhLang = (type:string)=>{
  proxy.$setLang(type) 
  proxy.$getLang()
}

</script>

<template>
  <ul>
    <li>{{ $t("电影") }}</li>
    <li>{{ $t('新闻')}}</li>
    <li>{{ $t('热点')}}</li>
  </ul>
  <div>
    <button @click="setLang('ZN')">切换英文</button>
    <button @click="setLang('EN')">切换中文</button>
  </div>
</template>

联系

·有其他问题或建议,作者邮箱:[email protected]