@kong-ui-public/i18n 0.3.4-pr.213.d4733dd.0 → 0.3.5-pr.231.276ad83.0

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,8 +1,8 @@
1
1
  import type { VNodeChild, App, PropType } from 'vue';
2
2
  import type { IntlShapeEx } from './types';
3
- export declare const i18nTComponent: (i18n?: IntlShapeEx | null) => import("vue").DefineComponent<{
3
+ export declare const i18nTComponent: <MessageSource = any>(i18n: IntlShapeEx<MessageSource>) => import("vue").DefineComponent<{
4
4
  i18n: {
5
- type: PropType<IntlShapeEx>;
5
+ type: PropType<IntlShapeEx<MessageSource>>;
6
6
  default: null;
7
7
  };
8
8
  keypath: {
@@ -15,7 +15,7 @@ export declare const i18nTComponent: (i18n?: IntlShapeEx | null) => import("vue"
15
15
  };
16
16
  }, () => VNodeChild, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
17
17
  i18n: {
18
- type: PropType<IntlShapeEx>;
18
+ type: PropType<IntlShapeEx<MessageSource>>;
19
19
  default: null;
20
20
  };
21
21
  keypath: {
@@ -28,11 +28,11 @@ export declare const i18nTComponent: (i18n?: IntlShapeEx | null) => import("vue"
28
28
  };
29
29
  }>>, {
30
30
  tag: string;
31
- i18n: IntlShapeEx;
31
+ i18n: IntlShapeEx<MessageSource>;
32
32
  }>;
33
33
  declare const _default: {
34
- install(app: App, options: {
35
- i18n: IntlShapeEx;
34
+ install<MessageSource = any>(app: App, options: {
35
+ i18n: IntlShapeEx<MessageSource>;
36
36
  }): void;
37
37
  };
38
38
  export default _default;
@@ -1 +1 @@
1
- {"version":3,"file":"Translation.d.ts","sourceRoot":"","sources":["../../src/Translation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAA;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAE1C,eAAO,MAAM,cAAc,UAAU,WAAW,GAAG,IAAI;;;;;;;;;;;;;SAmCxC,UAAU;;;;;;;;;;;;;;;;EAyBvB,CAAA;;iBAIa,GAAG,WAAW;QAAE,IAAI,EAAE,WAAW,CAAA;KAAE;;AADlD,wBAKC"}
1
+ {"version":3,"file":"Translation.d.ts","sourceRoot":"","sources":["../../src/Translation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAA;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAE1C,eAAO,MAAM,cAAc;;;;;;;;;;;;;SAmCZ,UAAU;;;;;;;;;;;;;;;;EAyBvB,CAAA;;sCAIkC,GAAG;;;;AADvC,wBAKC"}
@@ -1,4 +1,4 @@
1
1
  import type { IntlShapeEx, SupportedLocales } from './types';
2
- export declare const createI18n: (locale: SupportedLocales, messages: Record<string, any>, isGlobal?: boolean) => IntlShapeEx;
3
- export default function useI18n(): IntlShapeEx;
2
+ export declare const createI18n: <MessageSource = any>(locale: SupportedLocales, messages: MessageSource, isGlobal?: boolean) => IntlShapeEx<MessageSource>;
3
+ export default function useI18n<MessageSource>(): IntlShapeEx<MessageSource>;
4
4
  //# sourceMappingURL=i18n.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../src/i18n.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAA+B,MAAM,SAAS,CAAA;AAQzF,eAAO,MAAM,UAAU,WAAY,gBAAgB,YAAY,OAAO,MAAM,EAAE,GAAG,CAAC,aAAY,OAAO,KAAW,WAoC/G,CAAA;AAGD,MAAM,CAAC,OAAO,UAAU,OAAO,IAAI,WAAW,CAE7C"}
1
+ {"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../src/i18n.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAA+B,MAAM,SAAS,CAAA;AASzF,eAAO,MAAM,UAAU,gCAAiC,gBAAgB,sCAAqC,OAAO,+BA0CnH,CAAA;AAGD,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,aAAa,KAAK,WAAW,CAAC,aAAa,CAAC,CAE3E"}
@@ -2,10 +2,16 @@ import type { IntlShape } from '@formatjs/intl';
2
2
  import type { Options as IntlMessageFormatOptions } from 'intl-messageformat';
3
3
  export type MessageFormatPrimitiveValue = string | number | boolean | null | undefined;
4
4
  export type SupportedLocales = 'en-us';
5
- export type IntlShapeEx = IntlShape & {
6
- t: (translationKey: string, values?: Record<string, MessageFormatPrimitiveValue> | undefined, opts?: IntlMessageFormatOptions) => string;
7
- te: (translationKey: string) => boolean;
8
- tm: (translationKey: string) => Array<string>;
9
- source: Record<string, any>;
5
+ type Dot<T extends string, U extends string> = '' extends U ? T : `${T}.${U}`;
6
+ export type PathToDotNotation<MessageSource, V> = MessageSource extends V ? '' : {
7
+ [K in Extract<keyof MessageSource, string>]: Dot<K, PathToDotNotation<MessageSource[K], V>>;
8
+ }[Extract<keyof MessageSource, string>];
9
+ type TFunction<M> = (translationKey: PathToDotNotation<M, string>, values?: Record<string, MessageFormatPrimitiveValue> | undefined, opts?: IntlMessageFormatOptions) => string;
10
+ export type IntlShapeEx<MessageSource = any> = Omit<IntlShape, '$t'> & {
11
+ t: TFunction<MessageSource>;
12
+ te: (translationKey: PathToDotNotation<MessageSource, string>) => boolean;
13
+ tm: (translationKey: PathToDotNotation<MessageSource, string>) => Array<string>;
14
+ source: MessageSource;
10
15
  };
16
+ export {};
11
17
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,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AG,EAAE,GAAG;KAC9E,CAAC,IAAI,OAAO,CAAC,MAAM,aAAa,EAAE,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC,EAAE,iBAAiB,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;CAC5F,CAAC,OAAO,CAAC,MAAM,aAAa,EAAE,MAAM,CAAC,CAAC,CAAA;AAEvC,KAAK,SAAS,CAAC,CAAC,IAAI,CAAC,cAAc,EAAE,iBAAiB,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,2BAA2B,CAAC,GAAG,SAAS,EAAE,IAAI,CAAC,EAAE,wBAAwB,KAAK,MAAM,CAAA;AAG/K,MAAM,MAAM,WAAW,CAAC,aAAa,GAAG,GAAG,IAAI,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,GAAG;IACrE,CAAC,EAAE,SAAS,CAAC,aAAa,CAAC,CAAA;IAC3B,EAAE,EAAE,CAAC,cAAc,EAAE,iBAAiB,CAAC,aAAa,EAAE,MAAM,CAAC,KAAK,OAAO,CAAA;IACzE,EAAE,EAAE,CAAC,cAAc,EAAE,iBAAiB,CAAC,aAAa,EAAE,MAAM,CAAC,KAAK,KAAK,CAAC,MAAM,CAAC,CAAA;IAC/E,MAAM,EAAE,aAAa,CAAA;CACtB,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kong-ui-public/i18n",
3
- "version": "0.3.4-pr.213.d4733dd.0",
3
+ "version": "0.3.5-pr.231.276ad83.0",
4
4
  "type": "module",
5
5
  "main": "./dist/i18n.umd.js",
6
6
  "module": "./dist/i18n.es.js",