@intlayer/nuxtjs-i18n 9.5.10

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 (40) hide show
  1. package/README.md +329 -0
  2. package/dist/esm/constants.mjs +15 -0
  3. package/dist/esm/constants.mjs.map +1 -0
  4. package/dist/esm/index.mjs +4 -0
  5. package/dist/esm/module.mjs +75 -0
  6. package/dist/esm/module.mjs.map +1 -0
  7. package/dist/esm/runtime/NuxtLinkLocale.mjs +42 -0
  8. package/dist/esm/runtime/NuxtLinkLocale.mjs.map +1 -0
  9. package/dist/esm/runtime/composer.mjs +71 -0
  10. package/dist/esm/runtime/composer.mjs.map +1 -0
  11. package/dist/esm/runtime/define.mjs +23 -0
  12. package/dist/esm/runtime/define.mjs.map +1 -0
  13. package/dist/esm/runtime/index.mjs +7 -0
  14. package/dist/esm/runtime/nuxtPlugin.mjs +32 -0
  15. package/dist/esm/runtime/nuxtPlugin.mjs.map +1 -0
  16. package/dist/esm/runtime/nuxtVirtualModules.d.mjs +0 -0
  17. package/dist/esm/runtime/routing.mjs +143 -0
  18. package/dist/esm/runtime/routing.mjs.map +1 -0
  19. package/dist/esm/types.mjs +0 -0
  20. package/dist/types/constants.d.ts +13 -0
  21. package/dist/types/constants.d.ts.map +1 -0
  22. package/dist/types/index.d.ts +4 -0
  23. package/dist/types/module.d.ts +28 -0
  24. package/dist/types/module.d.ts.map +1 -0
  25. package/dist/types/runtime/NuxtLinkLocale.d.ts +42 -0
  26. package/dist/types/runtime/NuxtLinkLocale.d.ts.map +1 -0
  27. package/dist/types/runtime/composer.d.ts +66 -0
  28. package/dist/types/runtime/composer.d.ts.map +1 -0
  29. package/dist/types/runtime/define.d.ts +23 -0
  30. package/dist/types/runtime/define.d.ts.map +1 -0
  31. package/dist/types/runtime/index.d.ts +6 -0
  32. package/dist/types/runtime/nuxtPlugin.d.ts +12 -0
  33. package/dist/types/runtime/nuxtPlugin.d.ts.map +1 -0
  34. package/dist/types/runtime/nuxtVirtualModules.d.ts +8 -0
  35. package/dist/types/runtime/nuxtVirtualModules.d.ts.map +1 -0
  36. package/dist/types/runtime/routing.d.ts +47 -0
  37. package/dist/types/runtime/routing.d.ts.map +1 -0
  38. package/dist/types/types.d.ts +82 -0
  39. package/dist/types/types.d.ts.map +1 -0
  40. package/package.json +109 -0
@@ -0,0 +1,23 @@
1
+ //#region src/runtime/define.ts
2
+ /**
3
+ * Identity helper for `i18n.config.ts`. Kept for migration: message catalogs
4
+ * move to intlayer dictionaries, so the returned config is never loaded.
5
+ */
6
+ const defineI18nConfig = (config) => config;
7
+ /** Identity helper for lazy locale files; intlayer bundles dictionaries. */
8
+ const defineI18nLocale = (loader) => loader;
9
+ /** Identity helper for locale detectors; intlayer's middleware detects. */
10
+ const defineI18nLocaleDetector = (detector) => detector;
11
+ /**
12
+ * Page route options. Localized paths come from intlayer's
13
+ * `routing.rewrite` rules, so this is a no-op kept for migration.
14
+ */
15
+ const defineI18nRoute = (_route) => {};
16
+ /** Dynamic route params per locale; unused with intlayer's routing. */
17
+ const useSetI18nParams = () => () => {};
18
+ /** Preload hint for message keys; dictionaries are already bundled. */
19
+ const useI18nPreloadKeys = (_keys) => {};
20
+
21
+ //#endregion
22
+ export { defineI18nConfig, defineI18nLocale, defineI18nLocaleDetector, defineI18nRoute, useI18nPreloadKeys, useSetI18nParams };
23
+ //# sourceMappingURL=define.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define.mjs","names":[],"sources":["../../../src/runtime/define.ts"],"sourcesContent":["import type { I18nOptions } from 'vue-i18n';\nimport type {\n ConfigLoader,\n I18nRoute,\n LocaleLoader,\n SetI18nParamsFunction,\n} from '../types';\n\n/**\n * Identity helper for `i18n.config.ts`. Kept for migration: message catalogs\n * move to intlayer dictionaries, so the returned config is never loaded.\n */\nexport const defineI18nConfig = <Config extends I18nOptions>(\n config: ConfigLoader<Config>\n): ConfigLoader<Config> => config;\n\n/** Identity helper for lazy locale files; intlayer bundles dictionaries. */\nexport const defineI18nLocale = <Messages = Record<string, unknown>>(\n loader: LocaleLoader<Messages>\n): LocaleLoader<Messages> => loader;\n\n/** Identity helper for locale detectors; intlayer's middleware detects. */\nexport const defineI18nLocaleDetector = <\n Detector extends (...args: never[]) => string,\n>(\n detector: Detector\n): Detector => detector;\n\n/**\n * Page route options. Localized paths come from intlayer's\n * `routing.rewrite` rules, so this is a no-op kept for migration.\n */\nexport const defineI18nRoute = (_route: I18nRoute | false): void => {};\n\n/** Dynamic route params per locale; unused with intlayer's routing. */\nexport const useSetI18nParams = (): SetI18nParamsFunction => () => {};\n\n/** Preload hint for message keys; dictionaries are already bundled. */\nexport const useI18nPreloadKeys = (_keys: string[]): void => {};\n"],"mappings":";;;;;AAYA,MAAa,oBACX,WACyB;;AAG3B,MAAa,oBACX,WAC2B;;AAG7B,MAAa,4BAGX,aACa;;;;;AAMf,MAAa,mBAAmB,WAAoC,CAAC;;AAGrE,MAAa,+BAAsD,CAAC;;AAGpE,MAAa,sBAAsB,UAA0B,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { STRATEGIES, STRATEGY_NO_PREFIX, STRATEGY_PREFIX, STRATEGY_PREFIX_AND_DEFAULT, STRATEGY_PREFIX_EXCEPT_DEFAULT } from "../constants.mjs";
2
+ import { useBrowserLocale, useCookieLocale, useLocaleHead, useLocalePath, useLocaleRoute, useRouteBaseName, useSwitchLocalePath } from "./routing.mjs";
3
+ import { useDictionary, useDictionaryDynamic, useI18n } from "./composer.mjs";
4
+ import { defineI18nConfig, defineI18nLocale, defineI18nLocaleDetector, defineI18nRoute, useI18nPreloadKeys, useSetI18nParams } from "./define.mjs";
5
+ import { NuxtLinkLocale } from "./NuxtLinkLocale.mjs";
6
+
7
+ export { NuxtLinkLocale, STRATEGIES, STRATEGY_NO_PREFIX, STRATEGY_PREFIX, STRATEGY_PREFIX_AND_DEFAULT, STRATEGY_PREFIX_EXCEPT_DEFAULT, defineI18nConfig, defineI18nLocale, defineI18nLocaleDetector, defineI18nRoute, useBrowserLocale, useCookieLocale, useDictionary, useDictionaryDynamic, useI18n, useI18nPreloadKeys, useLocaleHead, useLocalePath, useLocaleRoute, useRouteBaseName, useSetI18nParams, useSwitchLocalePath };
@@ -0,0 +1,32 @@
1
+ import { createLocalePath, createLocaleRoute, createRouteBaseName, createSwitchLocalePath, getLocaleHead } from "./routing.mjs";
2
+ import { createI18n } from "@intlayer/vue-i18n";
3
+ import { defineNuxtPlugin } from "#app";
4
+
5
+ //#region src/runtime/nuxtPlugin.ts
6
+ /**
7
+ * Installs vue-i18n's globals (`$t`, `$d`, `$n`, `v-t`…) and the
8
+ * @nuxtjs/i18n helpers (`$localePath`, `$switchLocalePath`…) on the app.
9
+ *
10
+ * Registered after `nuxt-intlayer`'s plugin, which installs the intlayer
11
+ * client every helper reads the locale from.
12
+ */
13
+ var nuxtPlugin_default = defineNuxtPlugin({
14
+ name: "intlayer:nuxtjs-i18n",
15
+ setup: (nuxtApp) => {
16
+ const i18n = createI18n({});
17
+ nuxtApp.vueApp.use(i18n);
18
+ const router = nuxtApp.$router;
19
+ return { provide: {
20
+ i18n: i18n.global,
21
+ localePath: createLocalePath(router),
22
+ switchLocalePath: createSwitchLocalePath(router),
23
+ localeRoute: createLocaleRoute(router),
24
+ getRouteBaseName: createRouteBaseName(router),
25
+ localeHead: (options) => getLocaleHead(options, router)
26
+ } };
27
+ }
28
+ });
29
+
30
+ //#endregion
31
+ export { nuxtPlugin_default as default };
32
+ //# sourceMappingURL=nuxtPlugin.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nuxtPlugin.mjs","names":[],"sources":["../../../src/runtime/nuxtPlugin.ts"],"sourcesContent":["// @ts-nocheck -- Nuxt runtime types are provided at application level\n\nimport { createI18n } from '@intlayer/vue-i18n';\nimport { defineNuxtPlugin } from '#app';\nimport {\n createLocalePath,\n createLocaleRoute,\n createRouteBaseName,\n createSwitchLocalePath,\n getLocaleHead,\n} from './routing';\n\n/**\n * Installs vue-i18n's globals (`$t`, `$d`, `$n`, `v-t`…) and the\n * @nuxtjs/i18n helpers (`$localePath`, `$switchLocalePath`…) on the app.\n *\n * Registered after `nuxt-intlayer`'s plugin, which installs the intlayer\n * client every helper reads the locale from.\n */\nexport default defineNuxtPlugin({\n name: 'intlayer:nuxtjs-i18n',\n setup: (nuxtApp) => {\n const i18n = createI18n({});\n nuxtApp.vueApp.use(i18n);\n\n const router = nuxtApp.$router;\n\n return {\n provide: {\n i18n: i18n.global,\n localePath: createLocalePath(router),\n switchLocalePath: createSwitchLocalePath(router),\n localeRoute: createLocaleRoute(router),\n getRouteBaseName: createRouteBaseName(router),\n localeHead: (options) => getLocaleHead(options, router),\n },\n };\n },\n});\n"],"mappings":";;;;;;;;;;;;AAmBA,yBAAe,iBAAiB;CAC9B,MAAM;CACN,QAAQ,YAAY;EAClB,MAAM,OAAO,WAAW,CAAC,CAAC;EAC1B,QAAQ,OAAO,IAAI,IAAI;EAEvB,MAAM,SAAS,QAAQ;EAEvB,OAAO,EACL,SAAS;GACP,MAAM,KAAK;GACX,YAAY,iBAAiB,MAAM;GACnC,kBAAkB,uBAAuB,MAAM;GAC/C,aAAa,kBAAkB,MAAM;GACrC,kBAAkB,oBAAoB,MAAM;GAC5C,aAAa,YAAY,cAAc,SAAS,MAAM;EACxD,EACF;CACF;AACF,CAAC"}
File without changes
@@ -0,0 +1,143 @@
1
+ import { internationalization, routing } from "@intlayer/config/built";
2
+ import { getHTMLTextDir, getLocalizedUrl, getPathWithoutLocale } from "@intlayer/core/localization";
3
+ import { getCachedLocaleFromStorageClient } from "@intlayer/core/utils";
4
+ import { computed, getCurrentInstance, ref } from "vue";
5
+ import { createIntlayerClient } from "vue-intlayer";
6
+
7
+ //#region src/runtime/routing.ts
8
+ const defaultLocale = internationalization?.defaultLocale ?? "en";
9
+ const localeCodes = internationalization?.locales ?? [defaultLocale];
10
+ /** Separator of localized route names generated by `nuxt-intlayer`. */
11
+ const ROUTE_NAME_SEPARATOR = "___";
12
+ /** @nuxtjs/i18n strategy equivalent to intlayer's `routing.mode`. */
13
+ const strategy = {
14
+ "prefix-all": "prefix",
15
+ "prefix-no-default": "prefix_except_default",
16
+ "no-prefix": "no_prefix",
17
+ "search-params": "no_prefix"
18
+ }[routing?.mode ?? "prefix-no-default"];
19
+ /** The active locale — intlayer's client singleton, readable anywhere. */
20
+ const getActiveLocale = () => createIntlayerClient().locale.value ?? defaultLocale;
21
+ /** The first browser language matching a configured locale. */
22
+ const detectBrowserLocale = () => typeof navigator === "undefined" ? void 0 : navigator.languages.map((language) => localeCodes.find((code) => code === language) ?? localeCodes.find((code) => code === language.split("-")[0])).find((code) => code !== void 0);
23
+ /** `useBrowserLocale()` — the browser locale among the configured ones. */
24
+ const useBrowserLocale = () => detectBrowserLocale() ?? null;
25
+ /** `useCookieLocale()` — the locale persisted by intlayer, or `''`. */
26
+ const useCookieLocale = () => ref(getCachedLocaleFromStorageClient() ?? "");
27
+ /** The app router, when called from a component setup. */
28
+ const getRouter = () => getCurrentInstance()?.appContext.config.globalProperties.$router;
29
+ /** Current URL path (`/fr/about?tab=1#top`), from the router or `window`. */
30
+ const getCurrentFullPath = (router) => {
31
+ if (router) return router.currentRoute.value.fullPath;
32
+ if (typeof window === "undefined") return "/";
33
+ const { pathname, search, hash } = window.location;
34
+ return `${pathname}${search}${hash}`;
35
+ };
36
+ const toSearch = (query) => {
37
+ if (!query) return "";
38
+ const searchParams = new URLSearchParams();
39
+ for (const [key, value] of Object.entries(query)) for (const item of Array.isArray(value) ? value : [value]) searchParams.append(key, String(item));
40
+ const search = searchParams.toString();
41
+ return search ? `?${search}` : "";
42
+ };
43
+ /**
44
+ * Serialises a route argument to a path with query and hash. A named route
45
+ * is resolved through the router when one is available.
46
+ */
47
+ const toFullPath = (route, router) => {
48
+ if (typeof route === "string") return route.startsWith("/") ? route : `/${route}`;
49
+ if (!route.path && route.name && router?.hasRoute(route.name)) return router.resolve({
50
+ name: route.name,
51
+ params: route.params,
52
+ query: route.query,
53
+ hash: route.hash
54
+ }).fullPath;
55
+ const path = route.path ?? `/${route.name ?? ""}`;
56
+ const hash = route.hash ? route.hash.startsWith("#") ? route.hash : `#${route.hash}` : "";
57
+ return `${path.startsWith("/") ? path : `/${path}`}${toSearch(route.query)}${hash}`;
58
+ };
59
+ /** Localizes a full path (query and hash kept) for `locale`. */
60
+ const localizeFullPath = (fullPath, locale) => getLocalizedUrl(getPathWithoutLocale(fullPath), locale);
61
+ /** `localePath(route, locale?)` bound to a router. */
62
+ const createLocalePath = (router) => (route, locale) => localizeFullPath(toFullPath(route, router), locale ?? getActiveLocale());
63
+ /** `switchLocalePath(locale)` bound to a router. */
64
+ const createSwitchLocalePath = (router) => (locale) => localizeFullPath(getCurrentFullPath(router), locale);
65
+ /** `localeRoute(route, locale?)` bound to a router. */
66
+ const createLocaleRoute = (router) => {
67
+ const localePath = createLocalePath(router);
68
+ return (route, locale) => {
69
+ const fullPath = localePath(route, locale);
70
+ const path = fullPath.split(/[?#]/)[0] ?? fullPath;
71
+ return typeof route === "string" ? {
72
+ path,
73
+ fullPath
74
+ } : {
75
+ ...route,
76
+ path,
77
+ fullPath
78
+ };
79
+ };
80
+ };
81
+ /**
82
+ * Route base name bound to a router: strips the locale from a route name
83
+ * (`about___fr`) or path (`/fr/about`).
84
+ */
85
+ const createRouteBaseName = (router) => (route) => {
86
+ const name = typeof route === "object" ? route.name : route && !route.startsWith("/") ? route : void 0;
87
+ if (name) return name.split(ROUTE_NAME_SEPARATOR)[0];
88
+ const path = typeof route === "string" ? route : route?.path ?? getCurrentFullPath(router);
89
+ return getPathWithoutLocale(path.split(/[?#]/)[0] ?? path).replace(/^\//, "") || "index";
90
+ };
91
+ /** `localePath(route, locale?)` — the localized path of a route. */
92
+ const useLocalePath = () => createLocalePath(getRouter());
93
+ /** `switchLocalePath(locale)` — the current route in another locale. */
94
+ const useSwitchLocalePath = () => createSwitchLocalePath(getRouter());
95
+ /** `localeRoute(route, locale?)` — a localized route object. */
96
+ const useLocaleRoute = () => createLocaleRoute(getRouter());
97
+ /** `getRouteBaseName(route?)` — a route name without its locale suffix. */
98
+ const useRouteBaseName = () => createRouteBaseName(getRouter());
99
+ /** Resolves `html` attributes and SEO links for the active locale. */
100
+ const resolveLocaleHead = ({ dir = true, lang = true, seo = true }, router) => {
101
+ const activeLocale = getActiveLocale();
102
+ const head = { htmlAttrs: {
103
+ ...lang ? { lang: activeLocale } : {},
104
+ ...dir ? { dir: getHTMLTextDir(activeLocale) } : {}
105
+ } };
106
+ if (!seo) return head;
107
+ const basePath = getPathWithoutLocale(getCurrentFullPath(router).split(/[?#]/)[0] ?? "/");
108
+ head.link = [
109
+ ...localeCodes.map((locale) => ({
110
+ rel: "alternate",
111
+ hreflang: locale,
112
+ href: localizeFullPath(basePath, locale)
113
+ })),
114
+ {
115
+ rel: "alternate",
116
+ hreflang: "x-default",
117
+ href: localizeFullPath(basePath, defaultLocale)
118
+ },
119
+ {
120
+ rel: "canonical",
121
+ href: localizeFullPath(basePath, activeLocale)
122
+ }
123
+ ];
124
+ head.meta = [{
125
+ property: "og:locale",
126
+ content: activeLocale
127
+ }, ...localeCodes.filter((locale) => locale !== activeLocale).map((locale) => ({
128
+ property: "og:locale:alternate",
129
+ content: locale
130
+ }))];
131
+ return head;
132
+ };
133
+ /** `useLocaleHead()` — reactive head attributes for the active locale. */
134
+ const useLocaleHead = (options = {}) => {
135
+ const router = getRouter();
136
+ return computed(() => resolveLocaleHead(options, router));
137
+ };
138
+ /** Non-reactive head attributes, for `$localeHead()`. */
139
+ const getLocaleHead = (options = {}, router) => resolveLocaleHead(options, router);
140
+
141
+ //#endregion
142
+ export { createLocalePath, createLocaleRoute, createRouteBaseName, createSwitchLocalePath, defaultLocale, detectBrowserLocale, getActiveLocale, getCurrentFullPath, getLocaleHead, getRouter, localeCodes, localizeFullPath, strategy, useBrowserLocale, useCookieLocale, useLocaleHead, useLocalePath, useLocaleRoute, useRouteBaseName, useSwitchLocalePath };
143
+ //# sourceMappingURL=routing.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routing.mjs","names":[],"sources":["../../../src/runtime/routing.ts"],"sourcesContent":["import { internationalization, routing } from '@intlayer/config/built';\nimport {\n getHTMLTextDir,\n getLocalizedUrl,\n getPathWithoutLocale,\n} from '@intlayer/core/localization';\nimport { getCachedLocaleFromStorageClient } from '@intlayer/core/utils';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { computed, getCurrentInstance, type Ref, ref } from 'vue';\nimport { createIntlayerClient } from 'vue-intlayer';\nimport type { Router } from 'vue-router';\nimport type {\n I18nHeadMetaInfo,\n I18nHeadOptions,\n LocalePathFunction,\n LocaleRouteFunction,\n LocalizedRoute,\n RouteBaseNameFunction,\n RouteLocationGeneric,\n Strategies,\n SwitchLocalePathFunction,\n} from '../types';\n\nexport const defaultLocale = (internationalization?.defaultLocale ??\n 'en') as string;\nexport const localeCodes = (internationalization?.locales ?? [\n defaultLocale,\n]) as string[];\n\n/** Separator of localized route names generated by `nuxt-intlayer`. */\nconst ROUTE_NAME_SEPARATOR = '___';\n\n/** @nuxtjs/i18n strategy equivalent to intlayer's `routing.mode`. */\nexport const strategy: Strategies = (\n {\n 'prefix-all': 'prefix',\n 'prefix-no-default': 'prefix_except_default',\n 'no-prefix': 'no_prefix',\n 'search-params': 'no_prefix',\n } as const\n)[routing?.mode ?? 'prefix-no-default'];\n\n/** The active locale — intlayer's client singleton, readable anywhere. */\nexport const getActiveLocale = (): string =>\n (createIntlayerClient().locale.value as string | undefined) ?? defaultLocale;\n\n/** The first browser language matching a configured locale. */\nexport const detectBrowserLocale = (): string | undefined =>\n typeof navigator === 'undefined'\n ? undefined\n : navigator.languages\n .map(\n (language) =>\n localeCodes.find((code) => code === language) ??\n localeCodes.find((code) => code === language.split('-')[0])\n )\n .find((code) => code !== undefined);\n\n/** `useBrowserLocale()` — the browser locale among the configured ones. */\nexport const useBrowserLocale = (): string | null =>\n detectBrowserLocale() ?? null;\n\n/** `useCookieLocale()` — the locale persisted by intlayer, or `''`. */\nexport const useCookieLocale = (): Ref<string> =>\n ref(getCachedLocaleFromStorageClient() ?? '');\n\n/** The app router, when called from a component setup. */\nexport const getRouter = (): Router | undefined =>\n getCurrentInstance()?.appContext.config.globalProperties.$router as\n | Router\n | undefined;\n\n/** Current URL path (`/fr/about?tab=1#top`), from the router or `window`. */\nexport const getCurrentFullPath = (router: Router | undefined): string => {\n if (router) return router.currentRoute.value.fullPath;\n if (typeof window === 'undefined') return '/';\n const { pathname, search, hash } = window.location;\n return `${pathname}${search}${hash}`;\n};\n\nconst toSearch = (\n query: Exclude<RouteLocationGeneric, string>['query']\n): string => {\n if (!query) return '';\n\n const searchParams = new URLSearchParams();\n for (const [key, value] of Object.entries(query)) {\n for (const item of Array.isArray(value) ? value : [value]) {\n searchParams.append(key, String(item));\n }\n }\n\n const search = searchParams.toString();\n return search ? `?${search}` : '';\n};\n\n/**\n * Serialises a route argument to a path with query and hash. A named route\n * is resolved through the router when one is available.\n */\nconst toFullPath = (\n route: RouteLocationGeneric,\n router: Router | undefined\n): string => {\n if (typeof route === 'string') {\n return route.startsWith('/') ? route : `/${route}`;\n }\n\n if (!route.path && route.name && router?.hasRoute(route.name)) {\n return router.resolve({\n name: route.name,\n params: route.params,\n query: route.query,\n hash: route.hash,\n }).fullPath;\n }\n\n const path = route.path ?? `/${route.name ?? ''}`;\n const hash = route.hash\n ? route.hash.startsWith('#')\n ? route.hash\n : `#${route.hash}`\n : '';\n\n return `${path.startsWith('/') ? path : `/${path}`}${toSearch(route.query)}${hash}`;\n};\n\n/** Localizes a full path (query and hash kept) for `locale`. */\nexport const localizeFullPath = (fullPath: string, locale: string): string =>\n getLocalizedUrl(\n getPathWithoutLocale(fullPath),\n locale as LocalesValues\n ) as string;\n\n/** `localePath(route, locale?)` bound to a router. */\nexport const createLocalePath =\n (router: Router | undefined): LocalePathFunction =>\n (route, locale) =>\n localizeFullPath(toFullPath(route, router), locale ?? getActiveLocale());\n\n/** `switchLocalePath(locale)` bound to a router. */\nexport const createSwitchLocalePath =\n (router: Router | undefined): SwitchLocalePathFunction =>\n (locale) =>\n localizeFullPath(getCurrentFullPath(router), locale);\n\n/** `localeRoute(route, locale?)` bound to a router. */\nexport const createLocaleRoute = (\n router: Router | undefined\n): LocaleRouteFunction => {\n const localePath = createLocalePath(router);\n\n return (route, locale): LocalizedRoute => {\n const fullPath = localePath(route, locale);\n const path = fullPath.split(/[?#]/)[0] ?? fullPath;\n\n return typeof route === 'string'\n ? { path, fullPath }\n : { ...route, path, fullPath };\n };\n};\n\n/**\n * Route base name bound to a router: strips the locale from a route name\n * (`about___fr`) or path (`/fr/about`).\n */\nexport const createRouteBaseName =\n (router: Router | undefined): RouteBaseNameFunction =>\n (route) => {\n // A string without a leading slash is a route name, not a path.\n const name =\n typeof route === 'object'\n ? route.name\n : route && !route.startsWith('/')\n ? route\n : undefined;\n if (name) return name.split(ROUTE_NAME_SEPARATOR)[0];\n\n const path =\n typeof route === 'string'\n ? route\n : (route?.path ?? getCurrentFullPath(router));\n const basePath = getPathWithoutLocale(path.split(/[?#]/)[0] ?? path);\n\n return basePath.replace(/^\\//, '') || 'index';\n };\n\n/** `localePath(route, locale?)` — the localized path of a route. */\nexport const useLocalePath = (): LocalePathFunction =>\n createLocalePath(getRouter());\n\n/** `switchLocalePath(locale)` — the current route in another locale. */\nexport const useSwitchLocalePath = (): SwitchLocalePathFunction =>\n createSwitchLocalePath(getRouter());\n\n/** `localeRoute(route, locale?)` — a localized route object. */\nexport const useLocaleRoute = (): LocaleRouteFunction =>\n createLocaleRoute(getRouter());\n\n/** `getRouteBaseName(route?)` — a route name without its locale suffix. */\nexport const useRouteBaseName = (): RouteBaseNameFunction =>\n createRouteBaseName(getRouter());\n\n/** Resolves `html` attributes and SEO links for the active locale. */\nconst resolveLocaleHead = (\n { dir = true, lang = true, seo = true }: I18nHeadOptions,\n router: Router | undefined\n): I18nHeadMetaInfo => {\n const activeLocale = getActiveLocale();\n const head: I18nHeadMetaInfo = {\n htmlAttrs: {\n ...(lang ? { lang: activeLocale } : {}),\n ...(dir ? { dir: getHTMLTextDir(activeLocale as LocalesValues) } : {}),\n },\n };\n\n if (!seo) return head;\n\n const basePath = getPathWithoutLocale(\n getCurrentFullPath(router).split(/[?#]/)[0] ?? '/'\n );\n\n head.link = [\n ...localeCodes.map((locale) => ({\n rel: 'alternate',\n hreflang: locale,\n href: localizeFullPath(basePath, locale),\n })),\n {\n rel: 'alternate',\n hreflang: 'x-default',\n href: localizeFullPath(basePath, defaultLocale),\n },\n {\n rel: 'canonical',\n href: localizeFullPath(basePath, activeLocale),\n },\n ];\n head.meta = [\n { property: 'og:locale', content: activeLocale },\n ...localeCodes\n .filter((locale) => locale !== activeLocale)\n .map((locale) => ({ property: 'og:locale:alternate', content: locale })),\n ];\n\n return head;\n};\n\n/** `useLocaleHead()` — reactive head attributes for the active locale. */\nexport const useLocaleHead = (\n options: I18nHeadOptions = {}\n): Ref<I18nHeadMetaInfo> => {\n const router = getRouter();\n\n return computed(() => resolveLocaleHead(options, router));\n};\n\n/** Non-reactive head attributes, for `$localeHead()`. */\nexport const getLocaleHead = (\n options: I18nHeadOptions = {},\n router?: Router\n): I18nHeadMetaInfo => resolveLocaleHead(options, router);\n"],"mappings":"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"}
File without changes
@@ -0,0 +1,13 @@
1
+ //#region src/constants.d.ts
2
+ export declare const STRATEGY_PREFIX = "prefix";
3
+ export declare const STRATEGY_PREFIX_EXCEPT_DEFAULT = "prefix_except_default";
4
+ export declare const STRATEGY_PREFIX_AND_DEFAULT = "prefix_and_default";
5
+ export declare const STRATEGY_NO_PREFIX = "no_prefix";
6
+ export declare const STRATEGIES: {
7
+ readonly PREFIX: 'prefix';
8
+ readonly PREFIX_EXCEPT_DEFAULT: 'prefix_except_default';
9
+ readonly PREFIX_AND_DEFAULT: 'prefix_and_default';
10
+ readonly NO_PREFIX: 'no_prefix';
11
+ };
12
+ //#endregion
13
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","names":[],"sources":["../../src/constants.ts"],"mappings":";qBAAa;qBACA;qBACA;qBACA;qBAEA;WACX;WACA;WACA;WACA"}
@@ -0,0 +1,4 @@
1
+ import { STRATEGIES, STRATEGY_NO_PREFIX, STRATEGY_PREFIX, STRATEGY_PREFIX_AND_DEFAULT, STRATEGY_PREFIX_EXCEPT_DEFAULT } from "./constants.js";
2
+ import { ConfigLoader, Directions, I18nHeadMetaInfo, I18nHeadOptions, I18nRoute, LocaleHeadFunction, LocaleLoader, LocaleObject, LocalePathFunction, LocaleRouteFunction, LocaleType, LocalizedRoute, MetaAttrs, NuxtI18nOptions, RouteBaseNameFunction, RouteLocationGeneric, SetI18nParamsFunction, Strategies, SwitchLocalePathFunction } from "./types.js";
3
+ import nuxtjsI18nModule from "./module.js";
4
+ export { type ConfigLoader, type Directions, type I18nHeadMetaInfo, type I18nHeadOptions, type I18nRoute, type LocaleHeadFunction, type LocaleLoader, type LocaleObject, type LocalePathFunction, type LocaleRouteFunction, type LocaleType, type LocalizedRoute, type MetaAttrs, type NuxtI18nOptions, type RouteBaseNameFunction, type RouteLocationGeneric, STRATEGIES, STRATEGY_NO_PREFIX, STRATEGY_PREFIX, STRATEGY_PREFIX_AND_DEFAULT, STRATEGY_PREFIX_EXCEPT_DEFAULT, type SetI18nParamsFunction, type Strategies, type SwitchLocalePathFunction, nuxtjsI18nModule as default, nuxtjsI18nModule };
@@ -0,0 +1,28 @@
1
+ import { NuxtI18nOptions } from "./types.js";
2
+ import { NuxtModule } from "@nuxt/schema";
3
+ //#region src/module.d.ts
4
+ /**
5
+ * Nuxt module replacing `@nuxtjs/i18n` with intlayer.
6
+ *
7
+ * - installs `nuxt-intlayer` (dictionaries, locale routing, Vite plugin) with
8
+ * the `useI18n` caller, so `useI18n({ namespace })` call sites are
9
+ * rewritten to import only their dictionary;
10
+ * - aliases `#i18n` and auto-imports the @nuxtjs/i18n composables;
11
+ * - registers `<NuxtLinkLocale>` and the plugin providing `$t`,
12
+ * `$localePath`, `$switchLocalePath`…
13
+ *
14
+ * Locales, default locale and routing come from `intlayer.config.ts`; the
15
+ * `i18n` key of `nuxt.config` is accepted for migration and ignored.
16
+ *
17
+ * @example
18
+ * ```ts
19
+ * // nuxt.config.ts
20
+ * export default defineNuxtConfig({
21
+ * modules: ['@intlayer/nuxtjs-i18n'],
22
+ * });
23
+ * ```
24
+ */
25
+ export declare const nuxtjsI18nModule: NuxtModule<NuxtI18nOptions>;
26
+ //#endregion
27
+ export { nuxtjsI18nModule as default };
28
+ //# sourceMappingURL=module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.d.ts","names":[],"sources":["../../src/module.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;qBAyDa,kBAAkB,WAAW"}
@@ -0,0 +1,42 @@
1
+ import { RouteLocationGeneric } from "../types.js";
2
+ import { PropType } from "vue";
3
+ //#region src/runtime/NuxtLinkLocale.d.ts
4
+ /**
5
+ * `<NuxtLinkLocale to="/about" locale="fr">` — a `<NuxtLink>` whose target
6
+ * is localized for the active (or given) locale.
7
+ */
8
+ export declare const NuxtLinkLocale: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
9
+ to: {
10
+ type: PropType<RouteLocationGeneric>;
11
+ default: any;
12
+ };
13
+ href: {
14
+ type: PropType<RouteLocationGeneric>;
15
+ default: any;
16
+ };
17
+ locale: {
18
+ type: StringConstructor;
19
+ default: any;
20
+ };
21
+ }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
22
+ [key: string]: any;
23
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
24
+ to: {
25
+ type: PropType<RouteLocationGeneric>;
26
+ default: any;
27
+ };
28
+ href: {
29
+ type: PropType<RouteLocationGeneric>;
30
+ default: any;
31
+ };
32
+ locale: {
33
+ type: StringConstructor;
34
+ default: any;
35
+ };
36
+ }>> & Readonly<{}>, {
37
+ to: RouteLocationGeneric;
38
+ href: RouteLocationGeneric;
39
+ locale: string;
40
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
41
+ //#endregion
42
+ //# sourceMappingURL=NuxtLinkLocale.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NuxtLinkLocale.d.ts","names":[],"sources":["../../../src/runtime/NuxtLinkLocale.ts"],"mappings":";;;;;;;qBASa,8BAAc,8BAAA;;IAKK,MAAA,SAAS;;;;IAIT,MAAA,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;qCAsBvC"}
@@ -0,0 +1,66 @@
1
+ import { LocaleObject, Strategies } from "../types.js";
2
+ import { ComputedRef } from "vue";
3
+ import { Dictionary } from "@intlayer/types/dictionary";
4
+ import { DictionaryKeys, StrictModeLocaleMap } from "@intlayer/types/module_augmentation";
5
+ import { LooseComposer, ScopedComposer, TypedComposer } from "@intlayer/vue-i18n";
6
+ //#region src/runtime/composer.d.ts
7
+ /** What @nuxtjs/i18n adds to vue-i18n's composer. */
8
+ export type NuxtI18nComposerExtras = {
9
+ locales: ComputedRef<LocaleObject[]>;
10
+ localeCodes: ComputedRef<string[]>;
11
+ localeProperties: ComputedRef<LocaleObject>;
12
+ defaultLocale: string;
13
+ strategy: Strategies;
14
+ /** Activates a locale, persists it and navigates to the localized route. */
15
+ setLocale: (locale: string) => Promise<void>;
16
+ getBrowserLocale: () => string | undefined;
17
+ getLocaleCookie: () => string | undefined;
18
+ setLocaleCookie: (locale: string) => void;
19
+ /** Kept for API parity: locale switches are never deferred. */
20
+ finalizePendingLocaleChange: () => Promise<void>;
21
+ /** Kept for API parity: locale switches are never deferred. */
22
+ waitForPendingLocaleChange: () => Promise<void>;
23
+ /** Kept for API parity: intlayer dictionaries need no loading. */
24
+ loadLocaleMessages: (locale: string) => Promise<void>;
25
+ };
26
+ /** The @nuxtjs/i18n locale object describing a locale code. */
27
+ export declare const toLocaleObject: (code: string) => LocaleObject;
28
+ type ComposerOptions = Record<string, unknown>;
29
+ type NuxtUseI18n = {
30
+ <N extends DictionaryKeys>(options: ComposerOptions & {
31
+ namespace: N;
32
+ }): TypedComposer<N> & NuxtI18nComposerExtras;
33
+ (options?: ComposerOptions & {
34
+ namespace?: undefined;
35
+ }): LooseComposer & NuxtI18nComposerExtras;
36
+ };
37
+ type NuxtUseDictionary = {
38
+ <T extends Dictionary>(dictionary: T, options?: ComposerOptions & {
39
+ namespace?: undefined;
40
+ }): TypedComposer<T['key'] & DictionaryKeys> & NuxtI18nComposerExtras;
41
+ <T extends Dictionary, Prefix extends string>(dictionary: T, options: ComposerOptions & {
42
+ namespace: Prefix;
43
+ }): ScopedComposer<T['key'] & DictionaryKeys, Prefix> & NuxtI18nComposerExtras;
44
+ };
45
+ type NuxtUseDictionaryDynamic = {
46
+ <T extends Dictionary, K extends DictionaryKeys>(dictionaryLoaders: StrictModeLocaleMap<() => Promise<T>>, key: K, options?: ComposerOptions & {
47
+ namespace?: undefined;
48
+ }): TypedComposer<K> & NuxtI18nComposerExtras;
49
+ <T extends Dictionary, K extends DictionaryKeys, Prefix extends string>(dictionaryLoaders: StrictModeLocaleMap<() => Promise<T>>, key: K, options: ComposerOptions & {
50
+ namespace: Prefix;
51
+ }): ScopedComposer<K, Prefix> & NuxtI18nComposerExtras;
52
+ };
53
+ /**
54
+ * `useI18n()` of @nuxtjs/i18n: vue-i18n's composer (backed by intlayer
55
+ * dictionaries) plus the Nuxt locale helpers.
56
+ */
57
+ export declare const useI18n: NuxtUseI18n;
58
+ /**
59
+ * Build-optimized `useI18n({ namespace })`: the optimize pass rewrites the
60
+ * call to pass the dictionary, so only it reaches the bundle.
61
+ */
62
+ export declare const useDictionary: NuxtUseDictionary;
63
+ /** Per-locale lazy variant of {@link useDictionary}. */
64
+ export declare const useDictionaryDynamic: NuxtUseDictionaryDynamic;
65
+ //#endregion
66
+ //# sourceMappingURL=composer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"composer.d.ts","names":[],"sources":["../../../src/runtime/composer.ts"],"mappings":";;;;;;;YAmCY;EACV,SAAS,YAAY;EACrB,aAAa;EACb,kBAAkB,YAAY;EAC9B;EACA,UAAU;;EAEV,YAAY,mBAAmB;EAC/B;EACA;EACA,kBAAkB;;EAElB,mCAAmC;;EAEnC,kCAAkC;;EAElC,qBAAqB,mBAAmB;;;qBAI7B,iBAAc,iBAAmB;KA+CzC,kBAAkB;KAElB;GACF,UAAU,gBACT,SAAS;IAAoB,WAAW;MACvC,cAAc,KAAK;GAEpB,UAAU;IAAoB;MAC7B,gBAAgB;;KAGhB;GACF,UAAU,YACT,YAAY,GACZ,UAAU;IAAoB;MAC7B,cAAc,WAAW,kBAAkB;GAC7C,UAAU,YAAY,uBACrB,YAAY,GACZ,SAAS;IAAoB,WAAW;MACvC,eAAe,WAAW,gBAAgB,UAAU;;KAGpD;GACF,UAAU,YAAY,UAAU,gBAC/B,mBAAmB,0BAA0B,QAAQ,KACrD,KAAK,GACL,UAAU;IAAoB;MAC7B,cAAc,KAAK;GACrB,UAAU,YAAY,UAAU,gBAAgB,uBAC/C,mBAAmB,0BAA0B,QAAQ,KACrD,KAAK,GACL,SAAS;IAAoB,WAAW;MACvC,eAAe,GAAG,UAAU;;;;;;qBAOpB,SAGN;;;;;qBAMM,eAMN;;qBAGM,sBAON"}
@@ -0,0 +1,23 @@
1
+ import { ConfigLoader, I18nRoute, LocaleLoader, SetI18nParamsFunction } from "../types.js";
2
+ import { I18nOptions } from "vue-i18n";
3
+ //#region src/runtime/define.d.ts
4
+ /**
5
+ * Identity helper for `i18n.config.ts`. Kept for migration: message catalogs
6
+ * move to intlayer dictionaries, so the returned config is never loaded.
7
+ */
8
+ export declare const defineI18nConfig: <Config extends I18nOptions>(config: ConfigLoader<Config>) => ConfigLoader<Config>;
9
+ /** Identity helper for lazy locale files; intlayer bundles dictionaries. */
10
+ export declare const defineI18nLocale: <Messages = Record<string, unknown>>(loader: LocaleLoader<Messages>) => LocaleLoader<Messages>;
11
+ /** Identity helper for locale detectors; intlayer's middleware detects. */
12
+ export declare const defineI18nLocaleDetector: <Detector extends (...args: never[]) => string>(detector: Detector) => Detector;
13
+ /**
14
+ * Page route options. Localized paths come from intlayer's
15
+ * `routing.rewrite` rules, so this is a no-op kept for migration.
16
+ */
17
+ export declare const defineI18nRoute: (_route: I18nRoute | false) => void;
18
+ /** Dynamic route params per locale; unused with intlayer's routing. */
19
+ export declare const useSetI18nParams: () => SetI18nParamsFunction;
20
+ /** Preload hint for message keys; dictionaries are already bundled. */
21
+ export declare const useI18nPreloadKeys: (_keys: string[]) => void;
22
+ //#endregion
23
+ //# sourceMappingURL=define.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define.d.ts","names":[],"sources":["../../../src/runtime/define.ts"],"mappings":";;;;;;;qBAYa,mBAAoB,eAAe,aAAW,QACjD,aAAa,YACpB,aAAa;;qBAGH,mBAAoB,WAAW,yBAAuB,QACzD,aAAa,cACpB,aAAa;;qBAGH,2BACX,qBAAqB,0BAAwB,UAEnC,aACT;;;;;qBAMU,kBAAe,QAAY;;qBAG3B,wBAAuB;;qBAGvB,qBAAkB"}
@@ -0,0 +1,6 @@
1
+ import { STRATEGIES, STRATEGY_NO_PREFIX, STRATEGY_PREFIX, STRATEGY_PREFIX_AND_DEFAULT, STRATEGY_PREFIX_EXCEPT_DEFAULT } from "../constants.js";
2
+ import { NuxtLinkLocale } from "./NuxtLinkLocale.js";
3
+ import { NuxtI18nComposerExtras, useDictionary, useDictionaryDynamic, useI18n } from "./composer.js";
4
+ import { defineI18nConfig, defineI18nLocale, defineI18nLocaleDetector, defineI18nRoute, useI18nPreloadKeys, useSetI18nParams } from "./define.js";
5
+ import { useBrowserLocale, useCookieLocale, useLocaleHead, useLocalePath, useLocaleRoute, useRouteBaseName, useSwitchLocalePath } from "./routing.js";
6
+ export { type NuxtI18nComposerExtras, NuxtLinkLocale, STRATEGIES, STRATEGY_NO_PREFIX, STRATEGY_PREFIX, STRATEGY_PREFIX_AND_DEFAULT, STRATEGY_PREFIX_EXCEPT_DEFAULT, defineI18nConfig, defineI18nLocale, defineI18nLocaleDetector, defineI18nRoute, useBrowserLocale, useCookieLocale, useDictionary, useDictionaryDynamic, useI18n, useI18nPreloadKeys, useLocaleHead, useLocalePath, useLocaleRoute, useRouteBaseName, useSetI18nParams, useSwitchLocalePath };
@@ -0,0 +1,12 @@
1
+ //#region src/runtime/nuxtPlugin.d.ts
2
+ /**
3
+ * Installs vue-i18n's globals (`$t`, `$d`, `$n`, `v-t`…) and the
4
+ * @nuxtjs/i18n helpers (`$localePath`, `$switchLocalePath`…) on the app.
5
+ *
6
+ * Registered after `nuxt-intlayer`'s plugin, which installs the intlayer
7
+ * client every helper reads the locale from.
8
+ */
9
+ declare const _default: any;
10
+ //#endregion
11
+ export { _default as default };
12
+ //# sourceMappingURL=nuxtPlugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nuxtPlugin.d.ts","names":[],"sources":["../../../src/runtime/nuxtPlugin.ts"],"mappings":";;;;;;;;cAYA"}
@@ -0,0 +1,8 @@
1
+ //#region src/runtime/nuxtVirtualModules.d.ts
2
+ /** Nuxt virtual modules, typed by the application's generated `.nuxt` types. */
3
+ declare module '#components' {
4
+ import type { Component } from 'vue';
5
+ export const NuxtLink: Component;
6
+ }
7
+ export {};
8
+ //# sourceMappingURL=nuxtVirtualModules.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nuxtVirtualModules.d.ts","names":[],"sources":["../../../src/runtime/nuxtVirtualModules.d.ts"],"mappings":";;;gBAEgB;eAED,UAAU"}
@@ -0,0 +1,47 @@
1
+ import { I18nHeadMetaInfo, I18nHeadOptions, LocalePathFunction, LocaleRouteFunction, RouteBaseNameFunction, Strategies, SwitchLocalePathFunction } from "../types.js";
2
+ import { Ref } from "vue";
3
+ import { Router } from "vue-router";
4
+ //#region src/runtime/routing.d.ts
5
+ export declare const defaultLocale: string;
6
+ export declare const localeCodes: string[];
7
+ /** @nuxtjs/i18n strategy equivalent to intlayer's `routing.mode`. */
8
+ export declare const strategy: Strategies;
9
+ /** The active locale — intlayer's client singleton, readable anywhere. */
10
+ export declare const getActiveLocale: () => string;
11
+ /** The first browser language matching a configured locale. */
12
+ export declare const detectBrowserLocale: () => string | undefined;
13
+ /** `useBrowserLocale()` — the browser locale among the configured ones. */
14
+ export declare const useBrowserLocale: () => string | null;
15
+ /** `useCookieLocale()` — the locale persisted by intlayer, or `''`. */
16
+ export declare const useCookieLocale: () => Ref<string>;
17
+ /** The app router, when called from a component setup. */
18
+ export declare const getRouter: () => Router | undefined;
19
+ /** Current URL path (`/fr/about?tab=1#top`), from the router or `window`. */
20
+ export declare const getCurrentFullPath: (router: Router | undefined) => string;
21
+ /** Localizes a full path (query and hash kept) for `locale`. */
22
+ export declare const localizeFullPath: (fullPath: string, locale: string) => string;
23
+ /** `localePath(route, locale?)` bound to a router. */
24
+ export declare const createLocalePath: (router: Router | undefined) => LocalePathFunction;
25
+ /** `switchLocalePath(locale)` bound to a router. */
26
+ export declare const createSwitchLocalePath: (router: Router | undefined) => SwitchLocalePathFunction;
27
+ /** `localeRoute(route, locale?)` bound to a router. */
28
+ export declare const createLocaleRoute: (router: Router | undefined) => LocaleRouteFunction;
29
+ /**
30
+ * Route base name bound to a router: strips the locale from a route name
31
+ * (`about___fr`) or path (`/fr/about`).
32
+ */
33
+ export declare const createRouteBaseName: (router: Router | undefined) => RouteBaseNameFunction;
34
+ /** `localePath(route, locale?)` — the localized path of a route. */
35
+ export declare const useLocalePath: () => LocalePathFunction;
36
+ /** `switchLocalePath(locale)` — the current route in another locale. */
37
+ export declare const useSwitchLocalePath: () => SwitchLocalePathFunction;
38
+ /** `localeRoute(route, locale?)` — a localized route object. */
39
+ export declare const useLocaleRoute: () => LocaleRouteFunction;
40
+ /** `getRouteBaseName(route?)` — a route name without its locale suffix. */
41
+ export declare const useRouteBaseName: () => RouteBaseNameFunction;
42
+ /** `useLocaleHead()` — reactive head attributes for the active locale. */
43
+ export declare const useLocaleHead: (options?: I18nHeadOptions) => Ref<I18nHeadMetaInfo>;
44
+ /** Non-reactive head attributes, for `$localeHead()`. */
45
+ export declare const getLocaleHead: (options?: I18nHeadOptions, router?: Router) => I18nHeadMetaInfo;
46
+ //#endregion
47
+ //# sourceMappingURL=routing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routing.d.ts","names":[],"sources":["../../../src/runtime/routing.ts"],"mappings":";;;;qBAuBa;qBAEA;;qBAQA,UAAU;;qBAUV;;qBAIA;;qBAYA;;qBAIA,uBAAsB;;qBAItB,iBAAgB;;qBAMhB,qBAAkB,QAAY;;qBAuD9B,mBAAgB,kBAAoB;;qBAOpC,mBAAgB,QAClB,uBAAqB;;qBAKnB,yBAAsB,QACxB,uBAAqB;;qBAKnB,oBAAiB,QACpB,uBACP;;;;;qBAiBU,sBAAmB,QACrB,uBAAqB;;qBAqBnB,qBAAoB;;qBAIpB,2BAA0B;;qBAI1B,sBAAqB;;qBAIrB,wBAAuB;;qBAiDvB,gBAAa,UACf,oBACR,IAAI;;qBAOM,gBAAa,UACf,iBAAe,SACf,WACR"}
@@ -0,0 +1,82 @@
1
+ import { I18nOptions } from "vue-i18n";
2
+ //#region src/types.d.ts
3
+ export type Strategies = 'prefix' | 'prefix_except_default' | 'prefix_and_default' | 'no_prefix';
4
+ export type Directions = 'ltr' | 'rtl' | 'auto';
5
+ export type LocaleObject<T extends string = string> = {
6
+ code: T;
7
+ name?: string;
8
+ dir?: Directions;
9
+ domain?: string;
10
+ file?: string;
11
+ files?: string[];
12
+ isCatchallLocale?: boolean;
13
+ language?: string;
14
+ /** @deprecated Use `language`. */
15
+ iso?: string;
16
+ };
17
+ export type LocaleType = string | LocaleObject;
18
+ /** Page-level route options of `defineI18nRoute()`. */
19
+ export type I18nRoute = {
20
+ paths?: Partial<Record<string, `/${string}`>>;
21
+ locales?: string[];
22
+ };
23
+ export type I18nHeadOptions = {
24
+ dir?: boolean;
25
+ lang?: boolean;
26
+ seo?: boolean | {
27
+ canonicalQueries?: string[];
28
+ };
29
+ };
30
+ export type MetaAttrs = Record<string, string | undefined>;
31
+ export type I18nHeadMetaInfo = {
32
+ htmlAttrs?: MetaAttrs;
33
+ link?: MetaAttrs[];
34
+ meta?: MetaAttrs[];
35
+ };
36
+ /** A route as accepted by the localization helpers. */
37
+ export type RouteLocationGeneric = string | {
38
+ name?: string;
39
+ path?: string;
40
+ query?: Record<string, string | number | (string | number)[]>;
41
+ hash?: string;
42
+ params?: Record<string, string | string[]>;
43
+ };
44
+ /** A route object returned by `localeRoute()`. */
45
+ export type LocalizedRoute = {
46
+ path: string;
47
+ fullPath: string;
48
+ name?: string;
49
+ query?: Record<string, string | number | (string | number)[]>;
50
+ hash?: string;
51
+ params?: Record<string, string | string[]>;
52
+ };
53
+ export type LocalePathFunction = (route: RouteLocationGeneric, locale?: string) => string;
54
+ export type SwitchLocalePathFunction = (locale: string) => string;
55
+ export type LocaleRouteFunction = (route: RouteLocationGeneric, locale?: string) => LocalizedRoute;
56
+ export type RouteBaseNameFunction = (route?: RouteLocationGeneric) => string | undefined;
57
+ export type LocaleHeadFunction = (options?: I18nHeadOptions) => I18nHeadMetaInfo;
58
+ export type SetI18nParamsFunction = (params: Record<string, Record<string, string | string[]>>) => void;
59
+ export type LocaleLoader<Messages = Record<string, unknown>> = (locale: string) => Messages | Promise<Messages>;
60
+ export type ConfigLoader<Config extends I18nOptions = I18nOptions> = () => Config | Promise<Config>;
61
+ /**
62
+ * `i18n` options of `nuxt.config`. Intlayer's configuration owns locales,
63
+ * default locale and routing; these are accepted for migration and ignored.
64
+ */
65
+ export type NuxtI18nOptions = {
66
+ defaultLocale?: string;
67
+ locales?: LocaleType[];
68
+ strategy?: Strategies;
69
+ lazy?: boolean;
70
+ langDir?: string;
71
+ rootRedirect?: string | null;
72
+ vueI18n?: string;
73
+ detectBrowserLanguage?: {
74
+ alwaysRedirect?: boolean;
75
+ cookieKey?: string;
76
+ fallbackLocale?: string | null;
77
+ redirectOn?: 'all' | 'root' | 'no prefix';
78
+ useCookie?: boolean;
79
+ } | false;
80
+ };
81
+ //#endregion
82
+ //# sourceMappingURL=types.d.ts.map