Skip to content

Commit

Permalink
fix: add type exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
BobbieGoede committed Feb 7, 2024
1 parent 99400a9 commit fcdd21f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/runtime/composables/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useRequestHeaders, useCookie as useNuxtCookie } from '#imports'
import { ref, computed, watch, onUnmounted } from 'vue'
import { parseAcceptLanguage, wrapComposable, runtimeDetectBrowserLanguage } from '../internal'
import { localeCodes, normalizedLocales, nuxtI18nOptions } from '#build/i18n.options.mjs'
import { localeCodes, normalizedLocales } from '#build/i18n.options.mjs'
import { getActiveHead } from 'unhead'
import { getNormalizedLocales, initCommonComposableOptions } from '../utils'
import {
Expand Down Expand Up @@ -370,7 +370,7 @@ export function useCookieLocale(): Ref<string> {
const detect = runtimeDetectBrowserLanguage()

if (detect && detect.useCookie) {
const cookieKey = detect.cookieKey
const cookieKey = detect.cookieKey!

let code: string | null = null
if (process.client) {
Expand Down
10 changes: 2 additions & 8 deletions src/runtime/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,7 @@ import {
useNuxtApp,
unref
} from '#imports'
import {
NUXT_I18N_MODULE_ID,
isSSG,
localeCodes,
nuxtI18nOptions,
normalizedLocales
} from '#build/i18n.options.mjs'
import { NUXT_I18N_MODULE_ID, isSSG, localeCodes, nuxtI18nOptions, normalizedLocales } from '#build/i18n.options.mjs'
import { findBrowserLocale, getLocalesRegex, getI18nTarget } from './routing/utils'
import { initCommonComposableOptions, type CommonComposableOptions } from './utils'

Expand Down Expand Up @@ -106,7 +100,7 @@ export function getLocaleCookie(): string | undefined {
return
}

const localeCookie = useNuxtCookie(detect.cookieKey)
const localeCookie = useNuxtCookie(detect.cookieKey!)
const localeCode: string | undefined = localeCookie.value ?? undefined
__DEBUG__ && console.log(`getLocaleCookie cookie (${process.client ? 'client' : 'server'}) -`, localeCode)

Expand Down
8 changes: 2 additions & 6 deletions src/runtime/plugins/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,10 @@ export default defineNuxtPlugin({
const nuxtI18nOptions = { ..._nuxtI18nOptions }
nuxtI18nOptions.baseUrl = extendBaseUrl()


const _detectBrowserLanguage = runtimeDetectBrowserLanguage()

__DEBUG__ && console.log('isSSG', isSSG)
__DEBUG__ &&
console.log(
'useCookie on setup',
_detectBrowserLanguage && _detectBrowserLanguage.useCookie
)
__DEBUG__ && console.log('useCookie on setup', _detectBrowserLanguage && _detectBrowserLanguage.useCookie)
__DEBUG__ && console.log('defaultLocale on setup', nuxtI18nOptions.defaultLocale)

const vueI18nOptions: I18nOptions = await loadVueI18nOptions(vueI18nConfigs, useNuxtApp())
Expand Down Expand Up @@ -370,6 +365,7 @@ export default defineNuxtPlugin({
return () => {}
}
}
// @ts-ignore
app.use(i18n, pluginOptions) // TODO: should implement `{ inject: false } via `nuxtjs/i18n` configuration

// inject for nuxt helpers
Expand Down
1 change: 1 addition & 0 deletions src/runtime/routing/extends/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export function extendI18n<Context = unknown, TI18n extends I18n = I18n>(
const scope = effectScope()

const orgInstall = i18n.install
// @ts-ignore
i18n.install = (vue: NuxtApp['vueApp'], ...options: unknown[]) => {
const pluginOptions = isPluginOptions(options[0]) ? assign({}, options[0]) : { inject: true }
if (pluginOptions.inject == null) {
Expand Down

0 comments on commit fcdd21f

Please sign in to comment.