vue-i18n-routing
Advanced tools
Comparing version 0.0.0-9551f85 to 0.0.0-99283ca
@@ -1,11 +0,109 @@ | ||
import type { I18n } from 'vue-i18n'; | ||
import { Locale } from 'vue-i18n'; | ||
import type { Route as Route_2 } from 'vue-router3'; | ||
import type { RouteConfig } from 'vue-router3'; | ||
import type { RouteLocationNormalizedLoaded } from 'vue-router'; | ||
import type { Router } from 'vue-router'; | ||
import VueI18n from 'vue-i18n-legacy'; | ||
import VueRouter from 'vue-router3'; | ||
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 { 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 { RouteLocationNormalized } from '@intlify/vue-router-bridge'; | ||
import { RouteLocationNormalizedLoaded } from '@intlify/vue-router-bridge'; | ||
import type { RouteLocationRaw } from '@intlify/vue-router-bridge'; | ||
import type { Router } from '@intlify/vue-router-bridge'; | ||
import type { RouterOptions } from '@intlify/vue-router-bridge'; | ||
import { useRoute } 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> = (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 = { | ||
route?: ReturnType<typeof useRoute>; | ||
router?: ReturnType<typeof useRouter>; | ||
i18n?: Composer; | ||
}; | ||
/** | ||
* 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 I18nRoutingOptions} | ||
* | ||
* @returns A Vue Router instance | ||
* | ||
* @remakrs | ||
* You can create a vue router instance to be used by the Vue app. | ||
* | ||
* The routes of the created router instance are handled with i18n routing. | ||
* | ||
* 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 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; | ||
/** | ||
* Direction | ||
@@ -15,17 +113,233 @@ */ | ||
export declare function extendRouting<TRouter extends VueRouter | Router>({ router, i18n, defaultLocale, trailingSlash, routesNameSeparator, defaultLocaleRouteNameSuffix, localeCodes }?: VueI18nRoutingOptions): TRouter; | ||
export declare type ExtendComposerHook = (compser: Composer) => void; | ||
export declare type I18nRoutingOptions = Pick<VueI18nRoutingOptions, 'defaultLocale' | 'strategy' | 'defaultLocaleRouteNameSuffix' | 'trailingSlash' | 'localeCodes'> & { | ||
routesNameSeparator?: string; | ||
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 interface I18nRoutingReturn { | ||
getRouteBaseName(givenRoute?: Route_2 | RouteLocationNormalizedLoaded): string; | ||
localePath(route: any, locale?: Locale): string; | ||
localeRoute(route: any, locale?: Locale): any; | ||
localeLocation(route: any, locale?: Locale): any; | ||
switchLocalePath(locale: Locale): void; | ||
export declare type ExtendVueI18nHook = (composer: Composer) => ExtendProperyDescripters; | ||
/** | ||
* Find the browser locale | ||
* | ||
* @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 matched the locale code | ||
*/ | ||
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 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 | ||
*/ | ||
export declare interface I18nHeadMetaInfo { | ||
htmlAttrs?: MetaAttrs; | ||
meta?: MetaAttrs[]; | ||
link?: MetaAttrs[]; | ||
} | ||
/** | ||
* Options for {@link localeHead} function | ||
*/ | ||
export declare interface I18nHeadOptions { | ||
/** | ||
* Adds a `dir` attribute to the HTML element. | ||
* | ||
* @defaultValue false | ||
*/ | ||
addDirAttribute?: boolean; | ||
/** | ||
* Adds various SEO attributes. | ||
* | ||
* @defaultValue false | ||
*/ | ||
addSeoAttributes?: boolean | SeoAttributesOptions; | ||
} | ||
/** | ||
* Route config for vue-i18n-routing | ||
*/ | ||
export declare type I18nRoute = Route_2 & RouteLegacy & { | ||
redirect?: string; | ||
}; | ||
/** | ||
* 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 | ||
* | ||
* @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 type LocaleLocationFunction = (route: RawLocation | RouteLocationRaw, locale?: Locale) => Location | RouteLocation | undefined; | ||
/** | ||
* Locale object | ||
@@ -43,18 +357,83 @@ */ | ||
export declare function localizeRoutes(routes: VueI18nRoute[], { defaultLocale, strategy, trailingSlash, routesNameSeparator, defaultLocaleRouteNameSuffix, includeUprefixedFallback, localeCodes }?: Pick<VueI18nRoutingOptions, 'defaultLocale' | 'strategy' | 'localeCodes' | 'routesNameSeparator' | 'trailingSlash' | 'defaultLocaleRouteNameSuffix'> & { | ||
export declare function localePath(this: RoutingProxy, route: RawLocation | RouteLocationRaw, locale?: Locale): string; | ||
/** | ||
* 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 | ||
* | ||
* @returns Returns the localized URL for a given route | ||
* | ||
* @see {@link useLocalePath} | ||
*/ | ||
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 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 | ||
* | ||
* @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 type LocaleRouteFunction = (route: RawLocation | RouteLocationRaw, locale?: Locale) => Route | ReturnType<Router['resolve']> | undefined; | ||
/** | ||
* 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>; | ||
/** | ||
@@ -70,3 +449,55 @@ * Route config for lagacy vue-router v3 | ||
declare const STRATEGIES: { | ||
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 | ||
*/ | ||
export declare interface SeoAttributesOptions { | ||
/** | ||
* An array of strings corresponding to query params you would like to include in your canonical URL. | ||
* | ||
* @defaultValue [] | ||
*/ | ||
canonicalQueries?: string[]; | ||
} | ||
/** | ||
* 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"; | ||
@@ -83,7 +514,81 @@ readonly PREFIX_EXCEPT_DEFAULT: "prefix_except_default"; | ||
export declare function switchLocalePath(this: RoutingProxy, locale: Locale): string; | ||
/** | ||
* Swtich locale path function | ||
* | ||
* @param locale - A locale code, if not specified, uses the current locale | ||
* | ||
* @returns Returns a link to the current route in another language | ||
* | ||
* @see {@link useSwitchLocalePath} | ||
*/ | ||
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; | ||
export declare function useI18nRouting<Legacy extends boolean = false>(options?: I18nRoutingOptions): I18nRoutingReturn; | ||
/** | ||
* Use localize head meta | ||
* | ||
* @param options - An options, see about details {@link I18nHeadOptions}, {@link ComposableOptions}, {@link I18nCommonRoutingOptions} | ||
* | ||
* @returns Genereated SEO head meta information | ||
*/ | ||
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 | ||
@@ -94,38 +599,51 @@ * | ||
*/ | ||
export declare const VERSION = ""; | ||
export declare const VERSION: string; | ||
/** | ||
* 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; | ||
}; | ||
/** | ||
* Vue I18n routing options | ||
* An options of Vue I18n Routing Plugin | ||
*/ | ||
export declare interface VueI18nRoutingOptions { | ||
export declare interface VueI18nRoutingPluginOptions { | ||
/** | ||
* Vue Router instance | ||
* Whether to inject some option APIs style methods into Vue instance | ||
* | ||
* @defaultValue `true` | ||
*/ | ||
router?: VueRouter | Router; | ||
/** | ||
* Vue I18n instance | ||
*/ | ||
i18n?: VueI18n | I18n; | ||
defaultLocale?: string; | ||
localeCodes?: string[] | LocaleObject[]; | ||
strategy?: Strategies; | ||
trailingSlash?: boolean; | ||
routesNameSeparator?: string; | ||
defaultLocaleRouteNameSuffix?: string; | ||
inject?: boolean; | ||
} | ||
export { } | ||
import type { ComputedRef } from 'vue' | ||
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[]> | ||
} | ||
// eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
export interface ComposerCustom extends ComposerCustomProperties {} | ||
} | ||
declare module 'vue-i18n-bridge' { | ||
// 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 _e=Object.defineProperty,he=Object.defineProperties;var Re=Object.getOwnPropertyDescriptors;var x=Object.getOwnPropertySymbols;var k=Object.prototype.hasOwnProperty,H=Object.prototype.propertyIsEnumerable;var Y=(a,n,f)=>n in a?_e(a,n,{enumerable:!0,configurable:!0,writable:!0,value:f}):a[n]=f,w=(a,n)=>{for(var f in n||(n={}))k.call(n,f)&&Y(a,f,n[f]);if(x)for(var f of x(n))H.call(n,f)&&Y(a,f,n[f]);return a},M=(a,n)=>he(a,Re(n));var J=(a,n)=>{var f={};for(var $ in a)k.call(a,$)&&n.indexOf($)<0&&(f[$]=a[$]);if(a!=null&&x)for(var $ of x(a))n.indexOf($)<0&&H.call(a,$)&&(f[$]=a[$]);return f};var VueI18nRouting=function(a,n,f,$){"use strict";/*! | ||
* shared v9.2.0-beta.25 | ||
* (c) 2021 kazuya kawaguchi | ||
const VueI18nRouting=function(f,h,g,N){"use strict";const Ae=(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"},j="",G=Q.PREFIX_EXCEPT_DEFAULT,B=!1,D="___",M="default",Y="ltr",J="";/*! | ||
* shared v9.2.0-beta.37 | ||
* (c) 2022 kazuya kawaguchi | ||
* Released under the MIT License. | ||
*/const j=Object.assign,T=e=>typeof e=="string",K=e=>typeof e=="symbol",Q=e=>typeof e=="symbol";new Set(Object.getOwnPropertyNames(Symbol).map(e=>Symbol[e]).filter(Q));function y(e){return Boolean(e&&e.__v_isRef===!0)}Promise.resolve();function Z(e){e=e||[];const r=[];for(const c of e)T(c)?r.push({code:c}):r.push(c);return r}function V(e,r){return y(e.locale)&&r==="composition"}function G(e){return"global"in e&&"mode"in e}function v(e){return G(e)?V(e.global,e.mode)?e.global.locale.value:e.global.locale:y(e.locale)?e.locale.value:e.locale}function q(e,r){G(e)?V(e.global,e.mode)?e.global.locale.value=r:e.global.locale=r:y(e.locale)&&(e.locale.value=r)}function D(e,r,c){return e.replace(/\/+$/,"")+(r?"/":"")||(c?"":"/")}function ee(e,{localeCodes:r=[]}={}){if(!V(e.global,e.mode))throw new Error("");const c=n.ref(r);e.global.locales=n.computed(()=>c.value),console.log("... extends i18n done")}const oe={PREFIX:"prefix",PREFIX_EXCEPT_DEFAULT:"prefix_except_default",PREFIX_AND_DEFAULT:"prefix_and_default",NO_PREFIX:"no_prefix"},O="",B=oe.PREFIX_EXCEPT_DEFAULT,z=!1,U="___",N="default";function C(e,{defaultLocale:r=O,strategy:c=B,trailingSlash:d=z,routesNameSeparator:h=U,defaultLocaleRouteNameSuffix:R=N,includeUprefixedFallback:_=!1,localeCodes:A=[]}={}){if(c==="no_prefix")return e;const m=A.map(o=>T(o)?o:o.code);function g(o,E,F=!1,p=!1){return o.redirect&&(!o.component||!o.file)?[o]:E.reduce((s,l)=>{const{name:t}=o;let{path:i}=o;const u=w({},o);t&&(u.name=`${t}${h}${l}`),o.children&&(u.children=o.children.reduce((P,X)=>[...P,...g(X,[l],!0,p)],[]));const S=l===r;if(S&&c==="prefix_and_default")if(F)F&&p&&t&&(u.name+=`${h}${R}`);else{const P=M(w({},u),{path:i});if(t&&(P.name=`${u.name}${h}${R}`),o.children){P.children=[];for(const X of o.children)P.children=P.children.concat(g(X,[l],!0,!0))}s.push(P)}const L=F&&!i.startsWith("/"),I=!L&&!(S&&c==="prefix_except_default");return I&&(i=`/${l}${i}`),i&&(i=D(i,d,L)),I&&S&&c==="prefix"&&_&&s.push(w({},o)),u.path=i,s.push(u),s},[])}return e.reduce((o,E)=>[...o,...g(E,m||[])],[])}function te(e){return new RegExp(`^/(${e.join("|")})(?:/|$)`,"i")}function ne(e,r,c){const d=`(${e.join("|")})`,h=`(?:${r}${c})?`,R=new RegExp(`${r}${d}${h}$`,"i"),_=te(e);return m=>{if(m.name){const o=(T(m.name)?m.name:m.name.toString()).match(R);if(o&&o.length>1)return o[1]}else if(m.path){const g=m.path.match(_);if(g&&g.length>1)return g[1]}return""}}function ce({router:e,i18n:r,defaultLocale:c=O,strategy:d=B,trailingSlash:h=z,routesNameSeparator:R=U,defaultLocaleRouteNameSuffix:_=N,localeCodes:A=[]}={}){const m=Z(A),g=ne(m.map(o=>o.code),R,_);if(ee(r,{localeCodes:m}),n.isVue2){const o=e,E=o.constructor,F=o.options.routes||[],p=C(F,{localeCodes:A,defaultLocale:c,strategy:d,trailingSlash:h,routesNameSeparator:R,defaultLocaleRouteNameSuffix:_});console.log("vue2 routes",F,p);const b=new E({mode:"history",base:o.options.base,routes:p});return b.__defaultLocale=c,b.__strategy=d,b.__trailingSlash=h,b.__routesNameSeparator=R,b.__defaultLocaleRouteNameSuffix=_,b.beforeEach((s,l,t)=>{console.log("beforeEach",s,l);const i=v(r),u=g(s)||i||c||"";console.log("currentLocale",i,"finalLocale",u),i!==u&&q(r,u),t()}),b}else{const o=e,E=o.options.routes||[],F=C(E,{localeCodes:A,defaultLocale:c,strategy:d,trailingSlash:h,routesNameSeparator:R,defaultLocaleRouteNameSuffix:_});return console.log("vue3 routes",E,F,o),E.forEach(p=>o.removeRoute(p.name)),F.forEach(p=>o.addRoute(p)),o.__defaultLocale=c,o.__strategy=d,o.__trailingSlash=h,o.__routesNameSeparator=R,o.__defaultLocaleRouteNameSuffix=_,o.beforeEach((p,b,s)=>{console.log("beforeEach",p,b);const l=v(r),t=g(p)||l||c||"";console.log("currentLocale",l,"finalLocale",t),l!==t&&q(r,t),s()}),o}}const se=()=>{const e=n.getCurrentInstance();if(e==null)throw new Error("should be used in setup");return e.$router},re=()=>{const e=n.getCurrentInstance();if(e==null)throw new Error("should be used in setup");return n.computed(()=>e.$route)};function le(){return n.isVue2?re():f.useRoute()}function ae(){return n.isVue2?se():f.useRouter()}function ue(){return $.useI18n()}function ie(e={}){const r=ue(),c=ae(),d=le(),h=e.defaultLocaleRouteNameSuffix||c.__defaultLocaleRouteNameSuffix,R=e.defaultLocale||c.__defaultLocale,_=e.routesNameSeparator||c.__routesNameSeparator,A=e.strategy||c.__strategy;function m(s){const l=s!=null?s:n.isRef(d)?d.value:d;return l.name?W(l.name).split(_)[0]:void 0}function g(s,l){let t=W(s)+(A==="no_prefix"?"":_+l);return l===R&&A==="prefix_and_default"&&(t+=_+h),t}function o(s,l){const t=l||v(r);let i=s;T(s)&&(s[0]==="/"?i={path:s}:i={name:s});let u=j({},i);if(u.path&&!u.name){const L=c.resolve(u),I=n.isVue2?L.route:L,P=m(I);T(P)&&(u={name:g(P,t),params:I.params,query:I.query,hash:I.hash})}else{u.name=g(u.name,t);const{params:L}=u;L&&L["0"]===void 0&&L.pathMatch&&(L["0"]=L.pathMatch)}const S=c.resolve(u);return(n.isVue2?S.route.name:S.name)?S:c.resolve(s)}function E(s,l){const t=o(s,l);return t==null?"":n.isVue2?t.route.redirectedFrom||t.route.fullPath:t.redirectedFrom||t.fullPath}function F(s,l){const t=o(s,l);return t==null?void 0:n.isVue2?t.route:t}function p(s,l){const t=o(s,l);return t==null?void 0:n.isVue2?t.location:t.href}function b(s){const l=m();if(!l)return"";const I=n.isVue2&&n.isRef(d)?d.value:d,{params:t}=I,i=J(I,["params"]),u={},S=j({},i,{name:l,params:M(w(w({},t),u),{0:t.pathMatch})}),L=E(S,s);return console.log("switchLocalePath",r.locale.value,s,L),L}return{localePath:E,localeRoute:F,localeLocation:p,switchLocalePath:b}}function W(e){return T(e)?e:K(e)?e.toString():""}function fe({router:e,i18n:r,defaultLocale:c=O,trailingSlash:d=z,routesNameSeparator:h=U,defaultLocaleRouteNameSuffix:R=N,localeCodes:_=[]}={}){if(e==null)throw new Error("TODO");return ce({router:e,i18n:r,defaultLocale:c,trailingSlash:d,routesNameSeparator:h,defaultLocaleRouteNameSuffix:R,localeCodes:_})}const de="";return a.VERSION=de,a.extendRouting=fe,a.localizeRoutes=C,a.useI18nRouting=ie,Object.defineProperty(a,"__esModule",{value:!0}),a[Symbol.toStringTag]="Module",a}({},VueDemi,VueRouter,VueI18n); | ||
*/process.env.NODE_ENV;const Ie=typeof Symbol=="function"&&typeof Symbol.toStringTag=="symbol",Te=e=>Ie?Symbol(e):e,k=Object.assign,ye=Array.isArray,Oe=e=>typeof e=="function",y=e=>typeof e=="string",Pe=e=>typeof e=="boolean",Ce=e=>typeof e=="symbol",K=e=>e!==null&&typeof e=="object",be=/\/$|\/\?/;function Z(e="",t=!1){return t?be.test(e):e.endsWith("/")}function Ue(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 Ne(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 Fe=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)y(o)?t.push({code:o}):t.push(o);return t}function F(e){return e!=null&&"global"in e&&"mode"in e}function w(e){return e!=null&&!("__composer"in e)&&h.isRef(e.locale)}function C(e){return e!=null&&"__composer"in e}function z(e){return e!=null&&!("__composer"in e)&&!h.isRef(e.locale)}function O(e){return e!=null&&("__VUE_I18N_BRIDGE__"in e||"_sync"in e)}function se(e){return F(e)?w(e.global)?e.global:e.global.__composer:C(e)?e.__composer:e}function H(e){const t=F(e)?e.global:e;return w(t)?h.isVue2&&O(e)?e.locale:t.locale.value:(z(t)||C(t)||O(t),t.locale)}function we(e){const t=F(e)?e.global:e;return w(t)?h.isVue2&&O(e)?e.locales:t.locales.value:(z(t)||C(t)||O(t),t.locales)}function re(e,t){const o=F(e)?e.global:e;if(w(o))h.isVue2&&O(e)?e.locale=t:o.locale.value=t;else if(z(o)||C(o)||O(o))o.locale=t;else throw new Error("TODO:")}function $e(e,t,o){return e.replace(/\/+$/,"")+(t?"/":"")||(o?"":"/")}function ie(e){return g.isVueRouter4,h.isRef(e)?e.value:e}function ue(e){return y(e)?e:Ce(e)?e.toString():"(null)"}function fe(e,t,{defaultLocale:o,strategy:n,routesNameSeparator:a,defaultLocaleRouteNameSuffix:l}){let c=ue(e)+(n==="no_prefix"?"":a+t);return t===o&&n==="prefix_and_default"&&(c+=a+l),c}function de(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 Ve=ve;function je(e,t){return e.score===t.score?t.code.length-e.code.length:t.score-e.score}const Ge=je;function Be(e,t,{matcher:o=Ve,comparer:n=Ge}={}){const a=[];for(const c of e){const{code:s}=c,r=c.iso||s;a.push({code:s,iso:r})}const l=o(a,t);return l.length>1&&l.sort(n),l.length?l[0].code:""}function T(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 he(e,{locales:t=[],localeCodes:o=[],baseUrl:n=J,hooks:a={}}={}){const l=h.effectScope(),c=e.install;return e.install=(s,...r)=>{Reflect.apply(c,e,[s,...r]);const u=se(e);l.run(()=>De(u,{locales:t,localeCodes:o,baseUrl:n,hooks:a})),C(e.global)&&ke(e.global,a.onExtendVueI18n);const d=s,i=e.mode==="composition"?h.isVue3?d.config.globalProperties.$i18n:e:h.isVue2?e:null;if(i&&Me(i,u,a.onExtendExportedGlobal),(ze(r[0])?r[0]:{inject:!0}).inject&&s.mixin({methods:{resolveRoute:T($),localePath:T(x),localeRoute:T(q),localeLocation:T(te),switchLocalePath:T(v),getRouteBaseName:T(b),localeHead:T(oe)}}),d.unmount){const L=d.unmount;d.unmount=()=>{l.stop(),L()}}},l}function De(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=de(a,{}),t.hooks&&t.hooks.onExtendComposer&&t.hooks.onExtendComposer(e)}function Me(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 ke(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 ze(e){return K(e)&&"inject"in e&&Pe(e.inject)}function Le(e,{defaultLocale:t=j,strategy:o=G,trailingSlash:n=B,routesNameSeparator:a=D,defaultLocaleRouteNameSuffix:l=M,includeUprefixedFallback:c=!1,optionsResolver:s=void 0,locales:r=[]}={}){if(o==="no_prefix")return e;const u=r.map(i=>y(i)?i:i.code);function d(i,_,L=!1,S=!1){if(i.redirect&&(!i.component||!i.file))return[i];let R=null;if(s!=null&&(R=s(i,_),R==null))return[i];const p={locales:u,paths:{}};if(R!=null&&k(p,R),k(p,{locales:_}),p.locales.length>0&&R&&R.locales!=null&&R.locales.length>0){const E=[];for(const m of p.locales)R.locales.includes(m)&&E.push(m);p.locales=E}return p.locales.reduce((E,m)=>{const{name:V}=i;let{path:A}=i;const I={...i};V&&(I.name=`${V}${a}${m}`),i.children&&(I.children=i.children.reduce((P,le)=>[...P,...d(le,[m],!0,S)],[])),p.paths&&p.paths[m]&&(A=p.paths[m]);const U=m===t;if(U&&o==="prefix_and_default")if(L)L&&S&&V&&(I.name+=`${a}${l}`);else{const P={...I,path:A};if(V&&(P.name=`${I.name}${a}${l}`),i.children){P.children=[];for(const le of i.children)P.children=P.children.concat(d(le,[m],!0,!0))}E.push(P)}const Ee=L&&!A.startsWith("/"),Se=!Ee&&!(U&&o==="prefix_except_default");return Se&&(A=`/${m}${A}`),A&&(A=$e(A,n,Ee)),Se&&U&&o==="prefix"&&c&&E.push({...i}),I.path=A,E.push(I),E},[])}return e.reduce((i,_)=>[...i,...d(_,u||[])],[])}const ee=Te("vue-i18n-routing-gor");function ge(e,t){e[ee]?ae("already registered global options"):e[ee]=t}function _e(e){var t;return(t=e[ee])!=null?t:{}}function He(e,t={}){const{version:o,defaultLocale:n,locales:a,strategy:l,trailingSlash:c,routesNameSeparator:s,defaultLocaleRouteNameSuffix:r,defaultDirection:u,baseUrl:d,routes:i,routeOptionsResolver:_}=xe(t),L=ce(a),S=L.map(m=>m.code),R=Re(S,s,r);he(e,{locales:L,baseUrl:d,localeCodes:S});const p=Le(i,{locales:a,defaultLocale:n,strategy:l,trailingSlash:c,routesNameSeparator:s,defaultLocaleRouteNameSuffix:r,optionsResolver:_});t.routes=p;const E=Xe(t,o);return ge(E,{defaultLocale:n,localeCodes:S,strategy:l,trailingSlash:c,routesNameSeparator:s,defaultLocaleRouteNameSuffix:r,defaultDirection:u}),E.beforeEach((m,V,A)=>{const I=H(e),U=R(m)||I||n||"";I!==U&&re(e,U),A()}),E}function Xe(e,t){if(h.isVue3&&t===4)return g.createRouter(e);if(h.isVue2&&t===3)return new Ae.default(e);throw new Error("TODO:")}function me(e){return new RegExp(`^/(${e.join("|")})(?:/|$)`,"i")}function Re(e,t,o){const n=`(${e.join("|")})`,a=`(?:${t}${o})?`,l=new RegExp(`${t}${n}${a}$`,"i"),c=me(e);return r=>{if(K(r)){if(r.name){const d=(y(r.name)?r.name:r.name.toString()).match(l);if(d&&d.length>1)return d[1]}else if(r.path){const u=r.path.match(c);if(u&&u.length>1)return u[1]}}else if(y(r)){const u=r.match(c);if(u&&u.length>1)return u[1]}return""}}function xe(e){var t,o,n,a,l,c,s,r,u,d;return e.version=(t=e.version)!=null?t:4,e.defaultLocale=(o=e.defaultLocale)!=null?o:j,e.strategy=(n=e.strategy)!=null?n:G,e.trailingSlash=(a=e.trailingSlash)!=null?a:B,e.routesNameSeparator=(l=e.routesNameSeparator)!=null?l:D,e.defaultLocaleRouteNameSuffix=(c=e.defaultLocaleRouteNameSuffix)!=null?c:M,e.locales=(s=e.locales)!=null?s:[],e.defaultDirection=(r=e.defaultDirection)!=null?r:Y,e.baseUrl=(u=e.baseUrl)!=null?u:J,e.routes=(d=e.routes)!=null?d:[],e}function X(e,t,{defaultLocale:o=j,defaultDirection:n=Y,defaultLocaleRouteNameSuffix:a=M,routesNameSeparator:l=D,strategy:c=G,trailingSlash:s=B,localeCodes:r=[]}={}){const u=_e(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||r}}const qe=new Set(["prefix_and_default","prefix_except_default"]);function b(e){const t=this.router,{routesNameSeparator:o}=X(t,this),n=e!=null?h.isRef(e)?h.unref(e):e:this.route;return n.name?ue(n.name).split(o)[0]:void 0}function x(e,t){const o=$.call(this,e,t);return o==null?"":h.isVue3?o.redirectedFrom||o.fullPath:o.route.redirectedFrom||o.route.fullPath}function q(e,t){const o=$.call(this,e,t);return o==null?void 0:h.isVue3?o:o.route}function te(e,t){const o=$.call(this,e,t);return o==null?void 0:h.isVue3?o:o.location}function $(e,t){const o=this.router,n=this.i18n,a=t||H(n),{routesNameSeparator:l,defaultLocale:c,defaultLocaleRouteNameSuffix:s,strategy:r,trailingSlash:u}=X(o,this);let d=e;y(e)&&(d[0]==="/"?d={path:e}:d={name:e});let i=k({},d);if(i.path&&!i.name){const L=o.resolve(i),S=h.isVue3?L:L.route,R=b.call(this,S);y(R)?i={name:fe(R,a,{defaultLocale:c,strategy:r,routesNameSeparator:l,defaultLocaleRouteNameSuffix:s}),params:S.params,query:S.query,hash:S.hash}:(!(a===c&&qe.has(r))&&r!=="no_prefix"&&(i.path=`/${a}${i.path}`),i.path=u?Ne(i.path,!0):Ue(i.path,!0))}else{i.name=fe(i.name,a,{defaultLocale:c,strategy:r,routesNameSeparator:l,defaultLocaleRouteNameSuffix:s});const{params:L}=i;L&&L[0]===void 0&&L.pathMatch&&(L[0]=L.pathMatch)}const _=o.resolve(i);return(h.isVue3?_.name:_.route.name)?_:o.resolve(e)}function v(e){const t=this.route,o=b.call(this,t);if(!o)return"";const{params:n,...a}=!h.isVue3&&h.isRef(t)?t.value:t,c=k({},a,{name:o,params:{...n,...{},0:n.pathMatch}});return x.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=we(n),r=ce(s).find(i=>i.code===c)||{code:c},u=r.iso,d=r.dir||a;return e&&(l.htmlAttrs.dir=d),t&&c&&n.locales&&(u&&(l.htmlAttrs.lang=u),We.call(this,s,n.__baseUrl,l.link),Qe.call(this,n.__baseUrl,l.link,t),Ye(r,u,l.meta),Je(s,u,l.meta)),l}function We(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 r=s.iso;if(!r){ae("Locale ISO code is required to generate alternate link");continue}const[u,d]=r.split("-");u&&d&&(s.isCatchallLocale||!c.has(u))&&c.set(u,s),c.set(r,s)}for(const[s,r]of c.entries()){const u=v.call(this,r.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 Qe(e,t,o){const n=this.route,a=q.call(this,{...n,name:b.call(this,n)});if(a){let l=ne(a.path,e);const c=K(o)&&o.canonicalQueries||[];if(c.length){const s=a.query,r=new URLSearchParams;for(const d of c)if(d in s){const i=s[d];ye(i)?i.forEach(_=>r.append(d,_||"")):r.append(d,i||"")}const u=r.toString();u&&(l=`${l}?${u}`)}t.push({hid:"i18n-can",rel:"canonical",href:l})}}function Ye(e,t,o){!(e&&t)||o.push({hid:"i18n-og",property:"og:locale",content:pe(t)})}function Je(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:pe(l.iso)}));o.push(...a)}}function pe(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:r,routesNameSeparator:u}=e;return function(...d){return Reflect.apply(t,{router:o,route:n,i18n:a,defaultLocale:l,strategy:c,defaultLocaleRouteNameSuffix:s,trailingSlash:r,routesNameSeparator:u},d)}}function Ke(e=g.useRoute(),{router:t=g.useRouter(),routesNameSeparator:o=void 0}={}){const n={router:t,route:e,routesNameSeparator:o};return b.call(n,e)}function Ze({router:e=g.useRouter(),route:t=g.useRoute(),i18n:o=N.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 et({router:e=g.useRouter(),route:t=g.useRoute(),i18n:o=N.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=N.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 ot({router:e=g.useRouter(),route:t=g.useRoute(),i18n:o=N.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 nt({addDirAttribute:e=!1,addSeoAttributes:t=!1,strategy:o=void 0,defaultLocale:n=void 0,route:a=g.useRoute(),router:l=g.useRouter(),i18n:c=N.useI18n()}={}){const s=l,r=h.ref({htmlAttrs:{},link:[],meta:[]});function u(){r.value={htmlAttrs:{},link:[],meta:[]}}function d(i){r.value=Reflect.apply(oe,{router:l,route:i,i18n:c,defaultLocale:n,strategy:o},[{addDirAttribute:e,addSeoAttributes:t}])}if(Fe)if(h.isVue3){const i=h.watchEffect(()=>{u(),d(ie(s.currentRoute))});h.onUnmounted(()=>i())}else{const i=s.afterEach((_,L)=>{u(),d(_)});h.onUnmounted(()=>i()),d(a)}else d(ie(s.currentRoute));return r}const lt="0.0.0";return f.DEFAULT_BASE_URL=J,f.DEFAULT_DETECTION_DIRECTION=Y,f.DEFAULT_LOCALE=j,f.DEFAULT_LOCALE_ROUTE_NAME_SUFFIX=M,f.DEFAULT_ROUTES_NAME_SEPARATOR=D,f.DEFAULT_STRATEGY=G,f.DEFAULT_TRAILING_SLASH=B,f.STRATEGIES=Q,f.VERSION=lt,f.createLocaleFromRouteGetter=Re,f.createRouter=He,f.extendI18n=he,f.findBrowserLocale=Be,f.getGlobalOptions=_e,f.getLocale=H,f.getLocalesRegex=me,f.getRouteBaseName=b,f.isComposer=w,f.isExportedGlobalComposer=z,f.isI18nInstance=F,f.isLegacyVueI18n=O,f.isVueI18n=C,f.localeHead=oe,f.localeLocation=te,f.localePath=x,f.localeRoute=q,f.localizeRoutes=Le,f.proxyVueInstance=T,f.registerGlobalOptions=ge,f.resolveBaseUrl=de,f.resolveRoute=$,f.setLocale=re,f.switchLocalePath=v,f.useLocaleHead=nt,f.useLocaleLocation=tt,f.useLocalePath=Ze,f.useLocaleRoute=et,f.useRouteBaseName=Ke,f.useSwitchLocalePath=ot,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-9551f85", | ||
"version": "0.0.0-99283ca", | ||
"dependencies": { | ||
"@intlify/shared": "beta", | ||
"vue-demi": "*" | ||
"@intlify/shared": "next", | ||
"@intlify/vue-i18n-bridge": "^0.3.5", | ||
"@intlify/vue-router-bridge": "^0.3.5", | ||
"ufo": "^0.7.9", | ||
"vue-demi": "^0.12.1" | ||
}, | ||
"devDependencies": { | ||
"@microsoft/api-extractor": "^7.18.20", | ||
"@microsoft/api-extractor": "^7.28.4", | ||
"api-docs-gen": "^0.4.0", | ||
"rimraf": "^3.0.2", | ||
"vite": "^2.7.4", | ||
"typescript": "^4.7.4", | ||
"vite": "^3.0.0", | ||
"vite-plugin-dts": "^0.9.6", | ||
"vue": "^3.2.23", | ||
"vitest": "^0.18.0", | ||
"vue": "^3.2.27", | ||
"vue-i18n": "npm:vue-i18n@next", | ||
"vue-i18n-bridge": "beta", | ||
"vue-i18n-legacy": "npm:vue-i18n@latest", | ||
"vue-router": "^4.0.12", | ||
"vue-router3": "npm:vue-router@latest", | ||
"vue-i18n-bridge": "next", | ||
"vue-i18n-legacy": "npm:vue-i18n@8", | ||
"vue-router": "^4.0.15", | ||
"vue-router3": "npm:vue-router@3", | ||
"vue-template-compiler": "^2.6.14", | ||
"vue2": "npm:vue@2" | ||
@@ -26,2 +32,4 @@ }, | ||
"vue": "^2.6.14 || ^3.2.0", | ||
"vue-i18n": "^8.26.1 || ^9.2.0-beta.37", | ||
"vue-i18n-bridge": "^9.2.0-beta.37", | ||
"vue-router": "^3.5.3 || ^4.0.0" | ||
@@ -32,2 +40,14 @@ }, | ||
"optional": true | ||
}, | ||
"vue": { | ||
"optional": true | ||
}, | ||
"vue-i18n": { | ||
"optional": true | ||
}, | ||
"vue-i18n-bridge": { | ||
"optional": true | ||
}, | ||
"vue-router": { | ||
"optional": true | ||
} | ||
@@ -44,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", | ||
@@ -57,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/*" | ||
}, | ||
@@ -88,4 +115,7 @@ "license": "MIT", | ||
"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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Wildcard dependency
QualityPackage has a dependency with a floating version range. This can cause issues if the dependency publishes a new major version.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
83125
11
1542
0
10
15
2
1
+ Addedufo@^0.7.9
+ Added@intlify/core-base@9.14.2(transitive)
+ Added@intlify/message-compiler@9.14.2(transitive)
+ Added@intlify/shared@11.0.0-rc.19.14.2(transitive)
+ Added@intlify/vue-devtools@9.14.2(transitive)
+ Added@intlify/vue-i18n-bridge@0.3.6(transitive)
+ Added@intlify/vue-router-bridge@0.3.6(transitive)
+ Addedufo@0.7.11(transitive)
+ Addedvue-demi@0.12.5(transitive)
+ Addedvue-i18n@9.14.2(transitive)
+ Addedvue-i18n-bridge@9.14.2(transitive)
- Removed@intlify/shared@9.3.0-beta.27(transitive)
Updated@intlify/shared@next
Updatedvue-demi@^0.12.1