Gathering detailed insights and metrics for @picgo/i18n
Gathering detailed insights and metrics for @picgo/i18n
Gathering detailed insights and metrics for @picgo/i18n
Gathering detailed insights and metrics for @picgo/i18n
npm install @picgo/i18n
Typescript
Module System
Node Version
NPM Version
TypeScript (62.11%)
JavaScript (37.89%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
5 Stars
22 Commits
2 Forks
3 Watchers
5 Branches
5 Contributors
Updated on Nov 04, 2024
Latest Version
1.0.0
Package Id
@picgo/i18n@1.0.0
Unpacked Size
28.57 kB
Size
9.13 kB
File Count
32
NPM Version
8.1.2
Node Version
16.13.2
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
20
i18n 工具
i18n 默认提供 FileSyncAdapter、ObjectAdapter 两个适配器,适用的场景分别为:
安装
npm install @picgo/i18n -S
使用
1import { I18n, FileSyncAdapter, ObjectAdapter } from '@picgo/i18n';
2
3// use FileSyncAdapter
4const fileSyncAdapter = new FileSyncAdapter({
5 localesBaseDir: path.resolve(__dirname, './locales'), // locales文件目录
6});
7
8const i18n = new I18n({
9 adapter: fileSyncAdapter,
10 defaultLanguage: 'zh',
11});
12
13// use ObjectAdapter
14const objectAdapter = new ObjectAdapter({
15 zh: {
16 user: {
17 name: 'PicGo',
18 country: '中国',
19 },
20 report: {
21 singular: ' ${cnt}个报告',
22 plural: '${cnt}个报告',
23 },
24 },
25 en: {
26 user: {
27 name: 'PicGo',
28 country: 'China',
29 },
30 report: {
31 singular: 'only ${cnt} report',
32 plural: '${cnt} reports',
33 },
34 },
35});
36const i18n = new I18n({
37 adapter: objectAdapter,
38 defaultLanguage: 'zh',
39});
引入
1<script src="https://cdn.jsdelivr.net/npm/@picgo/i18n/dist/i18n_umd.js"></script>
使用
1const { ObjectAdapter, I18n } = PicGo_I18n; 2// use ObjectAdapter 3const objectAdapter = new ObjectAdapter({ 4 zh: { 5 user: { 6 name: 'PicGo', 7 country: '中国', 8 }, 9 report: { 10 singular: ' ${cnt}个报告', 11 plural: '${cnt}个报告', 12 }, 13 }, 14 en: { 15 user: { 16 name: 'PicGo', 17 country: 'China', 18 }, 19 report: { 20 singular: 'only ${cnt} report', 21 plural: '${cnt} reports', 22 }, 23 }, 24}); 25const i18n = new I18n({ 26 adapter: objectAdapter, 27 defaultLanguage: 'zh', 28});
1import { BaseAdapter } from 'i18n'; 2class CustomAdapter extends BaseAdapter { 3 getLocale(language) {} 4}
构造函数 I18n
1{ 2 "adater": BaseAdapter, // 适配器 3 "defaultLanguage": string // 默认语言 4}
i18n.setLanguage
i18n.getLauguage
i18n.translate
1// en.json 2{ 3 "report": { 4 "singular": "only ${cnt} report", 5 "plural": "${cnt} reports" 6 } 7}
1i18n.translate('report.singular', { cnt: 1 }); // only 1 report
构造函数 FileSyncAdapter
1{ 2 "localesBaseDir": string, // locales 文件所在路径,绝对路径 3 "localeFileName": { "language": 对应的locales文件名 } // localeFileName存储语言类型到locales文件的映射,该项可选,当不传入时,将自动扫描localesBaseDir目录下文件,并将各个locale文件名作为该文件对应的语言 4}
fileSyncAdapter.getLocale
构造函数 ObjectAdapter
1{ 2 "zh": { 3 "user": { 4 "name": "PicGo", 5 "country": "China" 6 }, 7 "report": { 8 "singular": " ${cnt}个报告", 9 "plural": "${cnt}个报告" 10 } 11 }, 12 "en": { 13 "user": { 14 "name": "PicGo", 15 "country": "China" 16 }, 17 "report": { 18 "singular": "only ${cnt} report", 19 "plural": "${cnt} reports" 20 } 21 } 22}
objectAdapter.getLocale
objectAdapter.setLocales 用于动态修改 objectAdapter 上的 locales 数据
1objectAdapter.setLocales({
2 zh: {
3 newData: 'this is new Data',
4 },
5});
Copyright (c) 2020 PicGo Group
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
Found 0/20 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
22 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More