Skip to content

Conversation

@kazupon
Copy link
Member

@kazupon kazupon commented Nov 21, 2025

Description

Linked Issues

Additional context

Summary by CodeRabbit

  • Documentation

    • Updated docs and examples to use the new Intlify naming and to reflect renamed middleware and resources.
    • Replaced context parameter name from ctx to c across examples and API docs.
  • Refactor

    • Standardized naming and context keys in the Hono integration to match the Intlify-centric API surface.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Nov 21, 2025

Walkthrough

This PR renames the Hono integration surface from i18n → intlify (public API, context keys, examples, docs, tests) and standardizes context parameter names from ctx to c across implementation, docs, examples, and tests.

Changes

Cohort / File(s) Summary
Documentation
packages/hono/README.md, packages/hono/docs/index.md, packages/hono/docs/functions/defineIntlifyMiddleware.md, packages/hono/docs/functions/detectLocaleFromAcceptLanguageHeader.md, packages/hono/docs/functions/getDetectorLocale.md, packages/hono/docs/functions/useTranslation.md
Renamed defineI18nMiddlewaredefineIntlifyMiddleware, replaced i18nintlify in examples and descriptions, and changed parameter name ctxc in function docs and samples.
Playground examples
packages/hono/playground/basic/index.ts, packages/hono/playground/global-schema/index.ts, packages/hono/playground/local-schema/index.ts, packages/hono/playground/typesafe-schema/index.ts
Updated imports and calls to defineIntlifyMiddleware, renamed local bindings i18nintlify, and adjusted app.use('*', ...) usages accordingly.
Tests
packages/hono/spec/integration.spec.ts, packages/hono/src/index.test.ts, packages/hono/src/index.test-d.ts
Updated tests to use defineIntlifyMiddleware, renamed middleware variables to intlify, changed context key lookups ('i18n''intlify', 'i18nLocaleDetector''intlifyLocaleDetector'), and standardized detector callback params from ctxc.
Source implementation
packages/hono/src/index.ts
Renamed exported API defineI18nMiddlewaredefineIntlifyMiddleware, changed internal context keys and variables from i18n/i18nLocaleDetectorintlify/intlifyLocaleDetector, and updated function signatures and internal usage to accept c instead of ctx (e.g., detectLocaleFromAcceptLanguageHeader, getDetectorLocale, useTranslation).

Sequence Diagram(s)

sequenceDiagram
  participant App
  participant HonoMiddleware as defineIntlifyMiddleware
  participant Detector as LocaleDetector
  participant Handler

  Note over App,HonoMiddleware `#DDDDFF`: Request flow with renamed middleware/key
  App->>HonoMiddleware: request -> middleware(c)
  HonoMiddleware->>Detector: call detector(c)
  Detector-->>HonoMiddleware: locale
  HonoMiddleware->>App: set context 'intlify' & 'intlifyLocaleDetector'
  App->>Handler: handler(c) uses useTranslation(c)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Pay extra attention to:
    • consistency of context key renames in packages/hono/src/index.ts and tests,
    • API export/name change (ensure package exports and typing reflect defineIntlifyMiddleware),
    • docs/examples for accurate parameter and call-site updates.

Possibly related PRs

Suggested labels

feature, Hono

Poem

🐰 A hop from i18n to Intlify I go,
I tidy keys and let the context flow,
ctx became just c, examples all in tune,
Docs, tests, and code now hum the same tune —
A small rabbit dance beneath the moon 🌙

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title clearly and specifically describes the main breaking change: renaming the exported middleware function from defineI18nMiddleware to defineIntlifyMiddleware across the Hono package.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch breaking/hono

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ab1094e and 0411f8d.

📒 Files selected for processing (1)
  • packages/hono/docs/functions/getDetectorLocale.md (3 hunks)
🔇 Additional comments (2)
packages/hono/docs/functions/getDetectorLocale.md (2)

36-40: Example code correctly uses updated parameter naming.

The code example has been properly updated to use c instead of ctx across all references (parameter, function call, and method invocation on context object).


10-10: Documentation is accurate and consistent with implementation.

The documented return type Promise<Intl.Locale> matches the actual implementation. Parameter naming (c) and middleware references (defineIntlifyMiddleware) are correctly updated throughout.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@kazupon kazupon changed the title breaking(hono): change defineI18nMiddleware to `defineIntlifyMiddle… breaking(hono): change defineI18nMiddleware to defineIntlifyMiddleware Nov 21, 2025
@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 21, 2025

Open in StackBlitz

npm i https://pkg.pr.new/@intlify/elysia@45
npm i https://pkg.pr.new/@intlify/h3@45
npm i https://pkg.pr.new/@intlify/hono@45

commit: 0411f8d

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/hono/spec/integration.spec.ts (1)

93-93: Inconsistent parameter naming: use c instead of ctx.

Line 93 uses ctx as the parameter name, while line 140 uses c. The PR standardizes on c throughout the codebase to align with Hono conventions.

Apply this diff to fix the inconsistency:

-    const localeDetector = async (ctx: Context, i18n: CoreContext<string, DefineLocaleMessage>) => {
-      const locale = getQueryLocale(ctx.req.raw).toString()
+    const localeDetector = async (c: Context, i18n: CoreContext<string, DefineLocaleMessage>) => {
+      const locale = getQueryLocale(c.req.raw).toString()
       await sleep(100)
       const loader = messages[locale]
       if (loader && !i18n.messages[locale]) {
🧹 Nitpick comments (1)
packages/hono/README.md (1)

124-149: Consider adding a "Migration Guide" section (optional enhancement).

While the examples clearly show the new API, a dedicated migration section (or a note in the PR description) explicitly mapping old API → new API would help users upgrading from the previous version. For example:

  • defineI18nMiddlewaredefineIntlifyMiddleware
  • i18n (middleware variable) → intlify
  • ctx (context parameter) → c
  • i18n.messagesintlify.messages

This is not a blocker, as the changes are evident from the examples, but would improve user experience for migration.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 552b5c0 and ab1094e.

📒 Files selected for processing (14)
  • packages/hono/README.md (5 hunks)
  • packages/hono/docs/functions/defineIntlifyMiddleware.md (4 hunks)
  • packages/hono/docs/functions/detectLocaleFromAcceptLanguageHeader.md (4 hunks)
  • packages/hono/docs/functions/getDetectorLocale.md (2 hunks)
  • packages/hono/docs/functions/useTranslation.md (4 hunks)
  • packages/hono/docs/index.md (1 hunks)
  • packages/hono/playground/basic/index.ts (2 hunks)
  • packages/hono/playground/global-schema/index.ts (3 hunks)
  • packages/hono/playground/local-schema/index.ts (2 hunks)
  • packages/hono/playground/typesafe-schema/index.ts (3 hunks)
  • packages/hono/spec/integration.spec.ts (10 hunks)
  • packages/hono/src/index.test-d.ts (1 hunks)
  • packages/hono/src/index.test.ts (6 hunks)
  • packages/hono/src/index.ts (8 hunks)
🧰 Additional context used
🧬 Code graph analysis (8)
packages/hono/src/index.test.ts (2)
packages/h3/src/index.ts (1)
  • intlify (122-126)
packages/hono/src/index.ts (1)
  • defineIntlifyMiddleware (123-164)
packages/hono/playground/basic/index.ts (1)
packages/hono/src/index.ts (1)
  • defineIntlifyMiddleware (123-164)
packages/hono/playground/global-schema/index.ts (1)
packages/hono/src/index.ts (1)
  • defineIntlifyMiddleware (123-164)
packages/hono/src/index.test-d.ts (1)
packages/hono/src/index.ts (1)
  • defineIntlifyMiddleware (123-164)
packages/hono/playground/local-schema/index.ts (1)
packages/hono/src/index.ts (1)
  • defineIntlifyMiddleware (123-164)
packages/hono/playground/typesafe-schema/index.ts (1)
packages/hono/src/index.ts (1)
  • defineIntlifyMiddleware (123-164)
packages/hono/spec/integration.spec.ts (2)
packages/h3/src/index.ts (2)
  • intlify (122-126)
  • CoreContext (39-39)
packages/hono/src/index.ts (2)
  • defineIntlifyMiddleware (123-164)
  • CoreContext (36-36)
packages/hono/src/index.ts (2)
packages/h3/src/index.ts (6)
  • intlify (122-126)
  • detectLocaleFromAcceptLanguageHeader (241-242)
  • getHeaderLocale (27-27)
  • useTranslation (297-323)
  • DefineLocaleMessage (262-262)
  • getDetectorLocale (344-347)
packages/shared/src/types.ts (1)
  • TranslationFunction (25-39)
🔇 Additional comments (22)
packages/hono/README.md (2)

75-115: Documentation consistently reflects the breaking API changes.

The README correctly documents the transition from defineI18nMiddleware to defineIntlifyMiddleware across all translation examples. The migration from ctx to c (Hono's standard context parameter) and i18n to intlify is consistently applied. The example progression from basic locale detection → middleware-based translation → custom detectors is clear and accurate.


116-199: Custom locale detector examples correctly document the new middleware API.

The custom detector examples (lines 122–151 and 162–199) properly show:

  • Correct function signature for sync detectors: (c: Context): string
  • Correct async signature: (c: Context, intlify: CoreContext<...>): Promise<string>
  • Proper access to middleware context via intlify.messages[locale] for lazy loading

All imports and middleware usage align with the new naming convention.

packages/hono/docs/functions/detectLocaleFromAcceptLanguageHeader.md (1)

10-10: LGTM! Documentation consistently updated.

The documentation correctly reflects the breaking API changes: parameter rename ctxc and middleware rename defineI18nMiddlewaredefineIntlifyMiddleware.

Also applies to: 19-19, 31-31, 33-33, 46-46

packages/hono/playground/global-schema/index.ts (1)

3-3: LGTM! Playground example properly updated.

The example correctly demonstrates the new defineIntlifyMiddleware API and follows the updated naming conventions.

Also applies to: 20-20, 29-29

packages/hono/spec/integration.spec.ts (1)

22-22: LGTM! Test file properly updated.

The test suite correctly uses the new defineIntlifyMiddleware API and updated naming conventions.

Also applies to: 34-34, 61-61, 73-73, 104-104, 117-117, 151-151, 161-161

packages/hono/docs/functions/defineIntlifyMiddleware.md (1)

5-5: LGTM! API documentation correctly updated.

The documentation comprehensively reflects the breaking change from defineI18nMiddleware to defineIntlifyMiddleware, including all descriptions, signatures, and examples.

Also applies to: 7-7, 10-10, 13-13, 28-28, 34-34, 44-44, 46-46, 62-62

packages/hono/playground/local-schema/index.ts (1)

3-3: LGTM! Playground example properly updated.

The local schema example correctly demonstrates the new defineIntlifyMiddleware API with updated naming conventions.

Also applies to: 11-11, 20-20

packages/hono/playground/typesafe-schema/index.ts (1)

3-3: LGTM! Typesafe schema example properly updated.

The example correctly demonstrates the new defineIntlifyMiddleware API with proper type safety and updated naming conventions.

Also applies to: 13-13, 24-24

packages/hono/src/index.test-d.ts (1)

2-2: LGTM! Type test properly updated.

The type test correctly validates the new defineIntlifyMiddleware API and ensures it conforms to the MiddlewareHandler interface.

Also applies to: 6-6, 12-12, 19-19

packages/hono/docs/index.md (1)

13-13: LGTM! Documentation index properly updated.

The function reference correctly links to the renamed defineIntlifyMiddleware documentation with an updated description.

packages/hono/playground/basic/index.ts (1)

4-4: LGTM! API rename applied consistently.

The import, variable naming, and middleware registration have been updated correctly to use the new defineIntlifyMiddleware API and intlify terminology.

Also applies to: 9-9, 22-22

packages/hono/docs/functions/getDetectorLocale.md (1)

19-19: LGTM! Documentation updates are consistent.

The parameter name and middleware reference updates align correctly with the API changes.

Also applies to: 29-29, 36-38

packages/hono/src/index.test.ts (3)

8-8: LGTM! Test import and basic validation updated correctly.

The import and test for defineIntlifyMiddleware have been updated consistently with the API changes.

Also applies to: 28-41


43-80: LGTM! Context key updates in test are correct.

The mock context setup correctly uses the new intlify and intlifyLocaleDetector keys, matching the implementation changes.


98-126: LGTM! Locale detector test updated correctly.

The getDetectorLocale test has been updated with the correct context keys and references the updated middleware name.

packages/hono/docs/functions/useTranslation.md (1)

10-10: LGTM! Documentation fully aligned with API changes.

All parameter names, middleware references, and example code have been updated correctly to reflect the new defineIntlifyMiddleware API and intlify terminology.

Also applies to: 41-41, 62-62, 68-68, 70-70, 82-82, 85-87

packages/hono/src/index.ts (6)

52-57: LGTM! Module declaration updated correctly.

The ContextVariableMap declaration properly reflects the new context keys (intlify and intlifyLocaleDetector), which are used consistently throughout the implementation.


88-164: LGTM! Middleware function implementation is correct.

The defineIntlifyMiddleware function has been properly renamed and updated:

  • JSDoc and examples reflect the new API
  • Internal variable naming is consistent (intlify)
  • Context keys (intlify, intlifyLocaleDetector) are set and cleaned up correctly
  • Warning message references the correct function name

166-194: LGTM! Locale detection function updated consistently.

The detectLocaleFromAcceptLanguageHeader function has been correctly updated:

  • Parameter renamed from ctx to c throughout
  • JSDoc examples reference the new middleware name
  • Implementation uses the new parameter correctly

196-216: LGTM! Internal helper function updated correctly.

The getLocaleAndIntlifyContext helper function properly uses the new context keys (intlify, intlifyLocaleDetector) and provides clear error messages referencing the updated middleware name.


218-276: LGTM! Translation function updated correctly.

The useTranslation function has been properly updated:

  • Parameter renamed from ctx to c consistently
  • JSDoc examples demonstrate the new API correctly
  • Implementation uses the updated getLocaleAndIntlifyContext helper
  • Translation logic remains intact

278-301: LGTM! Detector locale function updated correctly.

The getDetectorLocale function has been properly updated:

  • Parameter renamed from ctx to c
  • JSDoc references the correct middleware name
  • Implementation uses the updated helper function

@kazupon kazupon merged commit 9bf6668 into main Nov 21, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants