-
-
Notifications
You must be signed in to change notification settings - Fork 483
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: refactor module * chore: module only with context reference * chore: fix build * chore: move all prepare modules to prepare folder
- Loading branch information
Showing
16 changed files
with
374 additions
and
266 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import type { Resolver } from '@nuxt/kit' | ||
import type { LocaleInfo, LocaleObject, NuxtI18nOptions, VueI18nConfigPathInfo } from './types' | ||
import type { Nuxt } from '@nuxt/schema' | ||
import { createResolver, useLogger } from '@nuxt/kit' | ||
import { NUXT_I18N_MODULE_ID } from './constants' | ||
import createDebug from 'debug' | ||
|
||
export interface I18nNuxtContext { | ||
resolver: Resolver | ||
logger: ReturnType<(typeof import('@nuxt/kit'))['useLogger']> | ||
debug: ReturnType<typeof import('debug')> | ||
userOptions: NuxtI18nOptions | ||
options: Required<NuxtI18nOptions> | ||
isDev: boolean | ||
isSSR: boolean | ||
isPrepare: boolean | ||
isSSG: boolean | ||
isBuild: boolean | ||
isTest: boolean | ||
genTemplate: (isServer: boolean, lazy?: boolean) => string | ||
normalizedLocales: LocaleObject<string>[] | ||
localeCodes: string[] | ||
localeInfo: LocaleInfo[] | ||
vueI18nConfigPaths: Required<VueI18nConfigPathInfo>[] | ||
} | ||
|
||
const debug = createDebug('@nuxtjs/i18n:context') | ||
const resolver = createResolver(import.meta.url) | ||
|
||
export function createContext(userOptions: NuxtI18nOptions, nuxt: Nuxt): I18nNuxtContext { | ||
const options = userOptions as Required<NuxtI18nOptions> | ||
|
||
return { | ||
resolver, | ||
logger: useLogger(NUXT_I18N_MODULE_ID), | ||
debug, | ||
userOptions, | ||
options, | ||
isDev: nuxt.options.dev, | ||
isSSR: nuxt.options.ssr, | ||
isPrepare: nuxt.options._prepare, | ||
isSSG: nuxt.options._generate, | ||
isBuild: nuxt.options._build, | ||
isTest: nuxt.options.test, | ||
genTemplate: undefined!, | ||
normalizedLocales: undefined!, | ||
localeCodes: undefined!, | ||
localeInfo: undefined!, | ||
vueI18nConfigPaths: undefined! | ||
} | ||
} |
Oops, something went wrong.