From fbc27623ef2db6d689ceb682b53b126ea9bf2526 Mon Sep 17 00:00:00 2001 From: Sonarly Claude Code Date: Wed, 8 Apr 2026 03:08:31 +0000 Subject: [PATCH] chore: improve i18n workflow to prevent stale compiled translations (#18850) https://sonarly.com/issue/22697?type=bug The Docker image build did not run `lingui compile` before building the server and frontend, causing missing translation entries at runtime that flood logs with "Uncompiled message detected" warnings. --- .../engine/core-modules/i18n/i18n.service.ts | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/packages/twenty-server/src/engine/core-modules/i18n/i18n.service.ts b/packages/twenty-server/src/engine/core-modules/i18n/i18n.service.ts index 4c8ca4e78dd..700c025d010 100644 --- a/packages/twenty-server/src/engine/core-modules/i18n/i18n.service.ts +++ b/packages/twenty-server/src/engine/core-modules/i18n/i18n.service.ts @@ -1,4 +1,4 @@ -import { Injectable, type OnModuleInit } from '@nestjs/common'; +import { Injectable, Logger, type OnModuleInit } from '@nestjs/common'; import { type I18n, @@ -42,6 +42,9 @@ import { messages as zhHantMessages } from 'src/engine/core-modules/i18n/locales @Injectable() export class I18nService implements OnModuleInit { + private readonly logger = new Logger(I18nService.name); + private readonly loggedMissingIds = new Set(); + private i18nInstancesMap: Record = {} as Record; @@ -83,7 +86,19 @@ export class I18nService implements OnModuleInit { ( Object.entries(messagesByLocale) as [keyof typeof APP_LOCALES, Messages][] ).forEach(([locale, messages]) => { - const localeI18n = setupI18n(); + const localeI18n = setupI18n({ + missing: (_locale, id) => { + if (!this.loggedMissingIds.has(id)) { + this.loggedMissingIds.add(id); + this.logger.warn( + `Missing translation for message "${id}" in locale "${_locale}". ` + + 'Compiled catalogs may be stale — run lingui compile.', + ); + } + + return id; + }, + }); localeI18n.load(locale, messages); localeI18n.activate(locale);