Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions packages/h3/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import {
translate as _translate,
createCoreContext,
NOT_REOSLVED,
resolveValue,
compile,
fallbackWithLocaleChain,
// @ts-expect-error -- NOTE(kazupon): internal function
parseTranslateArgs
} from '@intlify/core'
Expand Down Expand Up @@ -198,6 +201,13 @@ export function defineIntlifyMiddleware<
const context = getEventContext<H3EventContext>(event)
context[SYMBOL_INTLIFY_LOCALE] = getLocaleDetector(event, intlify as CoreContext)
intlify.locale = context[SYMBOL_INTLIFY_LOCALE]

// @intlify/core has `sideEffects: false`. Some bundlers (like esbuild, used by cloudflare), may tree-shake the `register` calls in `core/src/index.ts`
// To get around this, we can explicitly set the compiler, messageResolver, and localeFallbacker here
intlify.messageCompiler = compile
intlify.messageResolver = resolveValue
intlify.localeFallbacker = fallbackWithLocaleChain

context[SYMBOL_INTLIFY] = intlify as CoreContext
}),
onResponse: onResponse((_, event) => {
Expand Down