Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
KishiTheMechanic committed Oct 26, 2024
1 parent db0f6a2 commit f298bc2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/i18nPlugin.ts
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -42,7 +43,7 @@ async function readJsonFile(filePath: string): Promise<Record<string, string>> {
export const i18nPlugin = (
{ languages, defaultLanguage, localesDir }: I18nOptions,
): MiddlewareFn<
{ t: Record<string, Record<string, string>>; path: string; locale: string }
TranslationState
> => {
return async (ctx) => {
const url = new URL(ctx.req.url)
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ export type MiddlewareFn<State = TranslationState> = (
export interface TranslationState {
t: Record<string, Record<string, string>>
path: string
locale: string
lang: string
}

0 comments on commit f298bc2

Please sign in to comment.