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

@vitescv/i18n

v2.0.2

Published

i18n module for vitescv

Downloads

2

Readme

简介

vitescv的i18n多语言模块 ,基于vue-i18n@8,提供多语言解决方案, 设置中的语言包会被当做全局加载.

安装

pnpm add @vitescv/i18n

使用

#在config.js中配置,配置部分同vue-i18n
import zhLang from "./i18n/zh.json"
modules:{
  ...
  "@vitescv/i18n":{
    dir:"i18n",              // 自动加载语言包的默认目录,内部文件名则为语言包名[lang].json
    locale:'zh',             // * 默认的语言,必填,
    fallbackLocale:'zh',     // 找不到语言包的回滚语言
    silentFallbackWarn:true, // 静默回滚错误
    messages:{               // 也可以自己设定,但是改动会触发配置文件改动,dev服务会重启
      "zh":zhLang,
      ...
    }
  },
}

页面中的自定义语言包可以在页面中自行设定,vue-i18n会自动加载合并

# pages/index.vue
....
import zhLang from "./zh.json"
export default {
  ...
  i18n:{
    messages:{
      'zh':zhLang,
      ...
    }
  },
  ...
}

扩展

该模块扩展了上下文,提供Context.I18n对象可以在其他摸块中提供对语言解决方案,该对象的api如下:

  • langs

​ 当前支持的语言列表数组

  • i18n

​ vue-i18n的实例

  • setLocaleMessage(lang,importer)

​ 针对某个语言增加全局语言包或者语言包加载器,其中importer方法可以返回一个json数据,也可以返回一个promise实现异步加载

  • setLocaleMessages(importers)

setLocaleMessage的批量方法,importers为lang和importer的映射对象