Skip to content

Commit bda1fbb

Browse files
committed
Update settings-service-plugin.ts
1 parent 42c6a11 commit bda1fbb

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

packages/services/service-settings/src/settings-service-plugin.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
builtinSettingsManifests,
1818
mailTestActionHandler,
1919
} from './manifests/index.js';
20+
import { settingsBuiltinTranslations } from './translations/index.js';
2021

2122
/** Configuration options for the SettingsServicePlugin. */
2223
export interface SettingsServicePluginOptions {
@@ -102,6 +103,35 @@ export class SettingsServicePlugin implements Plugin {
102103
if (!this.service) return;
103104

104105
ctx.hook('kernel:ready', async () => {
106+
// Contribute built-in settings translations into the i18n service.
107+
// Done in `kernel:ready` (not `init`) because the i18n service plugin
108+
// is typically registered AFTER capability-loaded service plugins.
109+
try {
110+
const i18n = ctx.getService<{
111+
loadTranslations: (locale: string, data: Record<string, unknown>) => void;
112+
}>('i18n');
113+
let loaded = 0;
114+
for (const [locale, data] of Object.entries(settingsBuiltinTranslations)) {
115+
if (data && typeof data === 'object') {
116+
try {
117+
i18n.loadTranslations(locale, data as Record<string, unknown>);
118+
loaded++;
119+
} catch (err: any) {
120+
ctx.logger?.warn?.(
121+
`SettingsServicePlugin: failed to load translations for '${locale}': ${err?.message ?? err}`,
122+
);
123+
}
124+
}
125+
}
126+
if (loaded > 0) {
127+
ctx.logger?.info?.(
128+
`SettingsServicePlugin: contributed built-in translations (${loaded} locale${loaded > 1 ? 's' : ''})`,
129+
);
130+
}
131+
} catch {
132+
// i18n service not registered — manifest literals remain authoritative.
133+
}
134+
105135
// Late-bind the data engine.
106136
let engine: IDataEngine | null = null;
107137
try {

0 commit comments

Comments
 (0)