Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion packages/h3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
},
"dependencies": {
"@intlify/core": "^11.1.12",
"@intlify/utils": "^0.13.0"
"@intlify/utils": "catalog:"
},
"devDependencies": {
"@types/node": "catalog:",
Expand Down
14 changes: 14 additions & 0 deletions packages/h3/src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ import type { H3Event } from 'h3'

test('detectLocaleFromAcceptLanguageHeader', () => {
const eventMock = {
web: {
request: {
headers: {
get: _name => (_name === 'accept-language' ? 'en-US,en;q=0.9,ja;q=0.8' : '')
}
}
},
node: {
req: {
method: 'GET',
Expand Down Expand Up @@ -57,6 +64,13 @@ describe('useTranslation', () => {
}
})
const eventMock = {
web: {
request: {
headers: {
get: _name => (_name === 'accept-language' ? 'ja;q=0.9,en;q=0.8' : '')
}
}
},
node: {
req: {
method: 'GET',
Expand Down
5 changes: 3 additions & 2 deletions packages/h3/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import {
// @ts-expect-error -- NOTE(kazupon): internal function
parseTranslateArgs
} from '@intlify/core'
import { getHeaderLocale } from '@intlify/utils/h3'
import { getHeaderLocale } from '@intlify/utils'
import { toWebRequest } from 'h3'

export * from '@intlify/utils/h3'

Expand Down Expand Up @@ -172,7 +173,7 @@ export function defineI18nMiddleware<
* @returns A locale string, which will be detected of **first** from `Accept-Language` header
*/
export const detectLocaleFromAcceptLanguageHeader = (event: H3Event): Locale =>
getHeaderLocale(event).toString()
getHeaderLocale(toWebRequest(event)).toString()

/**
* The type definition of Locale Message for `@intlify/h3` package
Expand Down
2 changes: 1 addition & 1 deletion packages/hono/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
},
"dependencies": {
"@intlify/core": "^9.6.0",
"@intlify/utils": "^0.11.1"
"@intlify/utils": "catalog:"
},
"devDependencies": {
"@cloudflare/workers-types": "^4.20231016.0",
Expand Down
18 changes: 15 additions & 3 deletions packages/hono/src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ import {
test('detectLocaleFromAcceptLanguageHeader', () => {
const mockContext = {
req: {
header: _name => (_name === 'accept-language' ? 'en-US,en;q=0.9,ja;q=0.8' : '')
raw: {
headers: {
get: _name => (_name === 'accept-language' ? 'en-US,en;q=0.9,ja;q=0.8' : '')
}
}
}
} as Context

Expand Down Expand Up @@ -54,7 +58,11 @@ describe('useTranslation', () => {
})
const mockContext = {
req: {
header: _name => (_name === 'accept-language' ? 'ja;q=0.9,en;q=0.8' : '')
raw: {
headers: {
get: _name => (_name === 'accept-language' ? 'ja;q=0.9,en;q=0.8' : '')
}
}
},
get: (_key: string) => context
} as Context
Expand All @@ -71,7 +79,11 @@ describe('useTranslation', () => {
test('not initialize context', () => {
const mockContext = {
req: {
header: _name => 'ja,en'
raw: {
headers: {
get: _name => 'ja,en'
}
}
},
get: (_key: string) => {}
} as Context
Expand Down
4 changes: 2 additions & 2 deletions packages/hono/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/

import { translate as _translate, createCoreContext, NOT_REOSLVED } from '@intlify/core'
import { getHeaderLocale } from '@intlify/utils/hono'
import { getHeaderLocale } from '@intlify/utils'

export * from '@intlify/utils/hono'

Expand Down Expand Up @@ -172,7 +172,7 @@ export function defineI18nMiddleware<
* ```
*/
export const detectLocaleFromAcceptLanguageHeader = (ctx: Context): Locale =>
getHeaderLocale(ctx).toString()
getHeaderLocale(ctx.req.raw).toString()

type ResolveResourceKeys<
Schema extends Record<string, any> = {}, // eslint-disable-line @typescript-eslint/no-explicit-any -- NOTE(kazupon): generic type
Expand Down
25 changes: 11 additions & 14 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ catalog:
typescript: ^5.9.3
tsdown: ^0.16.4
publint: ^0.3.15
'@intlify/utils': ^1.0.1
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Verify the new major version and check for breaking changes.

This is a major version upgrade for @intlify/utils (from 0.x to 1.x). Ensure that version ^1.0.1 exists and review the changelog for any breaking changes that might affect the workspace.


🌐 Web query:

What are the breaking changes in @intlify/utils version 1.0.1?

💡 Result:

I can look this up — may I search the web for the @intlify/utils v1.0.1 changelog/releases?


The specified version of @intlify/utils does not exist.

The latest version of @intlify/utils is 0.13.0, last published 2 years ago. Version ^1.0.1 does not exist in the npm registry. This will cause dependency resolution to fail unless this is a planned future release or the version specification is incorrect. Verify that the version constraint should be updated to match an existing release (e.g., ^0.13.0) or confirm this version will be published.

🤖 Prompt for AI Agents
In pnpm-workspace.yaml around line 11, the dependency entry '@intlify/utils':
^1.0.1 references a non-existent release and will break installs; update the
version constraint to a valid published version (for example '^0.13.0') or
change it to a tag that exists (e.g., 'latest') / a workspace path if you intend
to use a local package, then run pnpm install to verify resolution succeeds.


minimumReleaseAge: 1440

Expand Down
Loading