Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vue-i18n-routing

Package Overview
Dependencies
Maintainers
1
Versions
239
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-i18n-routing - npm Package Compare versions

Comparing version 0.0.0-2adf43f to 0.0.0-2b5973f

dist/vue-i18n-routing.js

599

dist/vue-i18n-routing.d.ts

@@ -1,9 +0,13 @@

import { Composer } from '@intlify/vue-i18n-bridge';
import type { Composer } from '@intlify/vue-i18n-bridge';
import { EffectScope } from 'vue-demi';
import type { ExportedGlobalComposer } from '@intlify/vue-i18n-bridge';
import type { I18n } from '@intlify/vue-i18n-bridge';
import type { Locale } from '@intlify/vue-i18n-bridge';
import type { RawLocation } from '@intlify/vue-router-bridge';
import type { Route as Route_2 } from '@intlify/vue-router-bridge';
import type { Ref } from 'vue-demi';
import { Route } from '@intlify/vue-router-bridge';
import type { RouteConfig } from '@intlify/vue-router-bridge';
import type { RouteLocation } from '@intlify/vue-router-bridge';
import type { RouteLocationNormalizedLoaded } from '@intlify/vue-router-bridge';
import { RouteLocationNormalized } from '@intlify/vue-router-bridge';
import { RouteLocationNormalizedLoaded } from '@intlify/vue-router-bridge';
import type { RouteLocationRaw } from '@intlify/vue-router-bridge';

@@ -14,6 +18,40 @@ import type { Router } from '@intlify/vue-router-bridge';

import { useRouter } from '@intlify/vue-router-bridge';
import type { VueI18n } from '@intlify/vue-i18n-bridge';
import type { VueRouter } from '@intlify/vue-router-bridge';
export declare type BaseUrlResolveHandler = (context: unknown) => string;
export declare type BaseUrlResolveHandler<Context = unknown> = (context: Context) => string;
/**
* The browser locale info
*
* @remarks
* This type is used by {@link FindBrowserLocaleOptions#sorter | sorter} in {@link findBrowserLocale} function
*/
export declare type BrowserLocale = {
/**
* The locale code, such as BCP 47 (e.g `en-US`), or `ja`
*/
code: string;
/**
* The score number
*
* @remarks
* The score number that is used by `sorter` of {@link FindBrowserLocaleOptions}
*/
score: number;
};
/**
* The browser locale matcher
*
* @remarks
* This matcher is used by {@link findBrowserLocale} function
*
* @param locales - The target {@link LocaleObject | locale} list
* @param browserLocales - The locale code list that is used in browser
*
* @returns The matched {@link BrowserLocale | locale info}
*/
export declare type BrowserLocaleMatcher = (locales: TargetLocale[], browserLocales: string[]) => BrowserLocale[];
export declare type ComposableOptions = {

@@ -26,6 +64,19 @@ route?: ReturnType<typeof useRoute>;

/**
* Options to compute route localizing
*
* @remarks
* The route options that is compute the route to be localized on {@link localizeRoutes}
*/
export declare type ComputedRouteOptions = {
locales: readonly string[];
paths: Record<string, string>;
};
export declare function createLocaleFromRouteGetter(localeCodes: string[], routesNameSeparator: string, defaultLocaleRouteNameSuffix: string): (route: Route | RouteLocationNormalizedLoaded | RouteLocationNormalized | string) => string;
/**
* Create a Vue Router instance
*
* @param i18n - A Vue I18n instance, see [Vue I18n API docs](https://vue-i18n.intlify.dev/api/general.html#i18n)
* @param options - An options, see {@link VueI18nRoutingOptions}
* @param options - An options, see {@link I18nRoutingOptions}
*

@@ -40,5 +91,21 @@ * @returns A Vue Router instance

* At the Vue 2 will return a [Vue Router v3 instance](https://router.vuejs.org/api/#router-construction-options), and at the Vue 3 will return a [Vue Router v4 instance](https://next.router.vuejs.org/api/#createrouter).
*
* @public
*/
export declare function createRouter<Options extends VueI18nRoutingOptions = VueI18nRoutingOptions>(i18n: I18n, options?: Options): Options['version'] extends 4 ? Router : VueRouter;
export declare function createRouter<Options extends I18nRoutingOptions = I18nRoutingOptions>(i18n: I18n, options?: Options): Options['version'] extends 4 ? Router : VueRouter;
export declare const DEFAULT_BASE_URL = "";
export declare const DEFAULT_DETECTION_DIRECTION = "ltr";
export declare const DEFAULT_LOCALE = "";
export declare const DEFAULT_LOCALE_ROUTE_NAME_SUFFIX = "default";
export declare const DEFAULT_ROUTES_NAME_SEPARATOR = "___";
export declare const DEFAULT_STRATEGY: "prefix_except_default";
export declare const DEFAULT_TRAILING_SLASH = false;
/**

@@ -49,13 +116,70 @@ * Direction

export declare type ExtendComposerHook = (compser: Composer) => void;
export declare type ExtendExportedGlobalHook = (global: Composer) => ExtendProperyDescripters;
export declare interface ExtendHooks {
onExtendComposer?: ExtendComposerHook;
onExtendExportedGlobal?: ExtendExportedGlobalHook;
onExtendVueI18n?: ExtendVueI18nHook;
}
export declare function extendI18n<TI18n extends I18n>(i18n: TI18n, { locales, localeCodes, baseUrl, hooks }?: VueI18nExtendOptions): EffectScope;
export declare type ExtendProperyDescripters = {
[key: string]: Pick<PropertyDescriptor, 'get'>;
};
export declare type ExtendVueI18nHook = (composer: Composer) => ExtendProperyDescripters;
/**
* Get route base name
* Find the browser locale
*
* @param givenRoute - A route object, if not provided, the route is returned with `useRoute` will be used
* @param routesNameSeparator - A route name separator, if not provided, default separator is `routesNameSeparator` option of {@link VueI18nRoutingOptions} will be used
* @param locales - The target {@link LocaleObject | locale} list
* @param browserLocales - The locale code list that is used in browser
* @param options - The options for {@link findBrowserLocale} function
*
* @returns The route base name, if route name is not defined, return null
* @returns The matched the locale code
*/
export declare function getRouteBaseName(givenRoute?: Route_2 | RouteLocationNormalizedLoaded, routesNameSeparator?: string): string | null;
export declare function findBrowserLocale(locales: LocaleObject[], browserLocales: string[], { matcher, comparer }?: FindBrowserLocaleOptions): string | '';
/**
* The options for {@link findBrowserLocale} function
*/
export declare type FindBrowserLocaleOptions = {
matcher?: BrowserLocaleMatcher;
comparer?: (a: BrowserLocale, b: BrowserLocale) => number;
};
/**
* Get global i18n routing options
*
* @param router - A router instance, about router type
*
* @returns - {@link I18nRoutingGlobalOptions | global options} from i18n routing options registory, if registered, return it, else empty object
*/
export declare function getGlobalOptions(router: Router | VueRouter): I18nRoutingGlobalOptions;
/**
* Get a locale
*
* @param i18n - An [I18n](https://vue-i18n.intlify.dev/api/general.html#i18n) instance or a [Composer](https://vue-i18n.intlify.dev/api/composition.html#composer) instance
*
* @returns A locale
*/
export declare function getLocale(i18n: I18n | Composer | VueI18n): Locale;
export declare function getLocaleCodes(i18n: I18n | VueI18n | Composer): string[];
export declare function getLocales(i18n: I18n | VueI18n | Composer): string[] | LocaleObject[];
export declare function getLocalesRegex(localeCodes: string[]): RegExp;
export declare function getRouteBaseName(this: RoutingProxy, givenRoute?: Route | RouteLocationNormalizedLoaded): string | undefined;
export declare type I18nCommonRoutingOptions = Pick<I18nRoutingOptions, 'defaultLocale' | 'strategy' | 'defaultLocaleRouteNameSuffix' | 'trailingSlash' | 'locales' | 'routesNameSeparator'>;
export declare type I18nCommonRoutingOptionsWithComposable = I18nCommonRoutingOptions & ComposableOptions;
/**
* I18n header meta info

@@ -65,8 +189,8 @@ */

htmlAttrs?: MetaAttrs;
meta?: MetaAttrs;
link?: MetaAttrs;
meta?: MetaAttrs[];
link?: MetaAttrs[];
}
/**
* Options for {@link useI18nHead} function
* Options for {@link localeHead} function
*/

@@ -89,17 +213,140 @@ export declare interface I18nHeadOptions {

/**
* Options for vue-i18n-routing common
* Route config for vue-i18n-routing
*/
export declare type I18nRoutingOptions = Pick<VueI18nRoutingOptions, 'defaultLocale' | 'strategy' | 'defaultLocaleRouteNameSuffix' | 'trailingSlash' | 'locales' | 'routesNameSeparator'> & ComposableOptions;
export declare type I18nRoute = Route_2 & RouteLegacy & {
redirect?: string;
};
/**
* Resolve locale location
* Global options for i18n routing
*/
export declare type I18nRoutingGlobalOptions<BaseUrl extends BaseUrlResolveHandler = BaseUrlResolveHandler> = Pick<I18nRoutingOptions<BaseUrl>, 'defaultLocale' | 'defaultDirection' | 'defaultLocaleRouteNameSuffix' | 'trailingSlash' | 'routesNameSeparator' | 'strategy'> & {
localeCodes?: string[];
};
/**
* Options to initialize a VueRouter instance
*
* @remarks
* This options is extended from Vue Router `RouterOptioins`, so you can specify those options.
*/
export declare type I18nRoutingOptions<BaseUrl extends BaseUrlResolveHandler = BaseUrlResolveHandler> = {
/**
* Vue Router version
*
* @remarks
* You can choice between vue-router v3 and v4.
*
* If you specify `3`, this function return Vue Router v3 instance, else specify `4`, this function return Vue Router v4 instance.
*
* @defaultValue 4
*/
version?: 3 | 4;
/**
* The app's default locale
*
* @remarks
* When using `prefix_except_default` strategy, URLs for locale specified here won't have a prefix.
*
* It's recommended to set this to some locale regardless of chosen strategy, as it will be used as a fallback locale when navigating to a non-existent route
*
* @defaultValue '' (emputy string)
*/
defaultLocale?: string;
/**
* List of locales supported by your app
*
* @remarks
* Can either be an array of string codes (e.g. `['en', 'fr']`) or an array of {@link LocaleObject} for more complex configurations
*
* @defaultValue []
*/
locales?: string[] | LocaleObject[];
/**
* Routes strategy
*
* @remarks
* Can be set to one of the following:
*
* - `no_prefix`: routes won't have a locale prefix
* - `prefix_except_default`: locale prefix added for every locale except default
* - `prefix`: locale prefix added for every locale
* - `prefix_and_default`: locale prefix added for every locale and default
*
* @defaultValue 'prefix_except_default'
*/
strategy?: Strategies;
/**
* Whether to use trailing slash
*
* @defaultValue false
*/
trailingSlash?: boolean;
/**
* Internal separator used for generated route names for each locale. You shouldn't need to change this
*
* @defaultValue '___'
*/
routesNameSeparator?: string;
/**
* Internal suffix added to generated route names for default locale
*
* @remarks
* if strategy is prefix_and_default. You shouldn't need to change this.
*
* @defaultValue 'default'
*/
defaultLocaleRouteNameSuffix?: string;
/**
* Default direction direction
*
* @defaultValue 'ltr'
*/
defaultDirection?: Directions;
/**
* The fallback base URL to use as a prefix for alternate URLs in hreflang tags.
*
* @remarks
* By default VueRouter's base URL will be used and only if that is not available, fallback URL will be used.
*
* Can also be a function (will be passed a Nuxt Context as a parameter) that returns a string.
*
* Useful to make base URL dynamic based on request headers.
*
* @defaultValue ''
*/
baseUrl?: string | BaseUrl;
/**
* Route options resolver
*
* @defaultValue undefined
*/
routeOptionsResolver?: RouteOptionsResolver;
} & RouterOptions;
export declare function isComposer(target: any): target is Composer;
export declare function isExportedGlobalComposer(target: any): target is ExportedGlobalComposer;
export declare function isI18nInstance(i18n: any): i18n is I18n;
export declare function isLegacyVueI18n(target: any): target is Pick<VueI18n, 'locale'>;
export declare function isVueI18n(target: any): target is VueI18n;
export declare function localeHead(this: RoutingProxy, { addDirAttribute, addSeoAttributes }?: I18nHeadOptions): I18nHeadMetaInfo;
export declare function localeLocation(this: RoutingProxy, route: RawLocation | RouteLocationRaw, locale?: Locale): Location | RouteLocation | undefined;
/**
* Resolve locale location function
*
* @param route - A route location. The path or name of the route or an object for more complex routes
* @param locale - A locale code, if not specified, uses the current locale
* @param options - An options, see about details {@link I18nRoutingOptions}
*
* @returns Returns the location object for a given route, the location object is resolved by vue-router rather than just a full route path.
*
* @see {@link useLocaleLocation}
*/
export declare function localeLocation(route: RawLocation | RouteLocationRaw, locale?: Locale, // TODO: locale should be more type inference (completion)
options?: I18nRoutingOptions): Location | RouteLocation | undefined;
export declare type LocaleLocationFunction = (route: RawLocation | RouteLocationRaw, locale?: Locale) => Location | RouteLocation | undefined;

@@ -119,44 +366,83 @@ /**

export declare function localePath(this: RoutingProxy, route: RawLocation | RouteLocationRaw, locale?: Locale): string;
/**
* Resolve locale path
* Resolve locale path function
*
* @param route - A route location. The path or name of the route or an object for more complex routes
* @param locale - A locale code, if not specified, uses the current locale
* @param options - An options, see about details {@link I18nRoutingOptions}
*
* @returns Returns the localized URL for a given route
*
* @see {@link useLocalePath}
*/
export declare function localePath(route: RawLocation | RouteLocationRaw, locale?: Locale, // TODO: locale should be more type inference (completion)
options?: I18nRoutingOptions): string;
export declare type LocalePathFunction = (route: RawLocation | RouteLocation, locale?: Locale) => string;
export declare function localeRoute(this: RoutingProxy, route: RawLocation | RouteLocationRaw, locale?: Locale): Route | ReturnType<Router['resolve']> | undefined;
/**
* Resolve locale route
* Resolve route fucntion
*
* @param route - A route location. The path or name of the route or an object for more complex routes
* @param locale - A locale code, if not specified, uses the current locale
* @param options - An options, see about details {@link I18nRoutingOptions}
*
* @returns Returns the route object for a given route, the route object is resolved by vue-router rather than just a full route path.
*
* @see {@link useLocaleRoute}
*/
export declare function localeRoute(route: RawLocation | RouteLocationRaw, locale?: Locale, // TODO: locale should be more type inference (completion)
options?: I18nRoutingOptions): Route_2 | ReturnType<Router['resolve']> | undefined;
export declare type LocaleRouteFunction = (route: RawLocation | RouteLocationRaw, locale?: Locale) => Route | ReturnType<Router['resolve']> | undefined;
export declare function localizeRoutes(routes: VueI18nRoute[], { defaultLocale, strategy, trailingSlash, routesNameSeparator, defaultLocaleRouteNameSuffix, includeUprefixedFallback, locales }?: Pick<VueI18nRoutingOptions, 'defaultLocale' | 'strategy' | 'locales' | 'routesNameSeparator' | 'trailingSlash' | 'defaultLocaleRouteNameSuffix'> & {
/**
* Localize routes
*
* @param routes - Some routes
* @param options - An options
*
* @returns Localized routes
*
* @public
*/
export declare function localizeRoutes(routes: I18nRoute[], { defaultLocale, strategy, trailingSlash, routesNameSeparator, defaultLocaleRouteNameSuffix, includeUprefixedFallback, optionsResolver, locales }?: Pick<I18nRoutingOptions, 'defaultLocale' | 'strategy' | 'locales' | 'routesNameSeparator' | 'trailingSlash' | 'defaultLocaleRouteNameSuffix'> & {
includeUprefixedFallback?: boolean;
}): VueI18nRoute[];
optionsResolver?: RouteOptionsResolver;
}): I18nRoute[];
export declare type MetaAttrs = Record<string, any>;
export declare function proxyVueInstance(target: Function): Function;
/**
* Register global i18n routing option registory
*
* @param router - A router instance, about router type
* @param options - A global options, about options type, see {@link I18nRoutingGlobalOptions}
*/
export declare function registerGlobalOptions<BaseUrl extends BaseUrlResolveHandler = BaseUrlResolveHandler>(router: Router | VueRouter, options: I18nRoutingGlobalOptions<BaseUrl>): void;
/**
* Resolve base url
*
* @param baseUrl - A base url to resolve on SEO and domain. if you want to resolve with dynamically, you can spacify {@link BaseUrlResolveHandler}
* @param context - A context to resolve base url, if you want to resolve base url with {@link BaseUrlResolveHandler}
*
* @returns A resolved base url
*/
export declare function resolveBaseUrl<Context = unknown>(baseUrl: string | BaseUrlResolveHandler<Context>, context: Context): string;
export declare function resolveRoute(this: RoutingProxy, route: any, locale?: Locale): any;
export { Route }
declare type _Route = UnionToIntersection<RouteConfig>;
/**
* Route config for vue-router v4
*/
export declare interface Route {
declare interface Route_2 {
name?: string;
path: string;
file?: string;
children?: Route[];
children?: Route_2[];
}
declare type _Route = UnionToIntersection<RouteConfig>;
/**

@@ -172,3 +458,35 @@ * Route config for lagacy vue-router v3

export { RouteLocationNormalized }
export { RouteLocationNormalizedLoaded }
/**
* Resolver for route localizing options
*/
export declare type RouteOptionsResolver = (route: I18nRoute, localeCodes: string[]) => ComputedRouteOptions | null;
/**
* Routing Proxy
*/
export declare type RoutingProxy = {
i18n: any;
getRouteBaseName: any;
localePath: any;
localeRoute: any;
localeLocation: any;
resolveRoute: any;
switchLocalePath: any;
localeHead: any;
route: Route | RouteLocationNormalizedLoaded;
router: Router | VueRouter;
defaultLocale?: string;
localeCodes?: string[];
strategy?: Strategies;
defaultDirection?: Directions;
defaultLocaleRouteNameSuffix?: string;
trailingSlash?: boolean;
routesNameSeparator?: string;
};
/**
* SEO Attribute options

@@ -185,3 +503,11 @@ */

declare const STRATEGIES: {
/**
* Set a locale
*
* @param i18n - An [I18n](https://vue-i18n.intlify.dev/api/general.html#i18n) instance or a [Composer](https://vue-i18n.intlify.dev/api/composition.html#composer) instance
* @param locale - A target locale
*/
export declare function setLocale(i18n: I18n | Composer, locale: Locale): void;
export declare const STRATEGIES: {
readonly PREFIX: "prefix";

@@ -198,24 +524,81 @@ readonly PREFIX_EXCEPT_DEFAULT: "prefix_except_default";

export declare function switchLocalePath(this: RoutingProxy, locale: Locale): string;
/**
* Switch locale path
* Swtich locale path function
*
* @param locale - A locale code, if not specified, uses the current locale
* @param options - An options, see about details {@link I18nRoutingOptions}
*
* @returns Returns a link to the current route in another language
*
* @see {@link useSwitchLocalePath}
*/
export declare function switchLocalePath(locale: Locale, { route, i18n }?: I18nRoutingOptions): string;
export declare type SwitchLocalePathFunction = (locale?: Locale) => string;
/**
* The target locale info
*
* @remarks
* This type is used by {@link BrowserLocaleMatcher} first argument
*/
export declare type TargetLocale = Required<Pick<LocaleObject, 'code' | 'iso'>>;
declare type UnionToIntersection<T> = (T extends any ? (k: T) => void : never) extends (k: infer U) => void ? U : never;
/**
* Generate SEO head meta information
* Use localize head meta
*
* @param options - An options, see about details {@link I18nHeadOptions}
* @param options - An options, see about details {@link I18nHeadOptions}, {@link ComposableOptions}, {@link I18nCommonRoutingOptions}
*
* @returns Genereated SEO head meta information
*/
export declare function useI18nHead({ addDirAttribute, addSeoAttributes, strategy, defaultLocale, route, router, i18n }?: Pick<I18nRoutingOptions, 'strategy' | 'defaultLocale'> & ComposableOptions & I18nHeadOptions): I18nHeadMetaInfo;
export declare function useLocaleHead({ addDirAttribute, addSeoAttributes, strategy, defaultLocale, route, router, i18n }?: Pick<I18nCommonRoutingOptionsWithComposable, 'strategy' | 'defaultLocale' | 'route' | 'router' | 'i18n'> & I18nHeadOptions): Ref<I18nHeadMetaInfo>;
/**
* Use resolve locale location
*
* @param options - An options, see about details {@link I18nRoutingOptions}
*
* @returns Returns a {@link LocaleLocationFunction}
*/
export declare function useLocaleLocation({ router, route, i18n, defaultLocale, defaultLocaleRouteNameSuffix, routesNameSeparator, strategy, trailingSlash }?: I18nCommonRoutingOptionsWithComposable): LocaleLocationFunction;
/**
* Use resolve locale path
*
* @param options - An options, see about details {@link I18nRoutingOptions}
*
* @returns Returns a {@link LocalePathFunction}
*/
export declare function useLocalePath({ router, route, i18n, defaultLocale, defaultLocaleRouteNameSuffix, routesNameSeparator, strategy, trailingSlash }?: I18nCommonRoutingOptionsWithComposable): LocalePathFunction;
/**
* Use resolve locale route
*
* @param options - An options, see about details {@link I18nRoutingOptions}
*
* @returns Returns a {@link LocaleRouteFunction}
*/
export declare function useLocaleRoute({ router, route, i18n, defaultLocale, defaultLocaleRouteNameSuffix, routesNameSeparator, strategy, trailingSlash }?: I18nCommonRoutingOptionsWithComposable): LocaleRouteFunction;
/**
* Use route base name
*
* @param givenRoute - A route object, if not provided, the route is returned with `useRoute` will be used
* @param options - An options, see about details {@link I18nRoutingOptions}
*
* @returns The route base name, if route name is not defined, return null
*/
export declare function useRouteBaseName(givenRoute?: Route | RouteLocationNormalizedLoaded, { router, routesNameSeparator }?: I18nCommonRoutingOptionsWithComposable): string | undefined;
/**
* Use swtich locale path
*
* @param options - An options, see about details {@link I18nRoutingOptions}
*
* @returns Returns a {@link SwitchLocalePathFunction}
*/
export declare function useSwitchLocalePath({ router, route, i18n, defaultLocale, defaultLocaleRouteNameSuffix, routesNameSeparator, strategy, trailingSlash }?: I18nCommonRoutingOptionsWithComposable): SwitchLocalePathFunction;
/**
* Vue I18n Routing Version

@@ -228,115 +611,49 @@ *

/**
* Route config for vue-i18n-routing
*/
export declare type VueI18nRoute = Route & RouteLegacy & {
redirect?: string;
export declare type VueI18nExtendOptions = Pick<I18nRoutingOptions, 'baseUrl'> & {
locales?: string[] | LocaleObject[];
localeCodes?: string[];
hooks?: ExtendHooks;
};
/**
* Options to initialize a VueRouter instance
*
* @remarks
* This options is extended from Vue Router `RouterOptioins`, so you can specify those options.
* An options of Vue I18n Routing Plugin
*/
export declare type VueI18nRoutingOptions<BaseUrl extends BaseUrlResolveHandler = BaseUrlResolveHandler> = {
export declare interface VueI18nRoutingPluginOptions {
/**
* Vue Router version
* Whether to inject some option APIs style methods into Vue instance
*
* @remarks
* You can choice between vue-router v3 and v4.
*
* If you specify `3`, this function return Vue Router v3 instance, else specify `4`, this function return Vue Router v4 instance.
*
* @defaultValue 4
* @defaultValue `true`
*/
version?: 3 | 4;
/**
* The app's default locale
*
* @remarks
* When using `prefix_except_default` strategy, URLs for locale specified here won't have a prefix.
*
* It's recommended to set this to some locale regardless of chosen strategy, as it will be used as a fallback locale when navigating to a non-existent route
*
* @defaultValue '' (emputy string)
*/
defaultLocale?: string;
/**
* List of locales supported by your app
*
* @remarks TODO:
*
* @defaultValue []
*/
locales?: string[] | LocaleObject[];
/**
* Routes strategy
*
* @remarks
* Can be set to one of the following:
*
* - `no_prefix`: routes won't have a locale prefix
* - `prefix_except_default`: locale prefix added for every locale except default
* - `prefix`: locale prefix added for every locale
* - `prefix_and_default`: locale prefix added for every locale and default
*
* @defaultValue 'prefix_except_default'
*/
strategy?: Strategies;
/**
* Whether to use trailing slash
*
* @defaultValue false
*/
trailingSlash?: boolean;
/**
* Internal separator used for generated route names for each locale. You shouldn't need to change this
*
* @defaultValue '___'
*/
routesNameSeparator?: string;
/**
* Internal suffix added to generated route names for default locale
*
* @remarks
* if strategy is prefix_and_default. You shouldn't need to change this.
*
* @defaultValue 'default'
*/
defaultLocaleRouteNameSuffix?: string;
/**
* Default detection direction
*
* @defaultValue 'ltr'
*/
defaultDetection?: Directions;
/**
* The fallback base URL to use as a prefix for alternate URLs in hreflang tags.
*
* @remarks
* By default VueRouter's base URL will be used and only if that is not available, fallback URL will be used.
*
* Can also be a function (will be passed a Nuxt Context as a parameter) that returns a string.
*
* Useful to make base URL dynamic based on request headers.
*
* @defaultValue ''
*/
baseUrl?: string | BaseUrl;
} & RouterOptions;
inject?: boolean;
}
export { }
import type { ComputedRef } from 'vue-demi'
export interface ComposerCustomProperties {
/**
* List of locales
*
* @remarks
* Can either be an array of string codes (e.g. `['en', 'fr']`) or an array of {@link LocaleObject} for more complex configurations
*/
locales: ComputedRef<string[] | LocaleObject[]>
/**
* List of locale codes
*/
localeCodes: ComputedRef<string[]>
__baseUrl: string
}
declare module 'vue-i18n' {
export interface ComposerCustom {
locales: ComputedRef<string[] | LocaleObject[]>
__baseUrl: string
}
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface ComposerCustom extends ComposerCustomProperties {}
}
declare module 'vue-i18n-bridge' {
export interface ComposerCustom {
locales: ComputedRef<string[] | LocaleObject[]>
__baseUrl: string
}
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface ComposerCustom extends ComposerCustomProperties {}
}
declare module '@intlify/vue-i18n-bridge' {
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface ComposerCustom extends ComposerCustomProperties {}
}

@@ -1,5 +0,5 @@

var xe=Object.defineProperty,De=Object.defineProperties;var we=Object.getOwnPropertyDescriptors;var C=Object.getOwnPropertySymbols;var te=Object.prototype.hasOwnProperty,ae=Object.prototype.propertyIsEnumerable;var ne=(f,u,_)=>u in f?xe(f,u,{enumerable:!0,configurable:!0,writable:!0,value:_}):f[u]=_,T=(f,u)=>{for(var _ in u||(u={}))te.call(u,_)&&ne(f,_,u[_]);if(C)for(var _ of C(u))ae.call(u,_)&&ne(f,_,u[_]);return f},v=(f,u)=>De(f,we(u));var le=(f,u)=>{var _={};for(var S in f)te.call(f,S)&&u.indexOf(S)<0&&(_[S]=f[S]);if(f!=null&&C)for(var S of C(f))u.indexOf(S)<0&&ae.call(f,S)&&(_[S]=f[S]);return _};var VueI18nRouting=function(f,u,_,S){"use strict";function oe(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var ce=oe(_);/*!
* shared v9.2.0-beta.28
const VueI18nRouting=function(f,h,g,w){"use strict";const ye=(e=>e&&typeof e=="object"&&"default"in e?e:{default:e})(g),Q={PREFIX:"prefix",PREFIX_EXCEPT_DEFAULT:"prefix_except_default",PREFIX_AND_DEFAULT:"prefix_and_default",NO_PREFIX:"no_prefix"},G="",B=Q.PREFIX_EXCEPT_DEFAULT,M=!1,k="___",D="default",Y="ltr",J="";/*!
* shared v9.2.2
* (c) 2022 kazuya kawaguchi
* Released under the MIT License.
*/const G=Object.assign,re=Array.isArray,se=e=>typeof e=="function",y=e=>typeof e=="string",fe=e=>typeof e=="boolean",ue=e=>typeof e=="symbol",ie=/\/$|\/\?/;function X(e="",t=!1){return t?ie.test(e):e.endsWith("/")}function de(e="",t=!1){if(!t)return(X(e)?e.slice(0,-1):e)||"/";if(!X(e,!0))return e||"/";const[a,...n]=e.split("?");return(a.slice(0,-1)||"/")+(n.length?`?${n.join("?")}`:"")}function he(e="",t=!1){if(!t)return e.endsWith("/")?e:e+"/";if(X(e,!0))return e||"/";const[a,...n]=e.split("?");return a+"/"+(n.length?`?${n.join("?")}`:"")}function _e(e,t){typeof console!="undefined"&&(console.warn("[vue-i18n-routing] "+e),t&&console.warn(t.stack))}function me(e){e=e||[];const t=[];for(const a of e)y(a)?t.push({code:a}):t.push(a);return t}function V(e,t){return u.isRef(e.locale)&&t==="composition"}function H(e){return"global"in e&&"mode"in e}function b(e){return H(e)?V(e.global,e.mode)?e.global.locale.value:e.global.locale:e.locale.value}function Le(e,t){H(e)?V(e.global,e.mode)?e.global.locale.value=t:e.global.locale=t:u.isRef(e.locale)&&(e.locale.value=t)}function ge(e,t,a){return e.replace(/\/+$/,"")+(t?"/":"")||(a?"":"/")}function W(e){return y(e)?e:ue(e)?e.toString():"(null)"}function B(e,t,{defaultLocale:a,strategy:n,routesNameSeparator:c,defaultLocaleRouteNameSuffix:l}){let r=W(e)+(n==="no_prefix"?"":c+t);return t===a&&n==="prefix_and_default"&&(r+=c+l),r}function Re(e,t){return se(e)?e(t):e}const $={PREFIX:"prefix",PREFIX_EXCEPT_DEFAULT:"prefix_except_default",PREFIX_AND_DEFAULT:"prefix_and_default",NO_PREFIX:"no_prefix"},O="",x=$.PREFIX_EXCEPT_DEFAULT,Q=!1,D="___",z="default",Ee="ltr",Y="";function w(e=_.useRoute(),t=_.useRouter().__routesNameSeparator||D){const a=u.unref(e);return a.name?W(a.name).split(t)[0]:null}const Se=new Set([$.PREFIX_AND_DEFAULT,$.PREFIX_EXCEPT_DEFAULT]);function J(e,t,a){const n=j(e,t,a);return n==null?"":u.isVue3?n.redirectedFrom||n.fullPath:n.route.redirectedFrom||n.route.fullPath}function K(e,t,a){const n=j(e,t,a);return n==null?void 0:u.isVue3?n:n.route}function pe(e,t,a){const n=j(e,t,a);return n==null?void 0:u.isVue3?n:n.location}function j(e,t,{router:a=_.useRouter(),i18n:n=S.useI18n(),defaultLocale:c=O,defaultLocaleRouteNameSuffix:l=z,routesNameSeparator:r=D,strategy:d=x,trailingSlash:h=!1}={}){const s=a.__defaultLocaleRouteNameSuffix||l,o=a.__defaultLocale||c,R=a.__routesNameSeparator||r,m=a.__strategy||d,E=t||b(n);let p=e;y(e)&&(p[0]==="/"?p={path:e}:p={name:e});let L=G({},p);if(L.path&&!L.name){const i=a.resolve(L),g=u.isVue3?i:i.route,I=w(g);y(I)?L={name:B(I,E,{defaultLocale:o,strategy:m,routesNameSeparator:R,defaultLocaleRouteNameSuffix:s}),params:g.params,query:g.query,hash:g.hash}:(!(E===c&&Se.has(m))&&m!==$.NO_PREFIX&&(L.path=`/${E}${L.path}`),L.path=h?he(L.path,!0):de(L.path,!0))}else{L.name=B(L.name,E,{defaultLocale:o,strategy:m,routesNameSeparator:R,defaultLocaleRouteNameSuffix:s});const{params:i}=L;i&&i["0"]===void 0&&i.pathMatch&&(i["0"]=i.pathMatch)}const A=a.resolve(L);return(u.isVue3?A.name:A.route.name)?A:a.resolve(e)}function M(e,{route:t=_.useRoute(),i18n:a=S.useI18n()}={}){const n=w();if(!n)return"";const s=!u.isVue3&&u.isRef(t)?t.value:t,{params:c}=s,l=le(s,["params"]),r={},d=G({},l,{name:n,params:v(T(T({},c),r),{0:c.pathMatch})});return J(d,e,{route:t,i18n:a})}function Ae({addDirAttribute:e=!1,addSeoAttributes:t=!1,strategy:a=x,defaultLocale:n=O,route:c=_.useRoute(),router:l=_.useRouter(),i18n:r=S.useI18n()}={}){const d=n||l.__defaultLocale,h=a||l.__strategy,s={htmlAttrs:{},link:[],meta:[]},o=b(r),R=l.__localeProperties||{code:o},m=R.iso,E=R.dir||l.__defaultDetection;if(e&&(s.htmlAttrs.dir=E),t&&o&&r.locales){m&&(s.htmlAttrs.lang=m);const p=r.locales.value;Ie(p,r.__baseUrl,s.link,{defaultLocale:d,strategy:h,route:c,router:l,i18n:r}),Pe(r.__baseUrl,s.link,t,{route:c,router:l,i18n:r}),Te(R,m,s.meta),ye(p,m,s.meta)}return s}function Ie(e,t,a,n){if(n.strategy===$.NO_PREFIX)return;const c=new Map;for(const l of e){const r=l.iso;if(!r){_e("Locale ISO code is required to generate alternate link");continue}const[d,h]=r.split("-");d&&h&&(l.isCatchallLocale||!c.has(d))&&c.set(d,l),c.set(r,l)}for(const[l,r]of c.entries()){const d=M(r.code,n);d&&a.push({hid:`i18n-alt-${l}`,rel:"alternate",href:k(d,t),hreflang:l})}if(n.defaultLocale){const l=M(n.defaultLocale,n);l&&a.push({hid:"i18n-xd",rel:"alternate",href:k(l,t),hreflang:"x-default"})}}function Pe(e,t,a,n){const{route:c}=n,l=K(v(T({},c),{name:w()}),void 0,n);if(l){let r=k(l.path,e);const d=!fe(a)&&a.canonicalQueries||[];if(d.length){const h=l.query,s=new URLSearchParams;for(const R of d)if(R in h){const m=h[R];re(m)?m.forEach(E=>s.append(R,E||"")):s.append(R,m||"")}const o=s.toString();o&&(r=`${r}?${o}`)}t.push({hid:"i18n-can",rel:"canonical",href:r})}}function Te(e,t,a){!(e&&t)||a.push({hid:"i18n-og",property:"og:locale",content:Z(t)})}function ye(e,t,a){const n=e.filter(c=>{const l=c.iso;return l&&l!==t});if(n.length){const c=n.map(l=>({hid:`i18n-og-alt-${l.iso}`,property:"og:locale:alternate",content:Z(l.iso)}));a.push(...c)}}function Z(e){return(e||"").replace(/-/g,"_")}function k(e,t){return e.match(/^https?:\/\//)?e:t+e}function ee(e,{defaultLocale:t=O,strategy:a=x,trailingSlash:n=Q,routesNameSeparator:c=D,defaultLocaleRouteNameSuffix:l=z,includeUprefixedFallback:r=!1,locales:d=[]}={}){if(a==="no_prefix")return e;const h=d.map(o=>y(o)?o:o.code);function s(o,R,m=!1,E=!1){return o.redirect&&(!o.component||!o.file)?[o]:R.reduce((L,A)=>{const{name:i}=o;let{path:g}=o;const I=T({},o);i&&(I.name=`${i}${c}${A}`),o.children&&(I.children=o.children.reduce((P,q)=>[...P,...s(q,[A],!0,E)],[]));const F=A===t;if(F&&a==="prefix_and_default")if(m)m&&E&&i&&(I.name+=`${c}${l}`);else{const P=v(T({},I),{path:g});if(i&&(P.name=`${I.name}${c}${l}`),o.children){P.children=[];for(const q of o.children)P.children=P.children.concat(s(q,[A],!0,!0))}L.push(P)}const N=m&&!g.startsWith("/"),U=!N&&!(F&&a==="prefix_except_default");return U&&(g=`/${A}${g}`),g&&(g=ge(g,n,N)),U&&F&&a==="prefix"&&r&&L.push(T({},o)),I.path=g,L.push(I),L},[])}return e.reduce((o,R)=>[...o,...s(R,h||[])],[])}function Fe(e,{locales:t=[],baseUrl:a=Y}={}){if(!V(e.global,e.mode))throw new Error("TODO:");const n=u.ref(t);e.global.locales=u.computed(()=>n.value),e.global.__baseUrl=Re(a,{})}function Ne(e){return new RegExp(`^/(${e.join("|")})(?:/|$)`,"i")}function $e(e,t,a){const n=`(${e.join("|")})`,c=`(?:${t}${a})?`,l=new RegExp(`${t}${n}${c}$`,"i"),r=Ne(e);return h=>{if(h.name){const o=(y(h.name)?h.name:h.name.toString()).match(l);if(o&&o.length>1)return o[1]}else if(h.path){const s=h.path.match(r);if(s&&s.length>1)return s[1]}return""}}function Ue(e){var t,a,n,c,l,r,d,h,s,o;return e.version=(t=e.version)!=null?t:4,e.defaultLocale=(a=e.defaultLocale)!=null?a:O,e.strategy=(n=e.strategy)!=null?n:x,e.trailingSlash=(c=e.trailingSlash)!=null?c:Q,e.routesNameSeparator=(l=e.routesNameSeparator)!=null?l:D,e.defaultLocaleRouteNameSuffix=(r=e.defaultLocaleRouteNameSuffix)!=null?r:z,e.locales=(d=e.locales)!=null?d:[],e.defaultDetection=(h=e.defaultDetection)!=null?h:Ee,e.baseUrl=(s=e.baseUrl)!=null?s:Y,e.routes=(o=e.routes)!=null?o:[],e}function be(e,t={}){const{version:a,defaultLocale:n,locales:c,strategy:l,trailingSlash:r,routesNameSeparator:d,defaultLocaleRouteNameSuffix:h,defaultDetection:s,baseUrl:o,routes:R}=Ue(t),m=b(e),E=me(c),p=E.map(g=>g.code),L=$e(p,d,h);Fe(e,{locales:E,baseUrl:o});const A=ee(R,{locales:c,defaultLocale:n,strategy:l,trailingSlash:r,routesNameSeparator:d,defaultLocaleRouteNameSuffix:h});t.routes=A;let i=null;if(u.isVue3&&a===4)i=_.createRouter(t);else if(u.isVue2&&a===3)i=new ce.default(t);else throw new Error("TODO:");return i.__defaultLocale=n,i.__localeCodes=p,i.__localeProperties=E.find(g=>g.code===m)||{code:m},i.__strategy=l,i.__trailingSlash=r,i.__routesNameSeparator=d,i.__defaultLocaleRouteNameSuffix=h,i.__defaultDetection=s,i.beforeEach((g,I,F)=>{const N=b(e),U=L(g)||N||n||"";N!==U&&Le(e,U),F()}),i}const Oe="0.0.0";return f.VERSION=Oe,f.createRouter=be,f.getRouteBaseName=w,f.localeLocation=pe,f.localePath=J,f.localeRoute=K,f.localizeRoutes=ee,f.switchLocalePath=M,f.useI18nHead=Ae,Object.defineProperty(f,"__esModule",{value:!0}),f[Symbol.toStringTag]="Module",f}({},VueDemi,VueRouter,VueI18n);
*/process.env.NODE_ENV;const Ie=typeof Symbol=="function"&&typeof Symbol.toStringTag=="symbol",Ce=e=>Ie?Symbol(e):e,z=Object.assign,Te=Array.isArray,Oe=e=>typeof e=="function",T=e=>typeof e=="string",Pe=e=>typeof e=="boolean",be=e=>typeof e=="symbol",K=e=>e!==null&&typeof e=="object",Ue=/\/$|\/\?/;function Z(e="",t=!1){return t?Ue.test(e):e.endsWith("/")}function Ne(e="",t=!1){if(!t)return(Z(e)?e.slice(0,-1):e)||"/";if(!Z(e,!0))return e||"/";const[o,...n]=e.split("?");return(o.slice(0,-1)||"/")+(n.length?`?${n.join("?")}`:"")}function Fe(e="",t=!1){if(!t)return e.endsWith("/")?e:e+"/";if(Z(e,!0))return e||"/";const[o,...n]=e.split("?");return o+"/"+(n.length?`?${n.join("?")}`:"")}const we=typeof window<"u";function ae(e,t){typeof console<"u"&&(console.warn("[vue-i18n-routing] "+e),t&&console.warn(t.stack))}function ce(e){e=e||[];const t=[];for(const o of e)T(o)?t.push({code:o}):t.push(o);return t}function U(e){return e!=null&&"global"in e&&"mode"in e}function N(e){return e!=null&&!("__composer"in e)&&h.isRef(e.locale)}function O(e){return e!=null&&"__composer"in e}function $(e){return e!=null&&!("__composer"in e)&&!h.isRef(e.locale)}function y(e){return e!=null&&("__VUE_I18N_BRIDGE__"in e||"_sync"in e)}function se(e){return U(e)?N(e.global)?e.global:e.global.__composer:O(e)?e.__composer:e}function H(e){const t=U(e)?e.global:e;return N(t)?h.isVue2&&y(e)?e.locale:t.locale.value:($(t)||O(t)||y(t),t.locale)}function re(e){const t=U(e)?e.global:e;return N(t)?h.isVue2&&y(e)?e.locales:t.locales.value:($(t)||O(t)||y(t),t.locales)}function $e(e){const t=U(e)?e.global:e;return N(t)?h.isVue2&&y(e)?e.localeCodes:t.localeCodes.value:($(t)||O(t)||y(t),t.localeCodes)}function ie(e,t){const o=U(e)?e.global:e;if(N(o))h.isVue2&&y(e)?e.locale=t:o.locale.value=t;else if($(o)||O(o)||y(o))o.locale=t;else throw new Error("TODO:")}function Ve(e,t,o){return e.replace(/\/+$/,"")+(t?"/":"")||(o?"":"/")}function ue(e){return g.isVueRouter4,h.isRef(e)?e.value:e}function fe(e){return T(e)?e:be(e)?e.toString():"(null)"}function de(e,t,{defaultLocale:o,strategy:n,routesNameSeparator:a,defaultLocaleRouteNameSuffix:l}){let c=fe(e)+(n==="no_prefix"?"":a+t);return t===o&&n==="prefix_and_default"&&(c+=a+l),c}function he(e,t){return Oe(e)?e(t):e}function ve(e,t){const o=[];for(const[n,a]of t.entries()){const l=e.find(c=>c.iso.toLowerCase()===a.toLowerCase());if(l){o.push({code:l.code,score:1-n/t.length});break}}for(const[n,a]of t.entries()){const l=a.split("-")[0].toLowerCase(),c=e.find(s=>s.iso.split("-")[0].toLowerCase()===l);if(c){o.push({code:c.code,score:.999-n/t.length});break}}return o}const je=ve;function Ge(e,t){return e.score===t.score?t.code.length-e.code.length:t.score-e.score}const Be=Ge;function Me(e,t,{matcher:o=je,comparer:n=Be}={}){const a=[];for(const c of e){const{code:s}=c,i=c.iso||s;a.push({code:s,iso:i})}const l=o(a,t);return l.length>1&&l.sort(n),l.length?l[0].code:""}function C(e){return function(){return Reflect.apply(e,{getRouteBaseName:this.getRouteBaseName,localePath:this.localePath,localeRoute:this.localeRoute,localeLocation:this.localeLocation,resolveRoute:this.resolveRoute,switchLocalePath:this.switchLocalePath,localeHead:this.localeHead,i18n:this.$i18n,route:this.$route,router:this.$router},arguments)}}function Le(e,{locales:t=[],localeCodes:o=[],baseUrl:n=J,hooks:a={}}={}){const l=h.effectScope(),c=e.install;return e.install=(s,...i)=>{Reflect.apply(c,e,[s,...i]);const u=se(e);l.run(()=>ke(u,{locales:t,localeCodes:o,baseUrl:n,hooks:a})),O(e.global)&&ze(e.global,a.onExtendVueI18n);const d=s,r=e.mode==="composition"?h.isVue3?d.config.globalProperties.$i18n:e:h.isVue2?e:null;if(r&&De(r,u,a.onExtendExportedGlobal),(He(i[0])?i[0]:{inject:!0}).inject&&s.mixin({methods:{resolveRoute:C(V),localePath:C(q),localeRoute:C(x),localeLocation:C(te),switchLocalePath:C(v),getRouteBaseName:C(P),localeHead:C(oe)}}),d.unmount){const _=d.unmount;d.unmount=()=>{l.stop(),_()}}},l}function ke(e,t){const{locales:o,localeCodes:n,baseUrl:a}=t,l=h.ref(o),c=h.ref(n);e.locales=h.computed(()=>l.value),e.localeCodes=h.computed(()=>c.value),e.__baseUrl=he(a,{}),t.hooks&&t.hooks.onExtendComposer&&t.hooks.onExtendComposer(e)}function De(e,t,o){const n=[{locales:{get(){return t.locales.value}},localeCodes:{get(){return t.localeCodes.value}},__baseUrl:{get(){return t.__baseUrl}}}];o&&n.push(o(t));for(const a of n)for(const[l,c]of Object.entries(a))Object.defineProperty(e,l,c)}function ze(e,t){const o=se(e),n=[{locales:{get(){return o.locales.value}},localeCodes:{get(){return o.localeCodes.value}},__baseUrl:{get(){return o.__baseUrl}}}];t&&n.push(t(o));for(const a of n)for(const[l,c]of Object.entries(a))Object.defineProperty(e,l,c)}function He(e){return K(e)&&"inject"in e&&Pe(e.inject)}function ge(e,{defaultLocale:t=G,strategy:o=B,trailingSlash:n=M,routesNameSeparator:a=k,defaultLocaleRouteNameSuffix:l=D,includeUprefixedFallback:c=!1,optionsResolver:s=void 0,locales:i=[]}={}){if(o==="no_prefix")return e;const u=i.map(r=>T(r)?r:r.code);function d(r,L,_=!1,I=!1){if(r.redirect&&(!r.component||!r.file))return[r];let p=null;if(s!=null&&(p=s(r,L),p==null))return[r];const R={locales:u,paths:{}};if(p!=null&&z(R,p),z(R,{locales:L}),R.locales.length>0&&p&&p.locales!=null&&p.locales.length>0){const E=[];for(const m of R.locales)p.locales.includes(m)&&E.push(m);R.locales=E}return R.locales.reduce((E,m)=>{const{name:j}=r;let{path:S}=r;const A={...r};j&&(A.name=`${j}${a}${m}`),r.children&&(A.children=r.children.reduce((b,le)=>[...b,...d(le,[m],!0,I)],[])),R.paths&&R.paths[m]&&(S=R.paths[m]);const F=m===t;if(F&&o==="prefix_and_default")if(_)_&&I&&j&&(A.name+=`${a}${l}`);else{const b={...A,path:S};if(j&&(b.name=`${A.name}${a}${l}`),r.children){b.children=[];for(const le of r.children)b.children=b.children.concat(d(le,[m],!0,!0))}E.push(b)}const Se=_&&!S.startsWith("/"),Ae=!Se&&!(F&&o==="prefix_except_default");return Ae&&(S=`/${m}${S}`),S&&(S=Ve(S,n,Se)),Ae&&F&&o==="prefix"&&c&&E.push({...r}),A.path=S,E.push(A),E},[])}return e.reduce((r,L)=>[...r,...d(L,u||[])],[])}const ee=Ce("vue-i18n-routing-gor");function _e(e,t){e[ee]?ae("already registered global options"):e[ee]=t}function me(e){var t;return(t=e[ee])!=null?t:{}}function Xe(e,t={}){const{version:o,defaultLocale:n,locales:a,strategy:l,trailingSlash:c,routesNameSeparator:s,defaultLocaleRouteNameSuffix:i,defaultDirection:u,baseUrl:d,routes:r,routeOptionsResolver:L}=xe(t),_=ce(a),I=_.map(m=>m.code),p=pe(I,s,i);Le(e,{locales:_,baseUrl:d,localeCodes:I});const R=ge(r,{locales:a,defaultLocale:n,strategy:l,trailingSlash:c,routesNameSeparator:s,defaultLocaleRouteNameSuffix:i,optionsResolver:L});t.routes=R;const E=qe(t,o);return _e(E,{defaultLocale:n,localeCodes:I,strategy:l,trailingSlash:c,routesNameSeparator:s,defaultLocaleRouteNameSuffix:i,defaultDirection:u}),E.beforeEach((m,j,S)=>{const A=H(e),F=p(m)||A||n||"";A!==F&&ie(e,F),S()}),E}function qe(e,t){if(h.isVue3&&t===4)return g.createRouter(e);if(h.isVue2&&t===3)return new ye.default(e);throw new Error("TODO:")}function Re(e){return new RegExp(`^/(${e.join("|")})(?:/|$)`,"i")}function pe(e,t,o){const n=`(${e.join("|")})`,a=`(?:${t}${o})?`,l=new RegExp(`${t}${n}${a}$`,"i"),c=Re(e);return i=>{if(K(i)){if(i.name){const d=(T(i.name)?i.name:i.name.toString()).match(l);if(d&&d.length>1)return d[1]}else if(i.path){const u=i.path.match(c);if(u&&u.length>1)return u[1]}}else if(T(i)){const u=i.match(c);if(u&&u.length>1)return u[1]}return""}}function xe(e){var t,o,n,a,l,c,s,i,u,d;return e.version=(t=e.version)!=null?t:4,e.defaultLocale=(o=e.defaultLocale)!=null?o:G,e.strategy=(n=e.strategy)!=null?n:B,e.trailingSlash=(a=e.trailingSlash)!=null?a:M,e.routesNameSeparator=(l=e.routesNameSeparator)!=null?l:k,e.defaultLocaleRouteNameSuffix=(c=e.defaultLocaleRouteNameSuffix)!=null?c:D,e.locales=(s=e.locales)!=null?s:[],e.defaultDirection=(i=e.defaultDirection)!=null?i:Y,e.baseUrl=(u=e.baseUrl)!=null?u:J,e.routes=(d=e.routes)!=null?d:[],e}function X(e,t,{defaultLocale:o=G,defaultDirection:n=Y,defaultLocaleRouteNameSuffix:a=D,routesNameSeparator:l=k,strategy:c=B,trailingSlash:s=M,localeCodes:i=[]}={}){const u=me(e);return{defaultLocale:t.defaultLocale||u.defaultLocale||o,defaultDirection:t.defaultDirection||u.defaultDirection||n,defaultLocaleRouteNameSuffix:t.defaultLocaleRouteNameSuffix||u.defaultLocaleRouteNameSuffix||a,routesNameSeparator:t.routesNameSeparator||u.routesNameSeparator||l,strategy:t.strategy||u.strategy||c,trailingSlash:t.trailingSlash||u.trailingSlash||s,localeCodes:t.localeCodes||u.localeCodes||i}}const We=new Set(["prefix_and_default","prefix_except_default"]);function P(e){const t=this.router,{routesNameSeparator:o}=X(t,this),n=e!=null?h.isRef(e)?h.unref(e):e:this.route;return n==null||!n.name?void 0:fe(n.name).split(o)[0]}function q(e,t){const o=V.call(this,e,t);return o==null?"":h.isVue3?o.redirectedFrom||o.fullPath:o.route.redirectedFrom||o.route.fullPath}function x(e,t){const o=V.call(this,e,t);return o==null?void 0:h.isVue3?o:o.route}function te(e,t){const o=V.call(this,e,t);return o==null?void 0:h.isVue3?o:o.location}function V(e,t){const o=this.router,n=this.i18n,a=t||H(n),{routesNameSeparator:l,defaultLocale:c,defaultLocaleRouteNameSuffix:s,strategy:i,trailingSlash:u}=X(o,this);let d=e;T(e)&&(d[0]==="/"?d={path:e}:d={name:e});let r=z({},d);if(r.path&&!r.name){let L=null;try{L=o.resolve(r)}catch{}const _=h.isVue3?L:L.route,I=P.call(this,_);T(I)?r={name:de(I,a,{defaultLocale:c,strategy:i,routesNameSeparator:l,defaultLocaleRouteNameSuffix:s}),params:_.params,query:_.query,hash:_.hash}:(!(a===c&&We.has(i))&&i!=="no_prefix"&&(r.path=`/${a}${r.path}`),r.path=u?Fe(r.path,!0):Ne(r.path,!0))}else{!r.name&&!r.path&&(r.name=P.call(this,this.route)),r.name=de(r.name,a,{defaultLocale:c,strategy:i,routesNameSeparator:l,defaultLocaleRouteNameSuffix:s});const{params:L}=r;L&&L[0]===void 0&&L.pathMatch&&(L[0]=L.pathMatch)}try{const L=o.resolve(r);return(h.isVue3?L.name:L.route.name)?L:o.resolve(e)}catch(L){if(h.isVue3&&L.type===1)return null;if(h.isVue2)return null}}function v(e){const t=this.route,o=P.call(this,t);if(!o)return"";const{params:n,...a}=!h.isVue3&&h.isRef(t)?t.value:t,c=z({},a,{name:o,params:{...n,...{},0:n.pathMatch}});return q.call(this,c,e)}function oe({addDirAttribute:e=!1,addSeoAttributes:t=!1}={}){const o=this.router,n=this.i18n,{defaultDirection:a}=X(o,this),l={htmlAttrs:{},link:[],meta:[]};if(n.locales==null||n.__baseUrl==null)return l;const c=H(n),s=re(n),i=ce(s).find(r=>r.code===c)||{code:c},u=i.iso,d=i.dir||a;return e&&(l.htmlAttrs.dir=d),t&&c&&n.locales&&(u&&(l.htmlAttrs.lang=u),Qe.call(this,s,n.__baseUrl,l.link),Ye.call(this,n.__baseUrl,l.link,t),Je(i,u,l.meta),Ke(s,u,l.meta)),l}function Qe(e,t,o){const n=this.router,{defaultLocale:a,strategy:l}=X(n,this);if(l===Q.NO_PREFIX)return;const c=new Map;for(const s of e){const i=s.iso;if(!i){ae("Locale ISO code is required to generate alternate link");continue}const[u,d]=i.split("-");u&&d&&(s.isCatchallLocale||!c.has(u))&&c.set(u,s),c.set(i,s)}for(const[s,i]of c.entries()){const u=v.call(this,i.code);u&&o.push({hid:`i18n-alt-${s}`,rel:"alternate",href:ne(u,t),hreflang:s})}if(a){const s=v.call(this,a);s&&o.push({hid:"i18n-xd",rel:"alternate",href:ne(s,t),hreflang:"x-default"})}}function Ye(e,t,o){const n=this.route,a=x.call(this,{...n,name:P.call(this,n)});if(a){let l=ne(a.path,e);const c=K(o)&&o.canonicalQueries||[];if(c.length){const s=a.query,i=new URLSearchParams;for(const d of c)if(d in s){const r=s[d];Te(r)?r.forEach(L=>i.append(d,L||"")):i.append(d,r||"")}const u=i.toString();u&&(l=`${l}?${u}`)}t.push({hid:"i18n-can",rel:"canonical",href:l})}}function Je(e,t,o){!(e&&t)||o.push({hid:"i18n-og",property:"og:locale",content:Ee(t)})}function Ke(e,t,o){const n=e.filter(a=>{const l=a.iso;return l&&l!==t});if(n.length){const a=n.map(l=>({hid:`i18n-og-alt-${l.iso}`,property:"og:locale:alternate",content:Ee(l.iso)}));o.push(...a)}}function Ee(e){return(e||"").replace(/-/g,"_")}function ne(e,t){return e.match(/^https?:\/\//)?e:t+e}function W(e,t){const{router:o,route:n,i18n:a,defaultLocale:l,strategy:c,defaultLocaleRouteNameSuffix:s,trailingSlash:i,routesNameSeparator:u}=e;return function(...d){return Reflect.apply(t,{router:o,route:n,i18n:a,defaultLocale:l,strategy:c,defaultLocaleRouteNameSuffix:s,trailingSlash:i,routesNameSeparator:u},d)}}function Ze(e=g.useRoute(),{router:t=g.useRouter(),routesNameSeparator:o=void 0}={}){const n={router:t,route:e,routesNameSeparator:o};return P.call(n,e)}function et({router:e=g.useRouter(),route:t=g.useRoute(),i18n:o=w.useI18n(),defaultLocale:n=void 0,defaultLocaleRouteNameSuffix:a=void 0,routesNameSeparator:l=void 0,strategy:c=void 0,trailingSlash:s=void 0}={}){return W({router:e,route:t,i18n:o,defaultLocale:n,defaultLocaleRouteNameSuffix:a,routesNameSeparator:l,strategy:c,trailingSlash:s},q)}function tt({router:e=g.useRouter(),route:t=g.useRoute(),i18n:o=w.useI18n(),defaultLocale:n=void 0,defaultLocaleRouteNameSuffix:a=void 0,routesNameSeparator:l=void 0,strategy:c=void 0,trailingSlash:s=void 0}={}){return W({router:e,route:t,i18n:o,defaultLocale:n,defaultLocaleRouteNameSuffix:a,routesNameSeparator:l,strategy:c,trailingSlash:s},x)}function ot({router:e=g.useRouter(),route:t=g.useRoute(),i18n:o=w.useI18n(),defaultLocale:n=void 0,defaultLocaleRouteNameSuffix:a=void 0,routesNameSeparator:l=void 0,strategy:c=void 0,trailingSlash:s=void 0}={}){return W({router:e,route:t,i18n:o,defaultLocale:n,defaultLocaleRouteNameSuffix:a,routesNameSeparator:l,strategy:c,trailingSlash:s},te)}function nt({router:e=g.useRouter(),route:t=g.useRoute(),i18n:o=w.useI18n(),defaultLocale:n=void 0,defaultLocaleRouteNameSuffix:a=void 0,routesNameSeparator:l=void 0,strategy:c=void 0,trailingSlash:s=void 0}={}){return W({router:e,route:t,i18n:o,defaultLocale:n,defaultLocaleRouteNameSuffix:a,routesNameSeparator:l,strategy:c,trailingSlash:s},v)}function lt({addDirAttribute:e=!1,addSeoAttributes:t=!1,strategy:o=void 0,defaultLocale:n=void 0,route:a=g.useRoute(),router:l=g.useRouter(),i18n:c=w.useI18n()}={}){const s=l,i=h.ref({htmlAttrs:{},link:[],meta:[]});function u(){i.value={htmlAttrs:{},link:[],meta:[]}}function d(r){i.value=Reflect.apply(oe,{router:l,route:r,i18n:c,defaultLocale:n,strategy:o},[{addDirAttribute:e,addSeoAttributes:t}])}if(we)if(h.isVue3){const r=h.watchEffect(()=>{u(),d(ue(s.currentRoute))});h.onUnmounted(()=>r())}else{const r=s.afterEach((L,_)=>{u(),d(L)});h.onUnmounted(()=>r()),d(a)}else d(ue(s.currentRoute));return i}const at="0.0.0";return f.DEFAULT_BASE_URL=J,f.DEFAULT_DETECTION_DIRECTION=Y,f.DEFAULT_LOCALE=G,f.DEFAULT_LOCALE_ROUTE_NAME_SUFFIX=D,f.DEFAULT_ROUTES_NAME_SEPARATOR=k,f.DEFAULT_STRATEGY=B,f.DEFAULT_TRAILING_SLASH=M,f.STRATEGIES=Q,f.VERSION=at,f.createLocaleFromRouteGetter=pe,f.createRouter=Xe,f.extendI18n=Le,f.findBrowserLocale=Me,f.getGlobalOptions=me,f.getLocale=H,f.getLocaleCodes=$e,f.getLocales=re,f.getLocalesRegex=Re,f.getRouteBaseName=P,f.isComposer=N,f.isExportedGlobalComposer=$,f.isI18nInstance=U,f.isLegacyVueI18n=y,f.isVueI18n=O,f.localeHead=oe,f.localeLocation=te,f.localePath=q,f.localeRoute=x,f.localizeRoutes=ge,f.proxyVueInstance=C,f.registerGlobalOptions=_e,f.resolveBaseUrl=he,f.resolveRoute=V,f.setLocale=ie,f.switchLocalePath=v,f.useLocaleHead=lt,f.useLocaleLocation=ot,f.useLocalePath=et,f.useLocaleRoute=tt,f.useRouteBaseName=Ze,f.useSwitchLocalePath=nt,Object.defineProperties(f,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),f}({},VueDemi,VueRouter,VueI18n);
{
"name": "vue-i18n-routing",
"description": "The i18n routing with using vue-i18n",
"version": "0.0.0-2adf43f",
"version": "0.0.0-2b5973f",
"dependencies": {
"@intlify/shared": "beta",
"@intlify/vue-i18n-bridge": "^0.3.4",
"@intlify/vue-router-bridge": "^0.3.4",
"ufo": "^0.7.9",
"vue-demi": "^0.12.1"
"@intlify/shared": "latest",
"@intlify/vue-i18n-bridge": "0.3.6",
"@intlify/vue-router-bridge": "0.3.6",
"ufo": "^0.8.5",
"vue-demi": "0.13.5"
},
"devDependencies": {
"@microsoft/api-extractor": "^7.18.20",
"@vue/test-utils": "^1.3.0",
"@microsoft/api-extractor": "^7.28.4",
"api-docs-gen": "^0.4.0",
"rimraf": "^3.0.2",
"typescript": "^4.5.4",
"vite": "^2.7.4",
"typescript": "^4.7.4",
"vite": "^3.0.0",
"vite-plugin-dts": "^0.9.6",
"vue": "^3.2.23",
"vue-i18n": "npm:vue-i18n@next",
"vue-i18n-bridge": "beta",
"vue-i18n-legacy": "npm:vue-i18n@latest",
"vitest": "^0.19.0",
"vue": "^3.2.27",
"vue-i18n": "npm:vue-i18n@latest",
"vue-i18n-bridge": "latest",
"vue-i18n-legacy": "npm:vue-i18n@8",
"vue-router": "^4.0.15",
"vue-router3": "npm:vue-router@3",
"vue-template-compiler": "^2.6.14",
"vue-router": "^4.0.12",
"vue-router3": "npm:vue-router@latest",
"vue2": "npm:vue@2"

@@ -32,4 +32,4 @@ },

"vue": "^2.6.14 || ^3.2.0",
"vue-i18n": "^8.26.1 || ^9.2.0-beta.25",
"vue-i18n-bridge": "^9.2.0-beta.25",
"vue-i18n": "^8.26.1 || ^9.2.0",
"vue-i18n-bridge": "^9.2.0",
"vue-router": "^3.5.3 || ^4.0.0"

@@ -40,2 +40,14 @@ },

"optional": true
},
"vue": {
"optional": true
},
"vue-i18n": {
"optional": true
},
"vue-i18n-bridge": {
"optional": true
},
"vue-router": {
"optional": true
}

@@ -52,7 +64,8 @@ },

"index.mjs",
"types.d.ts",
"LICENSE",
"README.md"
],
"main": "./dist/vue-i18n-routing.cjs.js",
"module": "./dist/vue-i18n-routing.es.js",
"main": "./dist/vue-i18n-routing.js",
"module": "./dist/vue-i18n-routing.mjs",
"unpkg": "dist/vue-i18n-routing.iife.js",

@@ -65,6 +78,12 @@ "jsdelivr": "dist/vue-i18n-routing.iife.js",

"node": "./index.mjs",
"default": "./dist/vue-i18n-routing.es.js"
"default": "./dist/vue-i18n-routing.mjs"
},
"require": "./dist/vue-i18n-routing.cjs.js"
}
"require": "./dist/vue-i18n-routing.js",
"types": "./dist/vue-i18n-routing.d.ts"
},
"./types": {
"types": "./types.d.ts"
},
"./package.json": "./package.json",
"./dist/*": "./dist/*"
},

@@ -86,3 +105,3 @@ "license": "MIT",

"engines": {
"node": ">= 12"
"node": ">= 14.6"
},

@@ -97,4 +116,7 @@ "publishConfig": {

"typecheck": "tsc -p . --noEmit",
"test": "vitest run",
"test:watch": "vitest",
"test:cover": "vitest --coverage",
"build:docs": "api-docs-gen ./temp/vue-i18n-routing.api.json -c ./docsgen.config.js -o ./ -g noprefix"
}
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc