@feugene/fint-i18n 0.2.0 → 0.2.2
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.
- package/README.md +6 -4
- package/README.ru.md +6 -4
- package/dist/chunks/{core-gGqMvw8y.js → core-CJdrAmJT.js} +1 -2
- package/dist/core.js +1 -1
- package/dist/index.js +1 -1
- package/dist/types/core/instance.d.ts +0 -1
- package/dist/types/core/types.d.ts +0 -1
- package/dist/types/vue/plugin.d.ts +11 -2
- package/dist/vue.js +10 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -25,6 +25,7 @@ You can find detailed information about the library in the relevant sections:
|
|
|
25
25
|
|
|
26
26
|
- 📦 **[Installation and Getting Started](./docs/en/installation.md)**: How to install the package and configure it in a Vue application.
|
|
27
27
|
- 📂 **[Defining Messages](./docs/en/defining-messages.md)**: JSON formats, loaders, and dynamic merging.
|
|
28
|
+
- 🌐 **[Authoring localization packages](./docs/en/authoring-localization-packages.md)**: Per-locale export contract for tree-shakable donor packages.
|
|
28
29
|
- 🚀 **[Usage](./docs/en/usage.md)**: How to use `t()`, `$t`, and the `v-t` directive.
|
|
29
30
|
- 📘 **[API Reference](./docs/en/api.md)**: Detailed description of all functions, methods, and composables.
|
|
30
31
|
- 🔌 **[Plugins](./docs/en/plugins.md)**: Extending functionality via the hook system and built-in plugins.
|
|
@@ -41,13 +42,14 @@ You can find detailed information about the library in the relevant sections:
|
|
|
41
42
|
import { createApp } from 'vue'
|
|
42
43
|
import { createFintI18n } from '@feugene/fint-i18n/core'
|
|
43
44
|
import { installI18n } from '@feugene/fint-i18n/vue'
|
|
44
|
-
import {
|
|
45
|
-
import {
|
|
46
|
-
|
|
45
|
+
import { en as appEn, ru as appRu } from './i18n/messages'
|
|
46
|
+
import { en as granularityEn, ru as granularityRu } from '@feugene/granularity/i18n'
|
|
47
47
|
const i18n = createFintI18n({
|
|
48
48
|
locale: 'en',
|
|
49
49
|
fallbackLocale: 'en',
|
|
50
|
-
|
|
50
|
+
// Import only the locales the application actually ships — bundlers will
|
|
51
|
+
// tree-shake the rest out of the final build.
|
|
52
|
+
loaders: [appEn, appRu, granularityEn, granularityRu],
|
|
51
53
|
})
|
|
52
54
|
|
|
53
55
|
const app = createApp(App)
|
package/README.ru.md
CHANGED
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
|
|
21
21
|
- 📦 **[Установка и начало работы](./docs/ru/installation.md)**: Как установить пакет и настроить его в приложении Vue.
|
|
22
22
|
- 📂 **[Определение сообщений](./docs/ru/defining-messages.md)**: Форматы JSON, лоадеры и динамический мердж.
|
|
23
|
+
- 🌐 **[Гайд для авторов локализационных пакетов](./docs/ru/authoring-localization-packages.md)**: Контракт per-locale экспортов для tree-shakable пакетов-доноров.
|
|
23
24
|
- 🚀 **[Использование](./docs/ru/usage.md)**: Как использовать `t()`, `$t` и директиву `v-t`.
|
|
24
25
|
- 📘 **[Справочник API](./docs/ru/api.md)**: Подробное описание всех функций, методов и композаблов.
|
|
25
26
|
- 🔌 **[Плагины](./docs/ru/plugins.md)**: Расширение функционала через систему хуков и встроенные плагины.
|
|
@@ -36,13 +37,14 @@
|
|
|
36
37
|
import { createApp } from 'vue'
|
|
37
38
|
import { createFintI18n } from '@feugene/fint-i18n/core'
|
|
38
39
|
import { installI18n } from '@feugene/fint-i18n/vue'
|
|
39
|
-
import {
|
|
40
|
-
import {
|
|
41
|
-
|
|
40
|
+
import { en as appEn, ru as appRu } from './i18n/messages'
|
|
41
|
+
import { en as granularityEn, ru as granularityRu } from '@feugene/granularity/i18n'
|
|
42
42
|
const i18n = createFintI18n({
|
|
43
43
|
locale: 'en',
|
|
44
44
|
fallbackLocale: 'en',
|
|
45
|
-
|
|
45
|
+
// Импортируйте только те локали, которые реально нужны приложению —
|
|
46
|
+
// остальные сборщик удалит при tree-shaking.
|
|
47
|
+
loaders: [appEn, appRu, granularityEn, granularityRu],
|
|
46
48
|
})
|
|
47
49
|
|
|
48
50
|
const app = createApp(App)
|
|
@@ -190,7 +190,6 @@ function m(t) {
|
|
|
190
190
|
var h = class {
|
|
191
191
|
locale;
|
|
192
192
|
fallbackLocale;
|
|
193
|
-
globalInstall;
|
|
194
193
|
messages = t({});
|
|
195
194
|
compiledMessages = Object.create(null);
|
|
196
195
|
loaderRegistry;
|
|
@@ -202,7 +201,7 @@ var h = class {
|
|
|
202
201
|
skipNextUsedBlockLoadLocale = null;
|
|
203
202
|
hooks = new a();
|
|
204
203
|
constructor(e) {
|
|
205
|
-
this.locale = n(e.locale), this.fallbackLocale = e.fallbackLocale || "", this.loaderRegistry = new l(e.loaders),
|
|
204
|
+
this.locale = n(e.locale), this.fallbackLocale = e.fallbackLocale || "", this.loaderRegistry = new l(e.loaders), e.plugins && e.plugins.forEach((e) => e.install(this)), r(this.locale, (e, t) => {
|
|
206
205
|
if (e !== t) {
|
|
207
206
|
if (this.skipNextUsedBlockLoadLocale === e) {
|
|
208
207
|
this.skipNextUsedBlockLoadLocale = null;
|
package/dist/core.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as e, n as t, r as n, t as r } from "./chunks/core-
|
|
1
|
+
import { i as e, n as t, r as n, t as r } from "./chunks/core-CJdrAmJT.js";
|
|
2
2
|
export { r as FintI18n, n as HookManager, e as compileTemplate, t as createFintI18n };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as e, n as t, r as n, t as r } from "./chunks/core-
|
|
1
|
+
import { i as e, n as t, r as n, t as r } from "./chunks/core-CJdrAmJT.js";
|
|
2
2
|
import { FINT_I18N_KEY as i, createVTDirective as a, installI18n as o, useFintI18n as s, useI18nScope as c } from "./vue.js";
|
|
3
3
|
import { BridgePlugin as l, HookLoggerPlugin as u, PersistencePlugin as d } from "./plugins.js";
|
|
4
4
|
export { l as BridgePlugin, i as FINT_I18N_KEY, r as FintI18n, u as HookLoggerPlugin, n as HookManager, d as PersistencePlugin, e as compileTemplate, t as createFintI18n, a as createVTDirective, o as installI18n, s as useFintI18n, c as useI18nScope };
|
|
@@ -4,7 +4,6 @@ import type { FintI18nOptions, Locale, MessageValue, TranslateOptions } from './
|
|
|
4
4
|
export declare class FintI18n {
|
|
5
5
|
locale: Ref<Locale>;
|
|
6
6
|
fallbackLocale: Locale;
|
|
7
|
-
globalInstall: boolean;
|
|
8
7
|
readonly messages: Record<Locale, any>;
|
|
9
8
|
private compiledMessages;
|
|
10
9
|
private readonly loaderRegistry;
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import type { App } from 'vue';
|
|
2
2
|
import type { FintI18n } from '@/core';
|
|
3
|
-
export
|
|
3
|
+
export type GlobalInstallFn = (app: App, i18n: FintI18n) => void;
|
|
4
|
+
export interface InstallI18nOptions {
|
|
4
5
|
directive?: string | boolean;
|
|
5
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Управляет регистрацией глобальных свойств ($t, $i18n).
|
|
8
|
+
* - функция: вызывается вместо стандартной регистрации;
|
|
9
|
+
* - `true` (по умолчанию): выполняется стандартная регистрация;
|
|
10
|
+
* - `false`: ничего не происходит.
|
|
11
|
+
*/
|
|
12
|
+
globalInstall?: boolean | GlobalInstallFn;
|
|
13
|
+
}
|
|
14
|
+
export declare function installI18n(app: App, i18n: FintI18n, options?: InstallI18nOptions): void;
|
package/dist/vue.js
CHANGED
|
@@ -42,10 +42,15 @@ function o(e, t, n) {
|
|
|
42
42
|
}
|
|
43
43
|
//#endregion
|
|
44
44
|
//#region src/vue/plugin.ts
|
|
45
|
-
function s(e, t
|
|
46
|
-
e.
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
function s(e, t) {
|
|
46
|
+
e.config.globalProperties.$t = t.t, e.config.globalProperties.$i18n = t;
|
|
47
|
+
}
|
|
48
|
+
function c(e, t, r = {}) {
|
|
49
|
+
e.provide(n, t);
|
|
50
|
+
let i = r.globalInstall ?? !0;
|
|
51
|
+
typeof i == "function" ? i(e, t) : i && s(e, t);
|
|
52
|
+
let o = r.directive === !1 ? null : typeof r.directive == "string" ? r.directive : "t";
|
|
53
|
+
o && e.directive(o, a(t));
|
|
49
54
|
}
|
|
50
55
|
//#endregion
|
|
51
|
-
export { n as FINT_I18N_KEY, a as createVTDirective,
|
|
56
|
+
export { n as FINT_I18N_KEY, a as createVTDirective, c as installI18n, r as useFintI18n, i as useI18nScope };
|
package/package.json
CHANGED