
Research
/Security News
Weaponizing Discord for Command and Control Across npm, PyPI, and RubyGems.org
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
@picgo/i18n
Advanced tools
i18n 工具
i18n 默认提供 FileSyncAdapter、ObjectAdapter 两个适配器,适用的场景分别为:
安装
npm install @picgo/i18n -S
使用
import { I18n, FileSyncAdapter, ObjectAdapter } from '@picgo/i18n';
// use FileSyncAdapter
const fileSyncAdapter = new FileSyncAdapter({
localesBaseDir: path.resolve(__dirname, './locales'), // locales文件目录
});
const i18n = new I18n({
adapter: fileSyncAdapter,
defaultLanguage: 'zh',
});
// use ObjectAdapter
const objectAdapter = new ObjectAdapter({
zh: {
user: {
name: 'PicGo',
country: '中国',
},
report: {
singular: ' ${cnt}个报告',
plural: '${cnt}个报告',
},
},
en: {
user: {
name: 'PicGo',
country: 'China',
},
report: {
singular: 'only ${cnt} report',
plural: '${cnt} reports',
},
},
});
const i18n = new I18n({
adapter: objectAdapter,
defaultLanguage: 'zh',
});
引入
<script src="https://cdn.jsdelivr.net/npm/@picgo/i18n/dist/i18n_umd.js"></script>
使用
const { ObjectAdapter, I18n } = PicGo_I18n;
// use ObjectAdapter
const objectAdapter = new ObjectAdapter({
zh: {
user: {
name: 'PicGo',
country: '中国',
},
report: {
singular: ' ${cnt}个报告',
plural: '${cnt}个报告',
},
},
en: {
user: {
name: 'PicGo',
country: 'China',
},
report: {
singular: 'only ${cnt} report',
plural: '${cnt} reports',
},
},
});
const i18n = new I18n({
adapter: objectAdapter,
defaultLanguage: 'zh',
});
import { BaseAdapter } from 'i18n';
class CustomAdapter extends BaseAdapter {
getLocale(language) {}
}
构造函数 I18n
{
"adater": BaseAdapter, // 适配器
"defaultLanguage": string // 默认语言
}
i18n.setLanguage
i18n.getLauguage
i18n.translate
// en.json
{
"report": {
"singular": "only ${cnt} report",
"plural": "${cnt} reports"
}
}
i18n.translate('report.singular', { cnt: 1 }); // only 1 report
构造函数 FileSyncAdapter
{
"localesBaseDir": string, // locales 文件所在路径,绝对路径
"localeFileName": { "language": 对应的locales文件名 } // localeFileName存储语言类型到locales文件的映射,该项可选,当不传入时,将自动扫描localesBaseDir目录下文件,并将各个locale文件名作为该文件对应的语言
}
fileSyncAdapter.getLocale
构造函数 ObjectAdapter
{
"zh": {
"user": {
"name": "PicGo",
"country": "China"
},
"report": {
"singular": " ${cnt}个报告",
"plural": "${cnt}个报告"
}
},
"en": {
"user": {
"name": "PicGo",
"country": "China"
},
"report": {
"singular": "only ${cnt} report",
"plural": "${cnt} reports"
}
}
}
objectAdapter.getLocale
objectAdapter.setLocales 用于动态修改 objectAdapter 上的 locales 数据
objectAdapter.setLocales({
zh: {
newData: 'this is new Data',
},
});
Copyright (c) 2020 PicGo Group
FAQs
i18n tool
The npm package @picgo/i18n receives a total of 836 weekly downloads. As such, @picgo/i18n popularity was classified as not popular.
We found that @picgo/i18n demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
Security News
Socket now integrates with Bun 1.3’s Security Scanner API to block risky packages at install time and enforce your organization’s policies in local dev and CI.
Research
The Socket Threat Research Team is tracking weekly intrusions into the npm registry that follow a repeatable adversarial playbook used by North Korean state-sponsored actors.