Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@kotori-bot/i18n

Package Overview
Dependencies
Maintainers
1
Versions
6
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.1.2 to 1.2.0

dist/common.d.ts

35

dist/index.d.ts

@@ -1,26 +0,11 @@

export declare enum LocaleIdentifier {
ja_JP = 0,
en_US = 1,
zh_TW = 2,
zh_CN = 3
import { I18n as I18nCommon, LocaleType, localeData } from './common';
export * from './common';
export declare class I18n<T extends LocaleType = LocaleType> extends I18nCommon<T> {
private ext;
private loader;
constructor(config?: ConstructorParameters<typeof I18nCommon<T>>[0] & {
ext?: string;
});
use(locales: localeData | string, lang?: T): void;
}
export type LocaleType = keyof typeof LocaleIdentifier;
export interface localeData {
[propName: string]: string;
}
export type LocaleDataList = {
[K in LocaleType]: localeData;
};
export declare class Locale {
private readonly localeDataList;
private lang;
constructor(type?: LocaleType);
use(data: {
type: LocaleType;
locales: localeData;
}): void;
locale(val: string, type?: LocaleType): string;
set(lang: LocaleType): void;
get(): "ja_JP" | "en_US" | "zh_TW" | "zh_CN";
}
export default Locale;
export default I18n;
"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);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Locale = exports.LocaleIdentifier = void 0;
var LocaleIdentifier;
(function (LocaleIdentifier) {
LocaleIdentifier[LocaleIdentifier["ja_JP"] = 0] = "ja_JP";
LocaleIdentifier[LocaleIdentifier["en_US"] = 1] = "en_US";
LocaleIdentifier[LocaleIdentifier["zh_TW"] = 2] = "zh_TW";
LocaleIdentifier[LocaleIdentifier["zh_CN"] = 3] = "zh_CN";
})(LocaleIdentifier || (exports.LocaleIdentifier = LocaleIdentifier = {}));
class Locale {
localeDataList = {
ja_JP: {},
en_US: {},
zh_TW: {},
zh_CN: {},
};
lang;
constructor(type = 'en_US') {
this.lang = LocaleIdentifier[type];
}
use(data) {
Object.keys(this.localeDataList[data.type]).forEach(locale => {
if (!(locale in data.locales))
exports.I18n = void 0;
const fs_1 = require("fs");
const path_1 = require("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, path_1.join)(dir, `${lang}${this.ext}`);
if (!(0, fs_1.existsSync)(file))
return;
delete this.localeDataList[data.type][locale];
try {
const locales = JSON.parse((0, fs_1.readFileSync)(file).toString());
this.use(locales, lang);
}
catch {
JSON.stringify('');
}
});
this.localeDataList[data.type] = Object.assign(this.localeDataList[data.type], data.locales);
}
locale(val, type = LocaleIdentifier[this.lang]) {
if (!(type in this.localeDataList))
return val;
return val in this.localeDataList[type] ? this.localeDataList[type][val] : val;
constructor(config = { lang: const_1.DEFAULT_LANG }) {
super(config);
this.ext = config.ext ?? const_1.DEFAULT_EXT;
}
set(lang) {
this.lang = LocaleIdentifier[lang];
use(locales, lang = this.lang) {
if (typeof locales === 'string') {
this.loader(locales);
return;
}
Object.keys(locales).forEach((locale) => {
this.localesData.get(lang).set(locale, locales[locale]);
});
}
get() {
return LocaleIdentifier[this.lang];
}
}
exports.Locale = Locale;
exports.default = Locale;
exports.I18n = I18n;
exports.default = I18n;
{
"name": "@kotori-bot/i18n",
"version": "1.1.2",
"version": "v1.2.0",
"description": "i18n For Kotori",
"main": "dist/index.js",
"browser": "dist/common.js",
"license": "GPL-3.0",
"author": "Hotaru <biyuehuya@gmail.com>",
"keywords": [
"kotori",
"chatbot",
"bot",
"robotics",
"kotori"
"i18n",
"tools"
],
"files": [
"dist"
"dist",
"LICENSE",
"README.md"
],

@@ -17,0 +20,0 @@ "bugs": {

Sorry, the diff of this file is not supported yet

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