vuesp-components 2.0.5 → 2.0.7
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/dist/plugins/i18n/index.d.ts +2 -0
- package/dist/plugins/i18n/index.d.ts.map +1 -1
- package/dist/plugins/i18n/types.d.ts +2 -0
- package/dist/plugins/i18n/types.d.ts.map +1 -1
- package/dist/plugins/index.es.js +35 -22
- package/dist/plugins/types.d.ts +2 -2
- package/dist/plugins/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { Plugin } from 'vue';
|
|
2
|
+
import { I18nPluralRule } from './types';
|
|
3
|
+
export declare function createPluralizer(rules: Record<string, I18nPluralRule>): (locale: string, count: number, forms: string[]) => string;
|
|
2
4
|
declare const i18nPlugin: Plugin;
|
|
3
5
|
export default i18nPlugin;
|
|
4
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/i18n/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,MAAM,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/i18n/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,MAAM,EAAE,MAAM,KAAK,CAAC;AACtD,OAAO,KAAK,EAAmE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAK5H,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,IAC1C,QAAQ,MAAM,EAAE,OAAO,MAAM,EAAE,OAAO,MAAM,EAAE,KAAG,MAAM,CAMlF;AAED,QAAA,MAAM,UAAU,EAAE,MAkFjB,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -4,6 +4,7 @@ export interface ILocaleMessages {
|
|
|
4
4
|
export interface ILocales {
|
|
5
5
|
[locale: string]: ILocaleMessages;
|
|
6
6
|
}
|
|
7
|
+
export type I18nPluralRule = (count: number, forms: string[]) => string;
|
|
7
8
|
export interface I18nState {
|
|
8
9
|
locale: string;
|
|
9
10
|
}
|
|
@@ -18,6 +19,7 @@ export interface I18nInstance {
|
|
|
18
19
|
export interface I18nOptions {
|
|
19
20
|
defaultLocale?: string;
|
|
20
21
|
locales?: ILocales;
|
|
22
|
+
pluralize: (locale: string, count: number, forms: string[]) => string;
|
|
21
23
|
}
|
|
22
24
|
declare module '@vue/runtime-core' {
|
|
23
25
|
interface ComponentCustomProperties {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/plugins/i18n/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,eAAe,CAAC;CACzC;AAED,MAAM,WAAW,QAAQ;IACvB,CAAC,MAAM,EAAE,MAAM,GAAG,eAAe,CAAC;CACnC;AAED,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,OAAO,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,MAAM,CAAC;AAE/E,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAC;IAC3B,EAAE,EAAE,OAAO,CAAC;IACZ,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,SAAS,IAAI,MAAM,CAAC;IACpB,cAAc,IAAI,MAAM,EAAE,CAAC;CAC5B;AAED,MAAM,WAAW,WAAW;IAC1B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/plugins/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
|
1
|
-
import { reactive as
|
|
2
|
-
const
|
|
3
|
-
install(
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import { reactive as P, readonly as k } from "vue";
|
|
2
|
+
const m = { en: {} }, y = "en", w = {
|
|
3
|
+
install(o, e) {
|
|
4
|
+
e != null && e.pluralize || (console.warn("[i18n-plugin] pluralize function is required. Please provide it in options."), e = { ...e, pluralize: (a, b, l) => l[0] || "" });
|
|
5
|
+
const f = (e == null ? void 0 : e.locales) || m, d = (e == null ? void 0 : e.defaultLocale) || y, z = e.pluralize, r = P({
|
|
6
|
+
locale: d
|
|
7
|
+
}), s = {
|
|
8
|
+
state: k(r),
|
|
9
|
+
$t(c, a = {}) {
|
|
10
|
+
const b = c.split(".");
|
|
11
|
+
let l = f[r.locale];
|
|
12
|
+
for (const n of b)
|
|
13
|
+
if (typeof l == "object" && l !== null)
|
|
14
|
+
l = l[n];
|
|
14
15
|
else {
|
|
15
|
-
|
|
16
|
+
l = void 0;
|
|
16
17
|
break;
|
|
17
18
|
}
|
|
18
|
-
|
|
19
|
+
if (typeof l != "string") return c;
|
|
20
|
+
if (l.includes("|")) {
|
|
21
|
+
const n = l.split("|").map((g) => g.trim()), u = a.count !== void 0 ? Number(a.count) : 0, t = z(r.locale, u, n);
|
|
22
|
+
let i = t;
|
|
23
|
+
return t.includes("{count}") && (i = t.replace(/{count}/g, String(u))), i = i.replace(/{(\w+)}/g, (g, L) => {
|
|
24
|
+
const v = a[L];
|
|
25
|
+
return v !== void 0 ? String(v) : g;
|
|
26
|
+
}), i;
|
|
27
|
+
}
|
|
28
|
+
return l.replace(/{(\w+)}/g, (n, u) => {
|
|
29
|
+
const t = a[u];
|
|
30
|
+
return t !== void 0 ? String(t) : n;
|
|
31
|
+
});
|
|
19
32
|
},
|
|
20
33
|
setLocale(c) {
|
|
21
|
-
if (
|
|
22
|
-
|
|
34
|
+
if (f[c]) {
|
|
35
|
+
r.locale = c;
|
|
23
36
|
return;
|
|
24
37
|
}
|
|
25
|
-
|
|
38
|
+
r.locale = d;
|
|
26
39
|
},
|
|
27
40
|
getLocale() {
|
|
28
|
-
return
|
|
41
|
+
return r.locale;
|
|
29
42
|
},
|
|
30
43
|
getListLocales() {
|
|
31
|
-
return Object.keys(
|
|
44
|
+
return Object.keys(f);
|
|
32
45
|
}
|
|
33
46
|
};
|
|
34
|
-
|
|
47
|
+
o.config.globalProperties.$t = s.$t, o.config.globalProperties.$i18n = s, o.provide("i18n", s);
|
|
35
48
|
}
|
|
36
49
|
};
|
|
37
50
|
export {
|
|
38
|
-
|
|
51
|
+
w as i18n
|
|
39
52
|
};
|
package/dist/plugins/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ILocaleMessages, ILocales, I18nOptions, I18nState, I18nInstance } from './i18n/types';
|
|
2
|
-
export { ILocaleMessages, ILocales, I18nOptions, I18nState, I18nInstance };
|
|
1
|
+
import { ILocaleMessages, ILocales, I18nOptions, I18nState, I18nInstance, I18nPluralRule } from './i18n/types';
|
|
2
|
+
export { ILocaleMessages, ILocales, I18nOptions, I18nState, I18nInstance, I18nPluralRule };
|
|
3
3
|
declare module '@vue/runtime-core' {
|
|
4
4
|
interface ComponentCustomProperties {
|
|
5
5
|
$i18n: I18nInstance;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/plugins/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/plugins/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE5H,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,YAAY,EAAE,cAAc,EAAE,CAAC;AAE3F,OAAO,QAAQ,mBAAmB,CAAC;IACjC,UAAU,yBAAyB;QACjC,KAAK,EAAE,YAAY,CAAC;KACrB;CACF;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,KAAK,CAAC,EAAE,YAAY,CAAC;KACtB;CACF"}
|
package/package.json
CHANGED