@yiiamee/multilinguist 1.2.3 → 1.2.4

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.
Files changed (2) hide show
  1. package/dist/module.mjs +16 -25
  2. package/package.json +1 -1
package/dist/module.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { defineNuxtModule, createResolver, addPlugin, addImportsDir, addTypeTemplate } from '@nuxt/kit';
1
+ import { defineNuxtModule, createResolver, addPlugin, addImportsDir } from '@nuxt/kit';
2
2
  import fs from 'fs';
3
3
  import path from 'path';
4
4
 
@@ -26,7 +26,19 @@ function GenerateLocaleKeysPlugin(defaultLocaleFromConfig, localesPath, outPath)
26
26
  ...keys.map((key) => ` ${JSON.stringify(key)}: string;`),
27
27
  `}`,
28
28
  ``,
29
- `export type LocaleKey = keyof TranslationMessages;`
29
+ `export type LocaleKey = keyof TranslationMessages;`,
30
+ ``,
31
+ `declare module '#app' {`,
32
+ ` interface NuxtApp {`,
33
+ " $t: (key: LocaleKey, variables?: Record<string, string>) => string;",
34
+ ` }`,
35
+ `}`,
36
+ ``,
37
+ `declare module 'vue' {`,
38
+ ` interface ComponentCustomProperties {`,
39
+ " $t: (key: LocaleKey, variables?: Record<string, string>) => string;",
40
+ ` }`,
41
+ `}`
30
42
  ].join("\n");
31
43
  fs.mkdirSync(path.dirname(outPath), { recursive: true });
32
44
  fs.writeFileSync(outPath, output, "utf-8");
@@ -58,34 +70,13 @@ const module = defineNuxtModule({
58
70
  const resolver = createResolver(import.meta.url);
59
71
  addPlugin(resolver.resolve("runtime/plugin"));
60
72
  addImportsDir(resolver.resolve("runtime/composables"));
61
- addTypeTemplate({
62
- filename: "types/multilinguist.d.ts",
63
- getContents: () => `
64
- import type { TranslationMessages } from './generated-locales'
65
-
66
- declare module '#app' {
67
- interface NuxtApp {
68
- $t: (key: keyof TranslationMessages) => string
69
- }
70
- }
71
-
72
- declare module 'vue' {
73
- interface ComponentCustomProperties {
74
- $t: (key: keyof TranslationMessages) => string
75
- }
76
- }
77
- `
78
- });
79
73
  nuxtApp.hook("vite:extendConfig", (viteConfig) => {
80
74
  viteConfig.plugins = viteConfig.plugins || [];
81
- viteConfig.plugins.push(GenerateLocaleKeysPlugin(moduleOptions.defaultLocale, `${nuxtApp.options.rootDir}/public/locales`, resolver.resolve("./types/generated-locales.d.ts")));
75
+ viteConfig.plugins.push(GenerateLocaleKeysPlugin(moduleOptions.defaultLocale, `${nuxtApp.options.rootDir}/public/locales`, resolver.resolve("./runtime/types/generated-locales.d.ts")));
82
76
  });
83
77
  nuxtApp.hook("prepare:types", ({ references }) => {
84
78
  references.push({
85
- path: resolver.resolve("./types/generated-locales.d.ts")
86
- });
87
- references.push({
88
- path: resolver.resolve("./types/multilinguist.d.ts")
79
+ path: resolver.resolve("./runtime/types/generated-locales.d.ts")
89
80
  });
90
81
  });
91
82
  nuxtApp.options.runtimeConfig.public.multilinguist = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yiiamee/multilinguist",
3
- "version": "1.2.3",
3
+ "version": "1.2.4",
4
4
  "description": "Nuxt 3 Multilinguist Localization module",
5
5
  "repository": "yiiameeMich/multilinguist",
6
6
  "license": "MIT",