@kotori-bot/i18n
Advanced tools
Comparing version 1.3.1 to 1.3.2
@@ -18,2 +18,3 @@ import LocaleIdentifier from './types/locale'; | ||
locale(locale: string, lang?: T): string; | ||
t(raw: TemplateStringsArray): string; | ||
set(lang: T): void; | ||
@@ -20,0 +21,0 @@ get(): T; |
/** | ||
* @Package @kotori-bot/i18n | ||
* @Version 1.3.1 | ||
* @Author Hotaru <biyuehuya@gmail.com> | ||
* @Version 1.3.2 | ||
* @Author Hotaru <me@hotaru.icu> | ||
* @Copyright 2024 Hotaru. All rights reserved. | ||
* @License GPL-3.0 | ||
* @Link https://github.com/kotorijs/kotori | ||
* @Date 2024/6/7 11:22:21 | ||
* @Date 2024/8/8 20:53:56 | ||
*/ | ||
@@ -58,8 +58,6 @@ | ||
this.lang = config.lang; | ||
this.supports.forEach((locale) => this.localesData.set(locale, /* @__PURE__ */ new Map())); | ||
for (const locale of this.supports) 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]); | ||
}); | ||
for (const locale in locales) this.localesData.get(lang)?.set(locale.toLowerCase(), locales[locale]); | ||
} | ||
@@ -69,2 +67,5 @@ locale(locale, lang = this.lang) { | ||
} | ||
t(raw) { | ||
return this.locale(raw.join("")); | ||
} | ||
set(lang) { | ||
@@ -71,0 +72,0 @@ this.lang = lang; |
@@ -1,4 +0,4 @@ | ||
import { LocaleType } from './common'; | ||
import type { LocaleType } from './common'; | ||
export declare const DEFAULT_SUPPORTS: ("en_US" | "en_GB" | "en_AU" | "zh_CN" | "zh_HK" | "zh_TW" | "zh_SG" | "es_ES" | "es_MX" | "ar_EG" | "ar_AE" | "ru_RU" | "fr_FR" | "fr_CA" | "de_DE" | "de_CH" | "it_IT" | "it_CH" | "hi_IN" | "pt_BR" | "pt_PT" | "tr_TR" | "ja_JP" | "id_ID" | "uk_UA" | "vi_VN" | "th_TH" | "sv_SE" | "nb_NO" | "da_DK" | "fi_FI" | "he_IL" | "sk_SK" | "bg_BG" | "lt_LT" | "sl_SI" | "sr_RS" | "mk_MK" | "sq_AL" | "et_EE" | "mt_MT" | "common")[]; | ||
export declare const DEFAULT_LANG: LocaleType; | ||
export declare const DEFAULT_EXT = ".json"; |
/** | ||
* @Package @kotori-bot/i18n | ||
* @Version 1.3.1 | ||
* @Author Hotaru <biyuehuya@gmail.com> | ||
* @Version 1.3.2 | ||
* @Author Hotaru <me@hotaru.icu> | ||
* @Copyright 2024 Hotaru. All rights reserved. | ||
* @License GPL-3.0 | ||
* @Link https://github.com/kotorijs/kotori | ||
* @Date 2024/6/7 11:22:21 | ||
* @Date 2024/8/8 20:53:56 | ||
*/ | ||
@@ -11,0 +11,0 @@ |
@@ -1,2 +0,2 @@ | ||
import { I18n as I18nCommon, LocaleType, localeData } from './common'; | ||
import { I18n as I18nCommon, type LocaleType, type localeData } from './common'; | ||
export * from './common'; | ||
@@ -3,0 +3,0 @@ export declare class I18n<T extends LocaleType = LocaleType> extends I18nCommon<T> { |
/** | ||
* @Package @kotori-bot/i18n | ||
* @Version 1.3.1 | ||
* @Author Hotaru <biyuehuya@gmail.com> | ||
* @Version 1.3.2 | ||
* @Author Hotaru <me@hotaru.icu> | ||
* @Copyright 2024 Hotaru. All rights reserved. | ||
* @License GPL-3.0 | ||
* @Link https://github.com/kotorijs/kotori | ||
* @Date 2024/6/7 11:22:21 | ||
* @Date 2024/8/8 20:53:56 | ||
*/ | ||
@@ -45,5 +45,5 @@ | ||
loader(dir) { | ||
this.supports.forEach((lang) => { | ||
for (const lang of this.supports) { | ||
const file = (0, import_node_path.join)(dir, `${lang}${this.ext}`); | ||
if (!(0, import_node_fs.existsSync)(file)) return; | ||
if (!(0, import_node_fs.existsSync)(file)) continue; | ||
try { | ||
@@ -55,3 +55,3 @@ const locales = JSON.parse((0, import_node_fs.readFileSync)(file).toString()); | ||
} | ||
}); | ||
} | ||
} | ||
@@ -58,0 +58,0 @@ constructor(config = { lang: import_const.DEFAULT_LANG }) { |
/** | ||
* @Package @kotori-bot/i18n | ||
* @Version 1.3.1 | ||
* @Author Hotaru <biyuehuya@gmail.com> | ||
* @Version 1.3.2 | ||
* @Author Hotaru <me@hotaru.icu> | ||
* @Copyright 2024 Hotaru. All rights reserved. | ||
* @License GPL-3.0 | ||
* @Link https://github.com/kotorijs/kotori | ||
* @Date 2024/6/7 11:22:21 | ||
* @Date 2024/8/8 20:53:56 | ||
*/ | ||
@@ -11,0 +11,0 @@ |
{ | ||
"name": "@kotori-bot/i18n", | ||
"version": "1.3.1", | ||
"version": "1.3.2", | ||
"description": "i18n For Kotori", | ||
@@ -8,3 +8,3 @@ "main": "dist/index.js", | ||
"license": "GPL-3.0", | ||
"author": "Hotaru <biyuehuya@gmail.com>", | ||
"author": "Hotaru <me@hotaru.icu>", | ||
"keywords": [ | ||
@@ -11,0 +11,0 @@ "kotori", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
52422
402
0