New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@kotori-bot/i18n

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@kotori-bot/i18n - npm Package Compare versions

Comparing version 1.3.0 to 1.3.1

174

dist/common.js

@@ -0,77 +1,107 @@

/**
* @Package @kotori-bot/i18n
* @Version 1.3.1
* @Author Hotaru <biyuehuya@gmail.com>
* @Copyright 2024 Hotaru. All rights reserved.
* @License GPL-3.0
* @Link https://github.com/kotorijs/kotori
* @Date 2024/6/7 11:22:21
*/
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.I18n = void 0;
const const_1 = require("./const");
const locale_1 = __importDefault(require("./types/locale"));
__exportStar(require("./types/locale"), exports);
__exportStar(require("./const"), exports);
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var common_exports = {};
__export(common_exports, {
I18n: () => I18n,
default: () => common_default
});
module.exports = __toCommonJS(common_exports);
var import_const = require("./const");
var import_locale = __toESM(require("./types/locale"));
__reExport(common_exports, require("./types/locale"), module.exports);
__reExport(common_exports, require("./const"), module.exports);
class I18n {
localesData = new Map();
lang;
supports;
constructor(config = { lang: const_1.DEFAULT_LANG }) {
this.supports = config.supports ?? const_1.DEFAULT_SUPPORTS;
this.lang = config.lang;
this.supports.forEach((locale) => this.localesData.set(locale, new Map()));
}
use(locales, lang = this.lang) {
Object.keys(locales).forEach((locale) => {
this.localesData.get(lang).set(locale, locales[locale]);
});
}
locale(locale, lang = this.lang) {
return this.localesData.get(lang)?.get(locale) ?? this.localesData.get('common')?.get(locale) ?? locale;
}
set(lang) {
this.lang = lang;
}
get() {
return this.lang;
}
extends(lang) {
const sonInstance = Object.create(this);
if (lang)
sonInstance.set(lang);
return sonInstance;
}
date(date = new Date(), style = undefined, lang = this.lang) {
return new Intl.DateTimeFormat(locale_1.default[lang], { timeStyle: style }).format(date);
}
time(time = new Date(), style = undefined, lang = this.lang) {
return new Intl.DateTimeFormat(locale_1.default[lang], { timeStyle: style }).format(time);
}
period(time = new Date(), style = undefined, lang = this.lang) {
return new Intl.DateTimeFormat(locale_1.default[lang], { dayPeriod: style }).format(time);
}
number(number, options, lang = this.lang) {
return new Intl.NumberFormat(locale_1.default[lang], options).format(number);
}
list(list, options, lang = this.lang) {
return new Intl.ListFormat(locale_1.default[lang], options).format(list);
}
rtime(value, unit, options, lang = this.lang) {
return new Intl.RelativeTimeFormat(locale_1.default[lang], options).format(value, unit);
}
segmenter(input, options, lang = this.lang) {
return new Intl.Segmenter(lang, options).segment(input);
}
localesData = /* @__PURE__ */ new Map();
lang;
supports;
constructor(config = { lang: import_const.DEFAULT_LANG }) {
this.supports = config.supports ?? import_const.DEFAULT_SUPPORTS;
this.lang = config.lang;
this.supports.forEach((locale) => this.localesData.set(locale, /* @__PURE__ */ new Map()));
}
use(locales, lang = this.lang) {
Object.keys(locales).forEach((locale) => {
this.localesData.get(lang).set(locale.toLowerCase(), locales[locale]);
});
}
locale(locale, lang = this.lang) {
return this.localesData.get(lang)?.get(locale.toLowerCase()) ?? this.localesData.get("common")?.get(locale.toLowerCase()) ?? locale;
}
set(lang) {
this.lang = lang;
}
get() {
return this.lang;
}
extends(lang) {
const sonInstance = Object.create(this);
if (lang) sonInstance.set(lang);
return sonInstance;
}
date(date = /* @__PURE__ */ new Date(), style = void 0, lang = this.lang) {
return new Intl.DateTimeFormat(import_locale.default[lang], { timeStyle: style }).format(date);
}
time(time = /* @__PURE__ */ new Date(), style = void 0, lang = this.lang) {
return new Intl.DateTimeFormat(import_locale.default[lang], { timeStyle: style }).format(time);
}
period(time = /* @__PURE__ */ new Date(), style = void 0, lang = this.lang) {
return new Intl.DateTimeFormat(import_locale.default[lang], { dayPeriod: style }).format(time);
}
number(number, options, lang = this.lang) {
return new Intl.NumberFormat(import_locale.default[lang], options).format(number);
}
list(list, options, lang = this.lang) {
return new Intl.ListFormat(import_locale.default[lang], options).format(list);
}
rtime(value, unit, options, lang = this.lang) {
return new Intl.RelativeTimeFormat(import_locale.default[lang], options).format(value, unit);
}
segmenter(input, options, lang = this.lang) {
return new Intl.Segmenter(lang, options).segment(input);
}
}
exports.I18n = I18n;
exports.default = I18n;
var common_default = I18n;
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
I18n,
...require("./types/locale"),
...require("./const")
});

@@ -0,10 +1,56 @@

/**
* @Package @kotori-bot/i18n
* @Version 1.3.1
* @Author Hotaru <biyuehuya@gmail.com>
* @Copyright 2024 Hotaru. All rights reserved.
* @License GPL-3.0
* @Link https://github.com/kotorijs/kotori
* @Date 2024/6/7 11:22:21
*/
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.DEFAULT_EXT = exports.DEFAULT_LANG = exports.DEFAULT_SUPPORTS = void 0;
const locale_1 = __importDefault(require("./types/locale"));
exports.DEFAULT_SUPPORTS = Object.keys(locale_1.default);
exports.DEFAULT_LANG = 'en_US';
exports.DEFAULT_EXT = '.json';
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var const_exports = {};
__export(const_exports, {
DEFAULT_EXT: () => DEFAULT_EXT,
DEFAULT_LANG: () => DEFAULT_LANG,
DEFAULT_SUPPORTS: () => DEFAULT_SUPPORTS
});
module.exports = __toCommonJS(const_exports);
var import_locale = __toESM(require("./types/locale"));
const DEFAULT_SUPPORTS = Object.keys(import_locale.default);
const DEFAULT_LANG = "en_US";
const DEFAULT_EXT = ".json";
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
DEFAULT_EXT,
DEFAULT_LANG,
DEFAULT_SUPPORTS
});

@@ -0,50 +1,70 @@

/**
* @Package @kotori-bot/i18n
* @Version 1.3.1
* @Author Hotaru <biyuehuya@gmail.com>
* @Copyright 2024 Hotaru. All rights reserved.
* @License GPL-3.0
* @Link https://github.com/kotorijs/kotori
* @Date 2024/6/7 11:22:21
*/
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.I18n = void 0;
const node_fs_1 = require("node:fs");
const node_path_1 = require("node:path");
const common_1 = require("./common");
const const_1 = require("./const");
__exportStar(require("./common"), exports);
class I18n extends common_1.I18n {
ext;
loader(dir) {
this.supports.forEach((lang) => {
const file = (0, node_path_1.join)(dir, `${lang}${this.ext}`);
if (!(0, node_fs_1.existsSync)(file))
return;
try {
const locales = JSON.parse((0, node_fs_1.readFileSync)(file).toString());
super.use(locales, lang);
}
catch {
JSON.stringify('');
}
});
}
constructor(config = { lang: const_1.DEFAULT_LANG }) {
super(config);
this.ext = config.ext ?? const_1.DEFAULT_EXT;
}
use(locales, lang = this.lang) {
if (typeof locales === 'string')
return this.loader(locales);
return super.use(locales, lang);
}
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var src_exports = {};
__export(src_exports, {
I18n: () => I18n,
default: () => src_default
});
module.exports = __toCommonJS(src_exports);
var import_node_fs = require("node:fs");
var import_node_path = require("node:path");
var import_common = require("./common");
var import_const = require("./const");
__reExport(src_exports, require("./common"), module.exports);
class I18n extends import_common.I18n {
ext;
loader(dir) {
this.supports.forEach((lang) => {
const file = (0, import_node_path.join)(dir, `${lang}${this.ext}`);
if (!(0, import_node_fs.existsSync)(file)) return;
try {
const locales = JSON.parse((0, import_node_fs.readFileSync)(file).toString());
super.use(locales, lang);
} catch {
JSON.stringify("");
}
});
}
constructor(config = { lang: import_const.DEFAULT_LANG }) {
super(config);
this.ext = config.ext ?? import_const.DEFAULT_EXT;
}
use(locales, lang = this.lang) {
if (typeof locales === "string") return this.loader(locales);
return super.use(locales, lang);
}
}
exports.I18n = I18n;
exports.default = I18n;
var src_default = I18n;
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
I18n,
...require("./common")
});

@@ -0,49 +1,85 @@

/**
* @Package @kotori-bot/i18n
* @Version 1.3.1
* @Author Hotaru <biyuehuya@gmail.com>
* @Copyright 2024 Hotaru. All rights reserved.
* @License GPL-3.0
* @Link https://github.com/kotorijs/kotori
* @Date 2024/6/7 11:22:21
*/
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.LocaleIdentifier = void 0;
var LocaleIdentifier;
(function (LocaleIdentifier) {
LocaleIdentifier["en_US"] = "en-US";
LocaleIdentifier["en_GB"] = "en-GB";
LocaleIdentifier["en_AU"] = "en-AU";
LocaleIdentifier["zh_CN"] = "zh-CN";
LocaleIdentifier["zh_HK"] = "zh-HK";
LocaleIdentifier["zh_TW"] = "zh-TW";
LocaleIdentifier["zh_SG"] = "zh-SG";
LocaleIdentifier["es_ES"] = "es-ES";
LocaleIdentifier["es_MX"] = "es-MX";
LocaleIdentifier["ar_EG"] = "ar-EG";
LocaleIdentifier["ar_AE"] = "ar-AE";
LocaleIdentifier["ru_RU"] = "ru-RU";
LocaleIdentifier["fr_FR"] = "fr-FR";
LocaleIdentifier["fr_CA"] = "fr-CA";
LocaleIdentifier["de_DE"] = "de-DE";
LocaleIdentifier["de_CH"] = "de-CH";
LocaleIdentifier["it_IT"] = "it-IT";
LocaleIdentifier["it_CH"] = "it-CH";
LocaleIdentifier["hi_IN"] = "hi-IN";
LocaleIdentifier["pt_BR"] = "pt-BR";
LocaleIdentifier["pt_PT"] = "pt-PT";
LocaleIdentifier["tr_TR"] = "tr-TR";
LocaleIdentifier["ja_JP"] = "ja-JP";
LocaleIdentifier["id_ID"] = "id-ID";
LocaleIdentifier["uk_UA"] = "uk-UA";
LocaleIdentifier["vi_VN"] = "vi-VN";
LocaleIdentifier["th_TH"] = "th-TH";
LocaleIdentifier["sv_SE"] = "sv-SE";
LocaleIdentifier["nb_NO"] = "nb-NO";
LocaleIdentifier["da_DK"] = "da-DK";
LocaleIdentifier["fi_FI"] = "fi-FI";
LocaleIdentifier["he_IL"] = "he-IL";
LocaleIdentifier["sk_SK"] = "sk-SK";
LocaleIdentifier["bg_BG"] = "bg-BG";
LocaleIdentifier["lt_LT"] = "lt-LT";
LocaleIdentifier["sl_SI"] = "sl-SI";
LocaleIdentifier["sr_RS"] = "sr-RS";
LocaleIdentifier["mk_MK"] = "mk-MK";
LocaleIdentifier["sq_AL"] = "sq-AL";
LocaleIdentifier["et_EE"] = "et-EE";
LocaleIdentifier["mt_MT"] = "mt-MT";
LocaleIdentifier["common"] = "COMMON";
})(LocaleIdentifier || (exports.LocaleIdentifier = LocaleIdentifier = {}));
exports.default = LocaleIdentifier;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var locale_exports = {};
__export(locale_exports, {
LocaleIdentifier: () => LocaleIdentifier,
default: () => locale_default
});
module.exports = __toCommonJS(locale_exports);
var LocaleIdentifier = /* @__PURE__ */ ((LocaleIdentifier2) => {
LocaleIdentifier2["en_US"] = "en-US";
LocaleIdentifier2["en_GB"] = "en-GB";
LocaleIdentifier2["en_AU"] = "en-AU";
LocaleIdentifier2["zh_CN"] = "zh-CN";
LocaleIdentifier2["zh_HK"] = "zh-HK";
LocaleIdentifier2["zh_TW"] = "zh-TW";
LocaleIdentifier2["zh_SG"] = "zh-SG";
LocaleIdentifier2["es_ES"] = "es-ES";
LocaleIdentifier2["es_MX"] = "es-MX";
LocaleIdentifier2["ar_EG"] = "ar-EG";
LocaleIdentifier2["ar_AE"] = "ar-AE";
LocaleIdentifier2["ru_RU"] = "ru-RU";
LocaleIdentifier2["fr_FR"] = "fr-FR";
LocaleIdentifier2["fr_CA"] = "fr-CA";
LocaleIdentifier2["de_DE"] = "de-DE";
LocaleIdentifier2["de_CH"] = "de-CH";
LocaleIdentifier2["it_IT"] = "it-IT";
LocaleIdentifier2["it_CH"] = "it-CH";
LocaleIdentifier2["hi_IN"] = "hi-IN";
LocaleIdentifier2["pt_BR"] = "pt-BR";
LocaleIdentifier2["pt_PT"] = "pt-PT";
LocaleIdentifier2["tr_TR"] = "tr-TR";
LocaleIdentifier2["ja_JP"] = "ja-JP";
LocaleIdentifier2["id_ID"] = "id-ID";
LocaleIdentifier2["uk_UA"] = "uk-UA";
LocaleIdentifier2["vi_VN"] = "vi-VN";
LocaleIdentifier2["th_TH"] = "th-TH";
LocaleIdentifier2["sv_SE"] = "sv-SE";
LocaleIdentifier2["nb_NO"] = "nb-NO";
LocaleIdentifier2["da_DK"] = "da-DK";
LocaleIdentifier2["fi_FI"] = "fi-FI";
LocaleIdentifier2["he_IL"] = "he-IL";
LocaleIdentifier2["sk_SK"] = "sk-SK";
LocaleIdentifier2["bg_BG"] = "bg-BG";
LocaleIdentifier2["lt_LT"] = "lt-LT";
LocaleIdentifier2["sl_SI"] = "sl-SI";
LocaleIdentifier2["sr_RS"] = "sr-RS";
LocaleIdentifier2["mk_MK"] = "mk-MK";
LocaleIdentifier2["sq_AL"] = "sq-AL";
LocaleIdentifier2["et_EE"] = "et-EE";
LocaleIdentifier2["mt_MT"] = "mt-MT";
LocaleIdentifier2["common"] = "COMMON";
return LocaleIdentifier2;
})(LocaleIdentifier || {});
var locale_default = LocaleIdentifier;
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
LocaleIdentifier
});
{
"name": "@kotori-bot/i18n",
"version": "1.3.0",
"version": "1.3.1",
"description": "i18n For Kotori",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc