Skip to content

Commit 6ea9935

Browse files
Copilothotlong
andcommitted
fix: add i18n route bridges to dispatcher plugin
The createDispatcherPlugin() bridges all service domains (auth, analytics, packages, storage, automation) from HttpDispatcher to the HTTP server, but i18n was missing. When no explicit I18nServicePlugin is loaded (kernel uses memory fallback i18n), no i18n HTTP routes were registered, causing 404. Add 3 i18n route bridges consistent with all other service domains: - GET /api/v1/i18n/locales - GET /api/v1/i18n/translations/:locale - GET /api/v1/i18n/labels/:object/:locale Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 32ea51a commit 6ea9935

2 files changed

Lines changed: 36 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1919
- `I18nServicePlugin` now accepts `registerRoutes` and `basePath` options for HTTP route control.
2020
- i18n endpoints now work independently of `RestServer`, enabling MSW/mock test environments
2121
to serve i18n routes without any REST API gateway dependency.
22+
- **Dispatcher i18n bridge routes**`createDispatcherPlugin()` now registers i18n HTTP route
23+
bridges (`GET /i18n/locales`, `GET /i18n/translations/:locale`, `GET /i18n/labels/:object/:locale`)
24+
via `HttpDispatcher.handleI18n()`, ensuring i18n endpoints work even when only the kernel's
25+
memory fallback i18n is active (no explicit `I18nServicePlugin` loaded). This is consistent with
26+
how auth, analytics, packages, storage, and automation services are bridged.
2227

2328
### Added
2429
- **i18n as core built-in service** — The i18n service is now a `core` criticality service with

packages/runtime/src/dispatcher-plugin.ts

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function errorResponse(err: any, res: any): void {
5353
* - /graphql (GraphQL)
5454
* - /analytics (BI queries)
5555
* - /packages (package management)
56-
56+
* - /i18n (internationalization — locales, translations, field labels)
5757
* - /storage (file storage)
5858
* - /automation (CRUD + triggers + runs)
5959
*
@@ -237,6 +237,36 @@ export function createDispatcherPlugin(config: DispatcherPluginConfig = {}): Plu
237237
}
238238
});
239239

240+
// ── i18n ────────────────────────────────────────────────────
241+
// Bridges to HttpDispatcher.handleI18n() which resolves the i18n
242+
// service from the kernel (either I18nServicePlugin or memory fallback).
243+
server.get(`${prefix}/i18n/locales`, async (req: any, res: any) => {
244+
try {
245+
const result = await dispatcher.handleI18n('/locales', 'GET', req.query, { request: req });
246+
sendResult(result, res);
247+
} catch (err: any) {
248+
errorResponse(err, res);
249+
}
250+
});
251+
252+
server.get(`${prefix}/i18n/translations/:locale`, async (req: any, res: any) => {
253+
try {
254+
const result = await dispatcher.handleI18n(`/translations/${req.params.locale}`, 'GET', req.query, { request: req });
255+
sendResult(result, res);
256+
} catch (err: any) {
257+
errorResponse(err, res);
258+
}
259+
});
260+
261+
server.get(`${prefix}/i18n/labels/:object/:locale`, async (req: any, res: any) => {
262+
try {
263+
const result = await dispatcher.handleI18n(`/labels/${req.params.object}/${req.params.locale}`, 'GET', req.query, { request: req });
264+
sendResult(result, res);
265+
} catch (err: any) {
266+
errorResponse(err, res);
267+
}
268+
});
269+
240270
// ── Automation ──────────────────────────────────────────────
241271
server.get(`${prefix}/automation`, async (req: any, res: any) => {
242272
try {

0 commit comments

Comments
 (0)