diff --git a/src/i18nPlugin.ts b/src/i18nPlugin.ts index 7563a37..cce1b72 100644 --- a/src/i18nPlugin.ts +++ b/src/i18nPlugin.ts @@ -1,6 +1,7 @@ import { join } from '@std/path' import { pathname, translationData } from '@/src/store.ts' import type { MiddlewareFn } from '@/src/types.ts' +import type { TranslationState } from '@/src/types.ts' /** * Configuration options for the i18n plugin. @@ -42,7 +43,7 @@ async function readJsonFile(filePath: string): Promise> { export const i18nPlugin = ( { languages, defaultLanguage, localesDir }: I18nOptions, ): MiddlewareFn< - { t: Record>; path: string; locale: string } + TranslationState > => { return async (ctx) => { const url = new URL(ctx.req.url) @@ -58,7 +59,7 @@ export const i18nPlugin = ( // Set the current state values ctx.state.path = rootPath // Valid - ctx.state.locale = lang // Valid + ctx.state.lang = lang // Valid pathname.value = rootPath diff --git a/src/types.ts b/src/types.ts index 2087600..5be80ac 100644 --- a/src/types.ts +++ b/src/types.ts @@ -34,5 +34,5 @@ export type MiddlewareFn = ( export interface TranslationState { t: Record> path: string - locale: string + lang: string }