@lytjs/plugin-i18n 6.9.2 → 6.9.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,65 @@
1
+ import * as _lytjs_core from '@lytjs/core';
2
+
3
+ /**
4
+ * @lytjs/plugin-i18n - 类型定义
5
+ */
6
+ /**
7
+ * 语言消息定义
8
+ */
9
+ type LocaleMessages = Record<string, string | Record<string, unknown>>;
10
+ /**
11
+ * 语言包
12
+ */
13
+ interface Locale {
14
+ [locale: string]: LocaleMessages;
15
+ }
16
+ /**
17
+ * i18n 配置选项
18
+ */
19
+ interface I18nOptions {
20
+ /** 默认语言 */
21
+ locale?: string;
22
+ /** 回退语言 */
23
+ fallbackLocale?: string;
24
+ /** 语言包 */
25
+ messages?: Locale;
26
+ /** 是否在控制台警告缺失的翻译 */
27
+ warnHtmlMessage?: boolean;
28
+ }
29
+ /**
30
+ * 翻译函数
31
+ */
32
+ type TranslateFn = (key: string, ...args: unknown[]) => string;
33
+ /**
34
+ * i18n 实例
35
+ */
36
+ interface I18nInstance {
37
+ /** 当前语言 */
38
+ locale: {
39
+ value: string;
40
+ };
41
+ /** 设置语言 */
42
+ setLocale(locale: string): void;
43
+ /** 获取翻译 */
44
+ t: TranslateFn;
45
+ /** 是否存在翻译 */
46
+ te(key: string, locale?: string): boolean;
47
+ /** 获取语言列表 */
48
+ availableLocales: string[];
49
+ /** 注册语言包 */
50
+ registerLocale(locale: string, messages: LocaleMessages): void;
51
+ /** 获取所有语言包 */
52
+ getMessages(): Locale;
53
+ }
54
+
55
+ /**
56
+ * 创建 i18n 实例
57
+ */
58
+ declare function createI18n(options?: I18nOptions): I18nInstance;
59
+ /**
60
+ * 注册语言包(独立函数版本)
61
+ */
62
+ declare function registerLocale(i18n: I18nInstance, locale: string, messages: LocaleMessages): void;
63
+ declare const pluginI18n: _lytjs_core.PluginDefinition<unknown>;
64
+
65
+ export { type I18nInstance, type I18nOptions, type Locale, type LocaleMessages, type TranslateFn, createI18n, pluginI18n as default, registerLocale };
@@ -0,0 +1,65 @@
1
+ import * as _lytjs_core from '@lytjs/core';
2
+
3
+ /**
4
+ * @lytjs/plugin-i18n - 类型定义
5
+ */
6
+ /**
7
+ * 语言消息定义
8
+ */
9
+ type LocaleMessages = Record<string, string | Record<string, unknown>>;
10
+ /**
11
+ * 语言包
12
+ */
13
+ interface Locale {
14
+ [locale: string]: LocaleMessages;
15
+ }
16
+ /**
17
+ * i18n 配置选项
18
+ */
19
+ interface I18nOptions {
20
+ /** 默认语言 */
21
+ locale?: string;
22
+ /** 回退语言 */
23
+ fallbackLocale?: string;
24
+ /** 语言包 */
25
+ messages?: Locale;
26
+ /** 是否在控制台警告缺失的翻译 */
27
+ warnHtmlMessage?: boolean;
28
+ }
29
+ /**
30
+ * 翻译函数
31
+ */
32
+ type TranslateFn = (key: string, ...args: unknown[]) => string;
33
+ /**
34
+ * i18n 实例
35
+ */
36
+ interface I18nInstance {
37
+ /** 当前语言 */
38
+ locale: {
39
+ value: string;
40
+ };
41
+ /** 设置语言 */
42
+ setLocale(locale: string): void;
43
+ /** 获取翻译 */
44
+ t: TranslateFn;
45
+ /** 是否存在翻译 */
46
+ te(key: string, locale?: string): boolean;
47
+ /** 获取语言列表 */
48
+ availableLocales: string[];
49
+ /** 注册语言包 */
50
+ registerLocale(locale: string, messages: LocaleMessages): void;
51
+ /** 获取所有语言包 */
52
+ getMessages(): Locale;
53
+ }
54
+
55
+ /**
56
+ * 创建 i18n 实例
57
+ */
58
+ declare function createI18n(options?: I18nOptions): I18nInstance;
59
+ /**
60
+ * 注册语言包(独立函数版本)
61
+ */
62
+ declare function registerLocale(i18n: I18nInstance, locale: string, messages: LocaleMessages): void;
63
+ declare const pluginI18n: _lytjs_core.PluginDefinition<unknown>;
64
+
65
+ export { type I18nInstance, type I18nOptions, type Locale, type LocaleMessages, type TranslateFn, createI18n, pluginI18n as default, registerLocale };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lytjs/plugin-i18n",
3
- "version": "6.9.2",
3
+ "version": "6.9.3",
4
4
  "description": "LytJS Internationalization plugin",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -28,9 +28,9 @@
28
28
  "clean": "rm -rf dist"
29
29
  },
30
30
  "dependencies": {
31
- "@lytjs/core": "workspace:*",
32
- "@lytjs/reactivity": "workspace:*",
33
- "@lytjs/common-is": "workspace:*"
31
+ "@lytjs/core": "^6.9.3",
32
+ "@lytjs/reactivity": "^6.9.3",
33
+ "@lytjs/common-is": "^6.9.3"
34
34
  },
35
35
  "devDependencies": {
36
36
  "tsup": "^8.0.0",