vuesp-components 2.0.6 → 2.0.8

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.
@@ -1,6 +1,5 @@
1
1
  import { Plugin } from 'vue';
2
2
  import { I18nPluralRule } from './types';
3
- export declare function createPluralizer(rules: Record<string, I18nPluralRule>): (locale: string, count: number, forms: string[]) => string;
4
- declare const i18nPlugin: Plugin;
5
- export default i18nPlugin;
3
+ export declare function i18nPluralizer(rules: Record<string, I18nPluralRule>): (locale: string, count: number, forms: string[]) => string;
4
+ export declare const i18nPlugin: Plugin;
6
5
  //# 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;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"}
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,cAAc,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,IACxC,QAAQ,MAAM,EAAE,OAAO,MAAM,EAAE,OAAO,MAAM,EAAE,KAAG,MAAM,CAMlF;AAED,eAAO,MAAM,UAAU,EAAE,MAkFxB,CAAC"}
@@ -1,3 +1,3 @@
1
- import { default as i18n } from './i18n';
2
- export { i18n };
1
+ import { i18nPlugin, i18nPluralizer } from './i18n';
2
+ export { i18nPlugin, i18nPluralizer };
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugins/index.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,iBAAiB,CAAC;AACnC,OAAO,EAAE,IAAI,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugins/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,CAAC"}
@@ -1,52 +1,60 @@
1
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 = {
2
+ const y = { en: {} }, $ = "en";
3
+ function w(t) {
4
+ return function(a, f, u) {
5
+ const r = t[a] || t.en || t.ru;
6
+ return !u || u.length === 0 ? "" : r(f, u);
7
+ };
8
+ }
9
+ const S = {
10
+ install(t, e) {
11
+ e != null && e.pluralize || (console.warn("[i18n-plugin] pluralize function is required. Please provide it in options."), e = { ...e, pluralize: (i, b, l) => l[0] || "" });
12
+ const a = (e == null ? void 0 : e.locales) || y, f = (e == null ? void 0 : e.defaultLocale) || $, u = e.pluralize, r = P({
13
+ locale: f
14
+ }), d = {
8
15
  state: k(r),
9
- $t(c, a = {}) {
16
+ $t(c, i = {}) {
10
17
  const b = c.split(".");
11
- let l = f[r.locale];
12
- for (const n of b)
18
+ let l = a[r.locale];
19
+ for (const o of b)
13
20
  if (typeof l == "object" && l !== null)
14
- l = l[n];
21
+ l = l[o];
15
22
  else {
16
23
  l = void 0;
17
24
  break;
18
25
  }
19
26
  if (typeof l != "string") return c;
20
27
  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;
28
+ const o = l.split("|").map((z) => z.trim()), s = i.count !== void 0 ? Number(i.count) : 0, n = u(r.locale, s, o);
29
+ let g = n;
30
+ return n.includes("{count}") && (g = n.replace(/{count}/g, String(s))), g = g.replace(/{(\w+)}/g, (z, L) => {
31
+ const v = i[L];
32
+ return v !== void 0 ? String(v) : z;
33
+ }), g;
27
34
  }
28
- return l.replace(/{(\w+)}/g, (n, u) => {
29
- const t = a[u];
30
- return t !== void 0 ? String(t) : n;
35
+ return l.replace(/{(\w+)}/g, (o, s) => {
36
+ const n = i[s];
37
+ return n !== void 0 ? String(n) : o;
31
38
  });
32
39
  },
33
40
  setLocale(c) {
34
- if (f[c]) {
41
+ if (a[c]) {
35
42
  r.locale = c;
36
43
  return;
37
44
  }
38
- r.locale = d;
45
+ r.locale = f;
39
46
  },
40
47
  getLocale() {
41
48
  return r.locale;
42
49
  },
43
50
  getListLocales() {
44
- return Object.keys(f);
51
+ return Object.keys(a);
45
52
  }
46
53
  };
47
- o.config.globalProperties.$t = s.$t, o.config.globalProperties.$i18n = s, o.provide("i18n", s);
54
+ t.config.globalProperties.$t = d.$t, t.config.globalProperties.$i18n = d, t.provide("i18n", d);
48
55
  }
49
56
  };
50
57
  export {
51
- w as i18n
58
+ S as i18nPlugin,
59
+ w as i18nPluralizer
52
60
  };
@@ -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;AAE5G,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC;AAE3E,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"}
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
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.0.6",
2
+ "version": "2.0.8",
3
3
  "name": "vuesp-components",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",