@yiiamee/multilinguist 1.2.5 → 1.2.6

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/module.mjs CHANGED
@@ -30,27 +30,18 @@ function GenerateLocaleKeysPlugin(defaultLocaleFromConfig, localesPath, outPath)
30
30
  ``,
31
31
  `declare module '#app' {`,
32
32
  ` interface NuxtApp {`,
33
- " $t: (key: LocaleKey, variables?: Record<string, string>) => string;",
33
+ " $t<K extends LocaleKey>(key: K, variables?: Record<string, string>): string; ",
34
+ " t<K extends LocaleKey>(key: K, variables?: Record<string, string>): string; ",
34
35
  ` }`,
35
36
  `}`,
36
37
  ``,
37
38
  `declare module 'vue' {`,
38
39
  ` interface ComponentCustomProperties {`,
39
- " $t: (key: LocaleKey, variables?: Record<string, string>) => string;",
40
+ " $t<K extends LocaleKey>(key: K, variables?: Record<string, string>): string; ",
41
+ " t<K extends LocaleKey>(key: K, variables?: Record<string, string>): string; ",
40
42
  ` }`,
41
43
  `}`,
42
- ``,
43
- `declare module '#app' {`,
44
- ` interface NuxtApp {`,
45
- " t: (key: LocaleKey, variables?: Record<string, string>) => string;",
46
- ` }`,
47
- `}`,
48
- ``,
49
- `declare module 'vue' {`,
50
- ` interface ComponentCustomProperties {`,
51
- " t: (key: LocaleKey, variables?: Record<string, string>) => string;",
52
- ` }`,
53
- `}`
44
+ ``
54
45
  ].join("\n");
55
46
  fs.mkdirSync(path.dirname(outPath), { recursive: true });
56
47
  fs.writeFileSync(outPath, output, "utf-8");
@@ -4,7 +4,7 @@ export type TranslationMap = readonly string[];
4
4
  export type Locale<T extends TranslationMap> = T[number];
5
5
  export type LocaleKeys<T extends TranslationMap> = T[keyof T];
6
6
  export type TMultilinguistResponse<T extends TranslationMap> = {
7
- t: (key: LocaleKey, variables?: Record<string, string>) => string;
7
+ t<K extends LocaleKey>(key: K, variables?: Record<string, string>): string;
8
8
  setLocale: (locale: Locale<T>) => void;
9
9
  initLocalization: () => Promise<void>;
10
10
  locale: Ref<Locale<T>>;
@@ -1,5 +1,5 @@
1
1
  export default function useMultilinguist(): {
2
- t: (key: import("../types/generated-locales.js").LocaleKey, variables?: Record<string, string>) => string;
2
+ t<K extends LocaleKey>(key: K, variables?: Record<string, string>): string;
3
3
  setLocale: (locale: string) => void;
4
4
  initLocalization: () => Promise<void>;
5
5
  locale: import("vue").Ref<string, string>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yiiamee/multilinguist",
3
- "version": "1.2.5",
3
+ "version": "1.2.6",
4
4
  "description": "Nuxt 3 Multilinguist Localization module",
5
5
  "repository": "yiiameeMich/multilinguist",
6
6
  "license": "MIT",
@@ -1,35 +0,0 @@
1
- // AUTO-GENERATED FILE — DO NOT EDIT MANUALLY
2
- export interface TranslationMessages {
3
- "Hello, World": string;
4
- "Switch Locale": string;
5
- "Paste your variable here": string;
6
- "nested.Nested key": string;
7
- "nested.Language": string;
8
- "nested.nested second level.nested second level language": string;
9
- }
10
-
11
- export type LocaleKey = keyof TranslationMessages;
12
-
13
- declare module '#app' {
14
- interface NuxtApp {
15
- $t: (key: LocaleKey, variables?: Record<string, string>) => string;
16
- }
17
- }
18
-
19
- declare module 'vue' {
20
- interface ComponentCustomProperties {
21
- $t: (key: LocaleKey, variables?: Record<string, string>) => string;
22
- }
23
- }
24
-
25
- declare module '#app' {
26
- interface NuxtApp {
27
- t: (key: LocaleKey, variables?: Record<string, string>) => string;
28
- }
29
- }
30
-
31
- declare module 'vue' {
32
- interface ComponentCustomProperties {
33
- t: (key: LocaleKey, variables?: Record<string, string>) => string;
34
- }
35
- }