The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
fix(i18n): translate server-side texts that reach users (#27335)
Mahmoud Abas0e7a81f77b8f
diff --git a/packages/twenty-sdk/src/cli/utilities/translations/__tests__/application-translations.spec.ts b/packages/twenty-sdk/src/cli/utilities/translations/__tests__/application-translations.spec.tsindex 14e6ba153c1..862188ccc2c 100644--- a/packages/twenty-sdk/src/cli/utilities/translations/__tests__/application-translations.spec.ts+++ b/packages/twenty-sdk/src/cli/utilities/translations/__tests__/application-translations.spec.ts@@ -104,6 +104,12 @@ describe('collectTranslatableStrings', () => {commandMenuItems: [{ label: 'Launch Rocket', shortLabel: 'Launch' }],navigationMenuItems: [{ name: 'Missions' }],timelineActivityTypes: [{ label: 'Launched a rocket' }],+ skills: [+ {+ label: 'Plan a launch',+ description: 'Picks the next launch window',+ },+ ],pageLayouts: [{name: 'Mission Control Layout',@@ -130,6 +136,11 @@ describe('collectTranslatableStrings', () => {message: 'Launched a rocket',context: 'timelineActivityType.label',},+ { message: 'Plan a launch', context: 'skill.label' },+ {+ message: 'Picks the next launch window',+ context: 'skill.description',+ },{ message: 'Mission Control Layout', context: 'pageLayout.name' },{ message: 'Overview', context: 'pageLayoutTab.title' },{ message: 'Fuel level', context: 'pageLayoutWidget.title' },diff --git a/packages/twenty-sdk/src/cli/utilities/translations/collect-translatable-strings.ts b/packages/twenty-sdk/src/cli/utilities/translations/collect-translatable-strings.tsindex 0e193827e18..cbf230f9ff1 100644--- a/packages/twenty-sdk/src/cli/utilities/translations/collect-translatable-strings.ts+++ b/packages/twenty-sdk/src/cli/utilities/translations/collect-translatable-strings.ts@@ -19,6 +19,7 @@ const MANIFEST_KEY_BY_METADATA_NAME = {navigationMenuItem: 'navigationMenuItems',timelineActivityType: 'timelineActivityTypes',settingsMenuItem: 'settingsMenuItems',+ skill: 'skills',} as const satisfies Partial<Record<TranslatableMetadataName, keyof Manifest>>;export const collectTranslatableStrings = (diff --git a/packages/twenty-server/src/engine/core-modules/approved-access-domain/services/approved-access-domain.service.ts b/packages/twenty-server/src/engine/core-modules/approved-access-domain/services/approved-access-domain.service.tsindex e75815099f8..ce2e37c7236 100644--- a/packages/twenty-server/src/engine/core-modules/approved-access-domain/services/approved-access-domain.service.ts+++ b/packages/twenty-server/src/engine/core-modules/approved-access-domain/services/approved-access-domain.service.ts@@ -20,6 +20,7 @@ import { JwtTokenTypeEnum } from 'src/engine/core-modules/auth/types/jwt-token-timport { WorkspaceDomainsService } from 'src/engine/core-modules/domain/workspace-domains/services/workspace-domains.service';import { EmailService } from 'src/engine/core-modules/email/email.service';import { FileUrlService } from 'src/engine/core-modules/file/file-url/file-url.service';+import { I18nService } from 'src/engine/core-modules/i18n/i18n.service';import { JwtWrapperService } from 'src/engine/core-modules/jwt/services/jwt-wrapper.service';import { decodeJwtHeader } from 'src/engine/core-modules/jwt/utils/decode-jwt-header.util';import { isAsymmetricJwtHeader } from 'src/engine/core-modules/jwt/utils/is-asymmetric-jwt-header.util';@@ -47,6 +48,7 @@ export class ApprovedAccessDomainService {private readonly fileUrlService: FileUrlService,private readonly workspaceDomainsService: WorkspaceDomainsService,private readonly jwtWrapperService: JwtWrapperService,+ private readonly i18nService: I18nService,) {}async sendApprovedAccessDomainValidationEmail(@@ -120,10 +122,12 @@ export class ApprovedAccessDomainService {plainText: true,});+ const i18n = this.i18nService.getI18nInstance(sender.locale);+await this.emailService.send({from: `${sender.name.firstName} ${sender.name.lastName} (via Twenty) <${this.twentyConfigService.get('EMAIL_FROM_ADDRESS')}>`,to,- subject: 'Approve your access domain',+ subject: i18n._(msg`Approve your access domain`),text,html,});diff --git a/packages/twenty-server/src/engine/core-modules/approved-access-domain/services/approved-access-domain.spec.ts b/packages/twenty-server/src/engine/core-modules/approved-access-domain/services/approved-access-domain.spec.tsindex ac5afea7d4d..bf1d35c6752 100644--- a/packages/twenty-server/src/engine/core-modules/approved-access-domain/services/approved-access-domain.spec.ts+++ b/packages/twenty-server/src/engine/core-modules/approved-access-domain/services/approved-access-domain.spec.ts@@ -13,6 +13,7 @@ import {import { JwtTokenTypeEnum } from 'src/engine/core-modules/auth/types/jwt-token-type.enum';import { WorkspaceDomainsService } from 'src/engine/core-modules/domain/workspace-domains/services/workspace-domains.service';import { EmailService } from 'src/engine/core-modules/email/email.service';+import { I18nService } from 'src/engine/core-modules/i18n/i18n.service';import { JwtWrapperService } from 'src/engine/core-modules/jwt/services/jwt-wrapper.service';import { TwentyConfigService } from 'src/engine/core-modules/twenty-config/twenty-config.service';import { type WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';@@ -100,6 +101,15 @@ describe('ApprovedAccessDomainService', () => {verifyJwtToken: jest.fn(),},},+ {+ provide: I18nService,+ useValue: {+ getI18nInstance: jest.fn(() => ({+ _: (descriptor: { id: string; message?: string }) =>+ descriptor.message ?? descriptor.id,+ })),+ },+ },],}).compile();diff --git a/packages/twenty-server/src/engine/core-modules/auth/services/auth.service.ts b/packages/twenty-server/src/engine/core-modules/auth/services/auth.service.tsindex 589c39d51ec..01e62e35a92 100644--- a/packages/twenty-server/src/engine/core-modules/auth/services/auth.service.ts+++ b/packages/twenty-server/src/engine/core-modules/auth/services/auth.service.ts@@ -948,6 +948,9 @@ export class AuthService {throw new AuthException('Public invite link is disabled for this workspace',AuthExceptionCode.FORBIDDEN_EXCEPTION,+ {+ userFriendlyMessage: msg`Public invite link is disabled for this workspace`,+ },);}diff --git a/packages/twenty-server/src/engine/core-modules/auth/services/sign-in-up.service.ts b/packages/twenty-server/src/engine/core-modules/auth/services/sign-in-up.service.tsindex c4ad4114599..fc3214c022b 100644--- a/packages/twenty-server/src/engine/core-modules/auth/services/sign-in-up.service.ts+++ b/packages/twenty-server/src/engine/core-modules/auth/services/sign-in-up.service.ts@@ -187,6 +187,7 @@ export class SignInUpService {throw new AuthException('Invitation not found',AuthExceptionCode.FORBIDDEN_EXCEPTION,+ { userFriendlyMessage: msg`Invitation not found` },);}@@ -215,6 +216,7 @@ export class SignInUpService {throw new AuthException('Invitation not found',AuthExceptionCode.FORBIDDEN_EXCEPTION,+ { userFriendlyMessage: msg`Invitation not found` },);}@@ -435,6 +437,7 @@ export class SignInUpService {throw new AuthException('New workspace setup is disabled',AuthExceptionCode.SIGNUP_DISABLED,+ { userFriendlyMessage: msg`New workspace setup is disabled` },);}}@@ -467,6 +470,7 @@ export class SignInUpService {throw new AuthException('New workspace setup is disabled',AuthExceptionCode.SIGNUP_DISABLED,+ { userFriendlyMessage: msg`New workspace setup is disabled` },);}diff --git a/packages/twenty-server/src/engine/core-modules/tool/tools/calendar-tool/create-calendar-event-tool.ts b/packages/twenty-server/src/engine/core-modules/tool/tools/calendar-tool/create-calendar-event-tool.tsindex 29f36c937a9..44727833512 100644--- a/packages/twenty-server/src/engine/core-modules/tool/tools/calendar-tool/create-calendar-event-tool.ts+++ b/packages/twenty-server/src/engine/core-modules/tool/tools/calendar-tool/create-calendar-event-tool.ts@@ -1,7 +1,9 @@import { Injectable, Logger } from '@nestjs/common';import { PermissionFlagType } from 'twenty-shared/constants';+import { SOURCE_LOCALE } from 'twenty-shared/translations';+import { I18nService } from 'src/engine/core-modules/i18n/i18n.service';import { CreateCalendarEventToolInputZodSchema } from 'src/engine/core-modules/tool/tools/calendar-tool/calendar-tool.schema';import { type CreateCalendarEventToolInput } from 'src/engine/core-modules/tool/tools/calendar-tool/types/create-calendar-event-tool-input.type';import { type ToolExecutionContext } from 'src/engine/core-modules/tool/types/tool-execution-context.type';@@ -23,6 +25,7 @@ export class CreateCalendarEventTool implements Tool {constructor(private readonly calendarEventComposerService: CalendarEventComposerService,private readonly createCalendarEventService: CreateCalendarEventService,+ private readonly i18nService: I18nService,) {}async execute(@@ -40,7 +43,9 @@ export class CreateCalendarEventTool implements Tool {return {success: false,message: 'Failed to create calendar event',- error: result.error,+ error: this.i18nService+ .getI18nInstance(SOURCE_LOCALE)+ ._(result.error),};}diff --git a/packages/twenty-server/src/engine/core-modules/tool/tools/email-tool/__tests__/draft-email-tool.spec.ts b/packages/twenty-server/src/engine/core-modules/tool/tools/email-tool/__tests__/draft-email-tool.spec.tsindex 2dffd897724..9b750280110 100644--- a/packages/twenty-server/src/engine/core-modules/tool/tools/email-tool/__tests__/draft-email-tool.spec.ts+++ b/packages/twenty-server/src/engine/core-modules/tool/tools/email-tool/__tests__/draft-email-tool.spec.ts@@ -1,7 +1,9 @@import { Test, type TestingModule } from '@nestjs/testing';+import { SOURCE_LOCALE } from 'twenty-shared/translations';import { ConnectedAccountProvider } from 'twenty-shared/types';+import { I18nService } from 'src/engine/core-modules/i18n/i18n.service';import { DraftEmailTool } from 'src/engine/core-modules/tool/tools/email-tool/draft-email-tool';import { EmailComposerService } from 'src/engine/core-modules/tool/tools/email-tool/email-composer.service';import { type EmailToolInput } from 'src/engine/core-modules/tool/tools/email-tool/types/email-tool-input.type';@@ -35,12 +37,17 @@ describe('DraftEmailTool', () => {let tool: DraftEmailTool;let mockComposeEmail: jest.Mock;let mockCreateDraft: jest.Mock;+ let mockGetI18nInstance: jest.Mock;beforeEach(async () => {jest.clearAllMocks();mockComposeEmail = jest.fn();mockCreateDraft = jest.fn();+ mockGetI18nInstance = jest.fn(() => ({+ _: (descriptor: { id: string; message?: string }) =>+ descriptor.message ?? descriptor.id,+ }));const module: TestingModule = await Test.createTestingModule({providers: [@@ -53,12 +60,38 @@ describe('DraftEmailTool', () => {provide: MessagingMessageOutboundService,useValue: { createDraft: mockCreateDraft },},+ {+ provide: I18nService,+ useValue: { getI18nInstance: mockGetI18nInstance },+ },],}).compile();tool = module.get(DraftEmailTool);});+ it('returns the composition error in the source locale', async () => {+ mockComposeEmail.mockResolvedValue({+ success: false,+ error: {+ id: 'invalid-email-addresses',+ message: 'Invalid email addresses: not-an-email',+ },+ });++ const result = await tool.execute(baseInput, {+ workspaceId: 'workspace-1',+ });++ expect(mockGetI18nInstance).toHaveBeenCalledWith(SOURCE_LOCALE);+ expect(mockCreateDraft).not.toHaveBeenCalled();+ expect(result).toEqual({+ success: false,+ message: 'Invalid email addresses: not-an-email',+ error: 'Invalid email addresses: not-an-email',+ });+ });+it('fails without drafting when the resolved account lacks the compose scope', async () => {mockComposeEmail.mockResolvedValue({success: true,diff --git a/packages/twenty-server/src/engine/core-modules/tool/tools/email-tool/__tests__/send-email-tool.spec.ts b/packages/twenty-server/src/engine/core-modules/tool/tools/email-tool/__tests__/send-email-tool.spec.tsindex 9294fa2ecb2..e2482b92414 100644--- a/packages/twenty-server/src/engine/core-modules/tool/tools/email-tool/__tests__/send-email-tool.spec.ts+++ b/packages/twenty-server/src/engine/core-modules/tool/tools/email-tool/__tests__/send-email-tool.spec.ts@@ -1,5 +1,8 @@import { Test, type TestingModule } from '@nestjs/testing';+import { SOURCE_LOCALE } from 'twenty-shared/translations';++import { I18nService } from 'src/engine/core-modules/i18n/i18n.service';import { EmailComposerService } from 'src/engine/core-modules/tool/tools/email-tool/email-composer.service';import { SendEmailTool } from 'src/engine/core-modules/tool/tools/email-tool/send-email-tool';import { type EmailToolInput } from 'src/engine/core-modules/tool/tools/email-tool/types/email-tool-input.type';@@ -35,6 +38,7 @@ describe('SendEmailTool', () => {let mockComposeEmail: jest.Mock;let mockSendComposedEmail: jest.Mock;let mockPersistSentMessage: jest.Mock;+ let mockGetI18nInstance: jest.Mock;beforeEach(async () => {jest.clearAllMocks();@@ -45,6 +49,10 @@ describe('SendEmailTool', () => {messageId: 'message-record-id',messageThreadId: 'message-thread-record-id',});+ mockGetI18nInstance = jest.fn(() => ({+ _: (descriptor: { id: string; message?: string }) =>+ descriptor.message ?? descriptor.id,+ }));const module: TestingModule = await Test.createTestingModule({providers: [@@ -60,6 +68,10 @@ describe('SendEmailTool', () => {persistSentMessage: mockPersistSentMessage,},},+ {+ provide: I18nService,+ useValue: { getI18nInstance: mockGetI18nInstance },+ },],}).compile();@@ -105,6 +117,25 @@ describe('SendEmailTool', () => {});});+ it('returns the composition error in the source locale', async () => {+ mockComposeEmail.mockResolvedValue({+ success: false,+ error: { id: 'no-recipients', message: 'No recipients specified' },+ });++ const result = await tool.execute(baseInput, {+ workspaceId: 'workspace-1',+ });++ expect(mockGetI18nInstance).toHaveBeenCalledWith(SOURCE_LOCALE);+ expect(mockSendComposedEmail).not.toHaveBeenCalled();+ expect(result).toEqual({+ success: false,+ message: 'No recipients specified',+ error: 'No recipients specified',+ });+ });+it('still succeeds without record ids when persistence fails', async () => {mockComposeEmail.mockResolvedValue({success: true,diff --git a/packages/twenty-server/src/engine/core-modules/tool/tools/email-tool/draft-email-tool.ts b/packages/twenty-server/src/engine/core-modules/tool/tools/email-tool/draft-email-tool.tsindex 8b22ca75e98..c47cac2a297 100644--- a/packages/twenty-server/src/engine/core-modules/tool/tools/email-tool/draft-email-tool.ts+++ b/packages/twenty-server/src/engine/core-modules/tool/tools/email-tool/draft-email-tool.ts@@ -1,6 +1,9 @@import { EmailOperation } from 'twenty-shared/types';import { Injectable, Logger } from '@nestjs/common';+import { SOURCE_LOCALE } from 'twenty-shared/translations';++import { I18nService } from 'src/engine/core-modules/i18n/i18n.service';import { EmailComposerService } from 'src/engine/core-modules/tool/tools/email-tool/email-composer.service';import { EmailToolInputZodSchema } from 'src/engine/core-modules/tool/tools/email-tool/email-tool.schema';import { EmailToolException } from 'src/engine/core-modules/tool/tools/email-tool/exceptions/email-tool.exception';@@ -24,6 +27,7 @@ export class DraftEmailTool implements Tool {constructor(private readonly emailComposerService: EmailComposerService,private readonly messageOutboundService: MessagingMessageOutboundService,+ private readonly i18nService: I18nService,) {}async execute(@@ -38,7 +42,11 @@ export class DraftEmailTool implements Tool {});if (!result.success) {- return result.output;+ const errorMessage = this.i18nService+ .getI18nInstance(SOURCE_LOCALE)+ ._(result.error);++ return { success: false, message: errorMessage, error: errorMessage };}const { data } = result;diff --git a/packages/twenty-server/src/engine/core-modules/tool/tools/email-tool/email-composer.service.ts b/packages/twenty-server/src/engine/core-modules/tool/tools/email-tool/email-composer.service.tsindex d1e4cfdbda4..aaef268a0cd 100644--- a/packages/twenty-server/src/engine/core-modules/tool/tools/email-tool/email-composer.service.ts+++ b/packages/twenty-server/src/engine/core-modules/tool/tools/email-tool/email-composer.service.ts@@ -1,6 +1,7 @@import { Injectable, Logger } from '@nestjs/common';import { InjectRepository } from '@nestjs/typeorm';+import { msg } from '@lingui/core/macro';import { isNonEmptyString } from '@sniptt/guards';import { MAX_EMAIL_RECIPIENTS } from 'twenty-shared/constants';import {@@ -180,6 +181,7 @@ export class EmailComposerService {throw new EmailToolException('No recipients specified',EmailToolExceptionCode.INVALID_EMAIL,+ { userFriendlyMessage: msg`No recipients specified` },);}@@ -189,6 +191,7 @@ export class EmailComposerService {throw new EmailToolException('No valid recipients specified',EmailToolExceptionCode.INVALID_EMAIL,+ { userFriendlyMessage: msg`No valid recipients specified` },);}@@ -232,6 +235,9 @@ export class EmailComposerService {throw new EmailToolException(`Too many recipients: ${total}. Maximum allowed is ${MAX_EMAIL_RECIPIENTS}.`,EmailToolExceptionCode.TOO_MANY_RECIPIENTS,+ {+ userFriendlyMessage: msg`Too many recipients: ${total}. Maximum allowed is ${MAX_EMAIL_RECIPIENTS}.`,+ },);}}@@ -378,29 +384,23 @@ export class EmailComposerService {recipients = this.normalizeRecipients(parameters);this.assertRecipientCountWithinLimit(recipients);} catch (error) {- const errorMessage =- error instanceof Error ? error.message : 'Invalid recipients';-return {success: false,- output: {- success: false,- message: errorMessage,- error: errorMessage,- },+ error:+ error instanceof EmailToolException+ ? error.userFriendlyMessage+ : msg`Invalid recipients`,};}const invalidEmails = this.validateEmails(recipients);if (invalidEmails.length > 0) {+ const invalidEmailList = invalidEmails.join(', ');+return {success: false,- output: {- success: false,- message: `Invalid email addresses: ${invalidEmails.join(', ')}`,- error: `Invalid email addresses: ${invalidEmails.join(', ')}`,- },+ error: msg`Invalid email addresses: ${invalidEmailList}`,};}diff --git a/packages/twenty-server/src/engine/core-modules/tool/tools/email-tool/send-email-tool.ts b/packages/twenty-server/src/engine/core-modules/tool/tools/email-tool/send-email-tool.tsindex b4e252df269..71fbe4c93a0 100644--- a/packages/twenty-server/src/engine/core-modules/tool/tools/email-tool/send-email-tool.ts+++ b/packages/twenty-server/src/engine/core-modules/tool/tools/email-tool/send-email-tool.ts@@ -1,6 +1,9 @@import { EmailOperation } from 'twenty-shared/types';import { Injectable, Logger } from '@nestjs/common';+import { SOURCE_LOCALE } from 'twenty-shared/translations';++import { I18nService } from 'src/engine/core-modules/i18n/i18n.service';import { EmailComposerService } from 'src/engine/core-modules/tool/tools/email-tool/email-composer.service';import { EmailToolInputZodSchema } from 'src/engine/core-modules/tool/tools/email-tool/email-tool.schema';import { EmailToolException } from 'src/engine/core-modules/tool/tools/email-tool/exceptions/email-tool.exception';@@ -22,6 +25,7 @@ export class SendEmailTool implements Tool {constructor(private readonly emailComposerService: EmailComposerService,private readonly sendEmailService: SendEmailService,+ private readonly i18nService: I18nService,) {}async execute(@@ -36,7 +40,11 @@ export class SendEmailTool implements Tool {});if (!result.success) {- return result.output;+ const errorMessage = this.i18nService+ .getI18nInstance(SOURCE_LOCALE)+ ._(result.error);++ return { success: false, message: errorMessage, error: errorMessage };}const { data } = result;diff --git a/packages/twenty-server/src/engine/core-modules/tool/tools/email-tool/types/email-composer-result.type.ts b/packages/twenty-server/src/engine/core-modules/tool/tools/email-tool/types/email-composer-result.type.tsindex 09dee66a2a0..ea15a553d8d 100644--- a/packages/twenty-server/src/engine/core-modules/tool/tools/email-tool/types/email-composer-result.type.ts+++ b/packages/twenty-server/src/engine/core-modules/tool/tools/email-tool/types/email-composer-result.type.ts@@ -1,7 +1,7 @@-import { type ToolOutput } from 'src/engine/core-modules/tool/types/tool-output.type';+import { type MessageDescriptor } from '@lingui/core';import { type ComposedEmail } from './composed-email.type';export type EmailComposerResult =| { success: true; data: ComposedEmail }- | { success: false; output: ToolOutput };+ | { success: false; error: MessageDescriptor };diff --git a/packages/twenty-server/src/engine/metadata-modules/ai/ai-models/services/ai-model-registry.service.ts b/packages/twenty-server/src/engine/metadata-modules/ai/ai-models/services/ai-model-registry.service.tsindex be6a1bca9c9..3c301968dad 100644--- a/packages/twenty-server/src/engine/metadata-modules/ai/ai-models/services/ai-model-registry.service.ts+++ b/packages/twenty-server/src/engine/metadata-modules/ai/ai-models/services/ai-model-registry.service.ts@@ -1,5 +1,6 @@import { Injectable, Logger } from '@nestjs/common';+import { msg } from '@lingui/core/macro';import { type LanguageModel, type TranscriptionModel } from 'ai';import { isNonEmptyString } from '@sniptt/guards';import {@@ -702,6 +703,9 @@ export class AiModelRegistryService {throw new AiException('The selected model has been disabled by the administrator.',AiExceptionCode.AGENT_EXECUTION_FAILED,+ {+ userFriendlyMessage: msg`The selected model has been disabled by the administrator.`,+ },);}diff --git a/packages/twenty-server/src/engine/metadata-modules/flat-entity/constant/__tests__/__snapshots__/overridable-and-translatable-properties.constant.spec.ts.snap b/packages/twenty-server/src/engine/metadata-modules/flat-entity/constant/__tests__/__snapshots__/overridable-and-translatable-properties.constant.spec.ts.snapindex d57211efb9c..2c82a8f9f83 100644--- a/packages/twenty-server/src/engine/metadata-modules/flat-entity/constant/__tests__/__snapshots__/overridable-and-translatable-properties.constant.spec.ts.snap+++ b/packages/twenty-server/src/engine/metadata-modules/flat-entity/constant/__tests__/__snapshots__/overridable-and-translatable-properties.constant.spec.ts.snap@@ -144,6 +144,10 @@ exports[`registry-derived override property maps derives the translatable proper"settingsMenuItem": ["title",],+ "skill": [+ "label",+ "description",+ ],"timelineActivityType": ["label",],diff --git a/packages/twenty-server/src/engine/metadata-modules/skill/__tests__/skill.resolver.spec.ts b/packages/twenty-server/src/engine/metadata-modules/skill/__tests__/skill.resolver.spec.tsnew file mode 100644index 00000000000..d3fba889d06--- /dev/null+++ b/packages/twenty-server/src/engine/metadata-modules/skill/__tests__/skill.resolver.spec.ts@@ -0,0 +1,132 @@+import { msg } from '@lingui/core/macro';+import { type APP_LOCALES } from 'twenty-shared/translations';++import { type I18nContext } from 'src/engine/core-modules/i18n/types/i18n-context.type';+import { type WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';+import { type IDataloaders } from 'src/engine/dataloaders/dataloader.interface';+import { type EffectiveEntityI18nContext } from 'src/engine/metadata-modules/overrides/types/effective-entity-i18n-context.type';+import { type SkillDTO } from 'src/engine/metadata-modules/skill/dtos/skill.dto';+import { SkillResolver } from 'src/engine/metadata-modules/skill/skill.resolver';++const WORKSPACE_ID = '33333333-3333-4333-8333-333333333333';+const STANDARD_APPLICATION_ID = '44444444-4444-4444-8444-444444444444';+const CUSTOM_APPLICATION_ID = '55555555-5555-4555-8555-555555555555';++const SKILL_LABEL = 'Workflow Building';+const SKILL_DESCRIPTION =+ 'Use when the user wants something to happen automatically: creating, changing, debugging or deleting a workflow, or phrasing a rule as when X happens do Y';++const FRENCH_MESSAGES: Record<string, string> = {+ [msg({ message: `Workflow Building`, context: 'skill.label' }).id]:+ 'Création de workflows',+ [msg({+ message: `Use when the user wants something to happen automatically: creating, changing, debugging or deleting a workflow, or phrasing a rule as when X happens do Y`,+ context: 'skill.description',+ }).id]: 'Utiliser pour automatiser une action',+};++describe('SkillResolver translatable fields', () => {+ const workspace = { id: WORKSPACE_ID } as WorkspaceEntity;+ const loaders = {} as IDataloaders;+ const context: { loaders: IDataloaders } & I18nContext = {+ loaders,+ req: { locale: 'fr-FR' },+ };++ const aSkill = (overrides: Partial<SkillDTO> = {}): SkillDTO => ({+ id: 'skill-id',+ name: 'research',+ label: SKILL_LABEL,+ description: SKILL_DESCRIPTION,+ content: 'Skill content',+ isCustom: false,+ isSystem: false,+ isActive: true,+ workspaceId: WORKSPACE_ID,+ applicationId: STANDARD_APPLICATION_ID,+ createdAt: new Date(),+ updatedAt: new Date(),+ ...overrides,+ });++ const buildResolver = () => {+ const applicationTranslationCatalogService = {+ buildEffectiveEntityI18nContext: jest.fn(+ async ({+ applicationId,+ locale,+ }: {+ applicationId: string | undefined;+ locale: keyof typeof APP_LOCALES | undefined;+ }): Promise<EffectiveEntityI18nContext> => ({+ locale,+ i18nInstance: {+ _: (messageId: string) => FRENCH_MESSAGES[messageId] ?? messageId,+ },+ isStandardApp: applicationId === STANDARD_APPLICATION_ID,+ applicationCatalog: undefined,+ workspaceCustomApplicationUniversalIdentifier:+ 'workspace-custom-application-universal-identifier',+ ownerApplicationUniversalIdentifier: undefined,+ }),+ ),+ };++ const resolver = new SkillResolver(+ {} as never,+ applicationTranslationCatalogService as never,+ );++ return { resolver, applicationTranslationCatalogService };+ };++ it('translates the label and description of a standard skill for the request locale', async () => {+ const { resolver, applicationTranslationCatalogService } = buildResolver();+ const skill = aSkill();++ const label = await resolver.label(skill, context, workspace);+ const description = await resolver.description(skill, context, workspace);++ expect(label).toBe('Création de workflows');+ expect(description).toBe('Utiliser pour automatiser une action');+ expect(+ applicationTranslationCatalogService.buildEffectiveEntityI18nContext,+ ).toHaveBeenCalledWith({+ applicationId: STANDARD_APPLICATION_ID,+ loaders,+ locale: 'fr-FR',+ workspaceId: WORKSPACE_ID,+ });+ });++ it('leaves a custom skill that no catalog knows unchanged', async () => {+ const { resolver } = buildResolver();+ const skill = aSkill({+ applicationId: CUSTOM_APPLICATION_ID,+ isCustom: true,+ label: 'Lead triage',+ description: 'Routes inbound leads to the right owner',+ });++ const label = await resolver.label(skill, context, workspace);+ const description = await resolver.description(skill, context, workspace);++ expect(label).toBe('Lead triage');+ expect(description).toBe('Routes inbound leads to the right owner');+ });++ it('returns a missing description without resolving a translation', async () => {+ const { resolver, applicationTranslationCatalogService } = buildResolver();++ const description = await resolver.description(+ aSkill({ description: undefined }),+ context,+ workspace,+ );++ expect(description).toBeUndefined();+ expect(+ applicationTranslationCatalogService.buildEffectiveEntityI18nContext,+ ).not.toHaveBeenCalled();+ });+});diff --git a/packages/twenty-server/src/engine/metadata-modules/skill/skill.module.ts b/packages/twenty-server/src/engine/metadata-modules/skill/skill.module.tsindex a4c284a4175..bed68894ed3 100644--- a/packages/twenty-server/src/engine/metadata-modules/skill/skill.module.ts+++ b/packages/twenty-server/src/engine/metadata-modules/skill/skill.module.ts@@ -1,6 +1,7 @@import { Module } from '@nestjs/common';import { ApplicationModule } from 'src/engine/core-modules/application/application.module';+import { ApplicationTranslationCatalogModule } from 'src/engine/metadata-modules/application-translation-catalog/application-translation-catalog.module';import { WorkspaceManyOrAllFlatEntityMapsCacheModule } from 'src/engine/metadata-modules/flat-entity/services/workspace-many-or-all-flat-entity-maps-cache.module';import { FlatSkillModule } from 'src/engine/metadata-modules/flat-skill/flat-skill.module';import { PermissionsModule } from 'src/engine/metadata-modules/permissions/permissions.module';@@ -17,6 +18,7 @@ import { ApplicationRegistrationLookupModule } from 'src/engine/core-modules/appWorkspaceManyOrAllFlatEntityMapsCacheModule,WorkspaceMigrationModule,ApplicationModule,+ ApplicationTranslationCatalogModule,PermissionsModule,FlatSkillModule,],diff --git a/packages/twenty-server/src/engine/metadata-modules/skill/skill.resolver.ts b/packages/twenty-server/src/engine/metadata-modules/skill/skill.resolver.tsindex e2df8c042a0..29dc2e4f030 100644--- a/packages/twenty-server/src/engine/metadata-modules/skill/skill.resolver.ts+++ b/packages/twenty-server/src/engine/metadata-modules/skill/skill.resolver.ts@@ -1,19 +1,31 @@import { UseGuards, UseInterceptors, UseFilters } from '@nestjs/common';-import { Args, Mutation, Query } from '@nestjs/graphql';+import {+ Args,+ Context,+ Mutation,+ Parent,+ Query,+ ResolveField,+} from '@nestjs/graphql';+import { isNonEmptyString } from '@sniptt/guards';import { PermissionFlagType } from 'twenty-shared/constants';import { UUIDScalarType } from 'src/engine/api/graphql/workspace-schema-builder/graphql-types/scalars';import { ApplicationExceptionFilter } from 'src/engine/core-modules/application/application-exception-filter';import { type FlatApplication } from 'src/engine/core-modules/application/types/flat-application.type';import { canCallerReachApplication } from 'src/engine/core-modules/application/utils/can-caller-reach-application.util';+import { type I18nContext } from 'src/engine/core-modules/i18n/types/i18n-context.type';import { WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';+import { type IDataloaders } from 'src/engine/dataloaders/dataloader.interface';import { ApplicationTargetArg } from 'src/engine/decorators/auth/application-target-arg.decorator';import { AuthApplication } from 'src/engine/decorators/auth/auth-application.decorator';import { AuthWorkspace } from 'src/engine/decorators/auth/auth-workspace.decorator';import { MetadataResolver } from 'src/engine/api/graphql/graphql-config/decorators/metadata-resolver.decorator';import { SettingsPermissionGuard } from 'src/engine/guards/settings-permission.guard';import { AuthPrincipalGuard } from 'src/engine/guards/auth-principal.guard';+import { ApplicationTranslationCatalogService } from 'src/engine/metadata-modules/application-translation-catalog/services/application-translation-catalog.service';+import { resolveEffectiveEntityProperty } from 'src/engine/metadata-modules/overrides/utils/resolve-effective-entity-property.util';import { CreateSkillInput } from 'src/engine/metadata-modules/skill/dtos/create-skill.input';import { SkillDTO } from 'src/engine/metadata-modules/skill/dtos/skill.dto';import { UpdateSkillInput } from 'src/engine/metadata-modules/skill/dtos/update-skill.input';@@ -45,7 +57,42 @@ import { ApplicationTargetGuard } from 'src/engine/guards/application-target.gua@MetadataResolver(() => SkillDTO)@UseFilters(ApplicationExceptionFilter, AuthGraphqlApiExceptionFilter)export class SkillResolver {- constructor(private readonly skillService: SkillService) {}+ constructor(+ private readonly skillService: SkillService,+ private readonly applicationTranslationCatalogService: ApplicationTranslationCatalogService,+ ) {}++ @ResolveField(() => String)+ async label(+ @Parent() skill: SkillDTO,+ @Context() context: { loaders: IDataloaders } & I18nContext,+ @AuthWorkspace() workspace: WorkspaceEntity,+ ): Promise<string> {+ return this.resolveTranslatableProperty({+ skill,+ property: 'label',+ context,+ workspaceId: workspace.id,+ });+ }++ @ResolveField(() => String, { nullable: true })+ async description(+ @Parent() skill: SkillDTO,+ @Context() context: { loaders: IDataloaders } & I18nContext,+ @AuthWorkspace() workspace: WorkspaceEntity,+ ): Promise<string | undefined> {+ if (!isNonEmptyString(skill.description)) {+ return skill.description;+ }++ return this.resolveTranslatableProperty({+ skill,+ property: 'description',+ context,+ workspaceId: workspace.id,+ });+ }@Query(() => [SkillDTO])async skills(@@ -125,4 +172,32 @@ export class SkillResolver {): Promise<SkillDTO> {return this.skillService.deactivate(id, workspace.id);}++ private async resolveTranslatableProperty({+ skill,+ property,+ context,+ workspaceId,+ }: {+ skill: SkillDTO;+ property: 'label' | 'description';+ context: { loaders: IDataloaders } & I18nContext;+ workspaceId: string;+ }): Promise<string> {+ return resolveEffectiveEntityProperty({+ metadataName: 'skill',+ baseValue: skill[property],+ overrides: undefined,+ property,+ i18nContext:+ await this.applicationTranslationCatalogService.buildEffectiveEntityI18nContext(+ {+ applicationId: skill.applicationId,+ loaders: context.loaders,+ locale: context.req.locale,+ workspaceId,+ },+ ),+ });+ }}diff --git a/packages/twenty-server/src/engine/workspace-manager/standard-objects-prefill-data/utils/prefill-workflow-command-menu-items.util.ts b/packages/twenty-server/src/engine/workspace-manager/standard-objects-prefill-data/utils/prefill-workflow-command-menu-items.util.tsindex 6d5891040ef..004f5972da1 100644--- a/packages/twenty-server/src/engine/workspace-manager/standard-objects-prefill-data/utils/prefill-workflow-command-menu-items.util.ts+++ b/packages/twenty-server/src/engine/workspace-manager/standard-objects-prefill-data/utils/prefill-workflow-command-menu-items.util.ts@@ -1,3 +1,4 @@+import { msg } from '@lingui/core/macro';import { v4 } from 'uuid';import { isDefined } from 'twenty-shared/utils';@@ -7,6 +8,7 @@ import { EngineComponentKey } from 'src/engine/metadata-modules/command-menu-iteimport { type FlatCommandMenuItem } from 'src/engine/metadata-modules/flat-command-menu-item/types/flat-command-menu-item.type';import { type WorkspaceManyOrAllFlatEntityMapsCacheService } from 'src/engine/metadata-modules/flat-entity/services/workspace-many-or-all-flat-entity-maps-cache.service';import { getWorkflowPrefillIds } from 'src/engine/workspace-manager/standard-objects-prefill-data/utils/prefill-workflows.util';+import { i18nLabel } from 'src/engine/workspace-manager/twenty-standard-application/utils/i18n-label.util';import { type WorkspaceMigrationValidateBuildAndRunService } from 'src/engine/workspace-manager/workspace-migration/services/workspace-migration-validate-build-and-run-service';const QUICK_LEAD_COMMAND_MENU_ITEM_UNIVERSAL_IDENTIFIER =@@ -60,9 +62,13 @@ export const prefillWorkflowCommandMenuItems = async ({frontComponentId: null,frontComponentUniversalIdentifier: null,engineComponentKey: EngineComponentKey.TRIGGER_WORKFLOW_VERSION,- label: 'Quick Lead',+ label: i18nLabel(+ msg({ message: `Quick Lead`, context: 'commandMenuItem.label' }),+ ),icon: 'IconUserPlus',- shortLabel: 'Quick Lead',+ shortLabel: i18nLabel(+ msg({ message: `Quick Lead`, context: 'commandMenuItem.shortLabel' }),+ ),position: 100,isPinned: false,availabilityType: CommandMenuItemAvailabilityType.GLOBAL,diff --git a/packages/twenty-server/src/engine/workspace-manager/twenty-standard-application/utils/skill-metadata/create-standard-flat-skill-metadata.util.ts b/packages/twenty-server/src/engine/workspace-manager/twenty-standard-application/utils/skill-metadata/create-standard-flat-skill-metadata.util.tsindex 978dcf373fa..e6d0feb5b72 100644--- a/packages/twenty-server/src/engine/workspace-manager/twenty-standard-application/utils/skill-metadata/create-standard-flat-skill-metadata.util.ts+++ b/packages/twenty-server/src/engine/workspace-manager/twenty-standard-application/utils/skill-metadata/create-standard-flat-skill-metadata.util.ts@@ -1,5 +1,8 @@+import { msg } from '@lingui/core/macro';+import { type FlatSkill } from 'src/engine/metadata-modules/flat-skill/types/flat-skill.type';import { type AllStandardSkillName } from 'src/engine/workspace-manager/twenty-standard-application/types/all-standard-skill-name.type';+import { i18nLabel } from 'src/engine/workspace-manager/twenty-standard-application/utils/i18n-label.util';import {type CreateStandardSkillArgs,createStandardSkillFlatMetadata,@@ -12,9 +15,15 @@ export const STANDARD_FLAT_SKILL_METADATA_BUILDERS_BY_SKILL_NAME = {context: {skillName: 'workflow-building',name: 'workflow-building',- label: 'Workflow Building',- description:- 'Use when the user wants something to happen automatically: creating, changing, debugging or deleting a workflow, or phrasing a rule as when X happens do Y',+ label: i18nLabel(+ msg({ message: `Workflow Building`, context: 'skill.label' }),+ ),+ description: i18nLabel(+ msg({+ message: `Use when the user wants something to happen automatically: creating, changing, debugging or deleting a workflow, or phrasing a rule as when X happens do Y`,+ context: 'skill.description',+ }),+ ),icon: 'IconSettingsAutomation',content: `# Workflow Building Skill@@ -156,9 +165,15 @@ Prioritize user understanding and workflow effectiveness.`,context: {skillName: 'data-manipulation',name: 'data-manipulation',- label: 'Data Manipulation',- description:- 'Use when finding, filtering, creating, updating or importing records, and whenever a request needs sorting or touches more than a handful of rows',+ label: i18nLabel(+ msg({ message: `Data Manipulation`, context: 'skill.label' }),+ ),+ description: i18nLabel(+ msg({+ message: `Use when finding, filtering, creating, updating or importing records, and whenever a request needs sorting or touches more than a handful of rows`,+ context: 'skill.description',+ }),+ ),icon: 'IconDatabase',content: `# Data Manipulation Skill@@ -286,9 +301,15 @@ Prioritize data integrity and provide clear feedback on operations performed.`,context: {skillName: 'workspace-demo-seeding',name: 'workspace-demo-seeding',- label: 'Workspace Demo Seeding',- description:- 'Use only when explicitly asked to fill a workspace with demonstration data for a given industry',+ label: i18nLabel(+ msg({ message: `Workspace Demo Seeding`, context: 'skill.label' }),+ ),+ description: i18nLabel(+ msg({+ message: `Use only when explicitly asked to fill a workspace with demonstration data for a given industry`,+ context: 'skill.description',+ }),+ ),icon: 'IconDatabase',content: `# Workspace Demo Seeding SkillYou will transform the existing standard workspace into a fully custom demo tailored to the user's business type.@@ -408,9 +429,15 @@ Loop STEP 6 for all the custom objectscontext: {skillName: 'dashboard-building',name: 'dashboard-building',- label: 'Dashboard Building',- description:- 'Use when the user asks for a dashboard, a chart, a metric tile or a report page, or wants to change one that exists',+ label: i18nLabel(+ msg({ message: `Dashboard Building`, context: 'skill.label' }),+ ),+ description: i18nLabel(+ msg({+ message: `Use when the user asks for a dashboard, a chart, a metric tile or a report page, or wants to change one that exists`,+ context: 'skill.description',+ }),+ ),icon: 'IconLayoutDashboard',content: `# Dashboard Building Skill@@ -566,9 +593,15 @@ After creating a tab, use its returned tabId as pageLayoutTabId when calling addcontext: {skillName: 'metadata-building',name: 'metadata-building',- label: 'Metadata Building',- description:- 'Use when the data model itself changes: adding or editing objects, fields, relations or select options',+ label: i18nLabel(+ msg({ message: `Metadata Building`, context: 'skill.label' }),+ ),+ description: i18nLabel(+ msg({+ message: `Use when the data model itself changes: adding or editing objects, fields, relations or select options`,+ context: 'skill.description',+ }),+ ),icon: 'IconBuildingSkyscraper',content: `# Metadata Building Skill@@ -647,9 +680,15 @@ Prioritize data model integrity and user understanding.`,context: {skillName: 'code-interpreter',name: 'code-interpreter',- label: 'Code Interpreter',- description:- 'Use for Python over data the record tools cannot express: statistics, chart images, parsing an uploaded file. Do not use it for ordinary record reads and writes',+ label: i18nLabel(+ msg({ message: `Code Interpreter`, context: 'skill.label' }),+ ),+ description: i18nLabel(+ msg({+ message: `Use for Python over data the record tools cannot express: statistics, chart images, parsing an uploaded file. Do not use it for ordinary record reads and writes`,+ context: 'skill.description',+ }),+ ),icon: 'IconCode',content: `# Code Interpreter Skill@@ -813,9 +852,15 @@ For importing CSV/Excel/spreadsheet data, load the \`data-manipulation\` skill fcontext: {skillName: 'xlsx',name: 'xlsx',- label: 'Excel & Spreadsheets',- description:- 'Use whenever a spreadsheet is the input or the output, including formulas, formatting, charts and CSV conversion',+ label: i18nLabel(+ msg({ message: `Excel & Spreadsheets`, context: 'skill.label' }),+ ),+ description: i18nLabel(+ msg({+ message: `Use whenever a spreadsheet is the input or the output, including formulas, formatting, charts and CSV conversion`,+ context: 'skill.description',+ }),+ ),icon: 'IconFileSpreadsheet',content: `# Excel Processing Skill@@ -951,9 +996,15 @@ If errors found, fix them and recalculate again.context: {skillName: 'pdf',name: 'pdf',- label: 'PDF Processing',- description:- 'Use whenever a PDF is involved: reading text or tables, filling a form, creating, merging or splitting one',+ label: i18nLabel(+ msg({ message: `PDF Processing`, context: 'skill.label' }),+ ),+ description: i18nLabel(+ msg({+ message: `Use whenever a PDF is involved: reading text or tables, filling a form, creating, merging or splitting one`,+ context: 'skill.description',+ }),+ ),icon: 'IconFileTypePdf',content: `# PDF Processing Skill@@ -1089,9 +1140,15 @@ writer.write('/home/user/output/page1.pdf')context: {skillName: 'docx',name: 'docx',- label: 'Word Documents',- description:- 'Use whenever a Word document is the input or the output, including templates, styles and tracked changes',+ label: i18nLabel(+ msg({ message: `Word Documents`, context: 'skill.label' }),+ ),+ description: i18nLabel(+ msg({+ message: `Use whenever a Word document is the input or the output, including templates, styles and tracked changes`,+ context: 'skill.description',+ }),+ ),icon: 'IconFileTypeDocx',content: `# Word Document Processing Skill@@ -1248,9 +1305,15 @@ para.paragraph_format.space_after = Pt(12)context: {skillName: 'view-building',name: 'view-building',- label: 'View Building',- description:- 'Use when creating or changing a view of any type, table, kanban or calendar, including the columns, filters, sorts and grouping on it',+ label: i18nLabel(+ msg({ message: `View Building`, context: 'skill.label' }),+ ),+ description: i18nLabel(+ msg({+ message: `Use when creating or changing a view of any type, table, kanban or calendar, including the columns, filters, sorts and grouping on it`,+ context: 'skill.description',+ }),+ ),icon: 'IconLayoutBoard',content: `# View Building Skill@@ -1385,9 +1448,15 @@ Some fields carry sub-fields you filter on directly:context: {skillName: 'pptx',name: 'pptx',- label: 'PowerPoint',- description:- 'Use whenever a PowerPoint deck is the input or the output, including slides, templates, tables and charts',+ label: i18nLabel(+ msg({ message: `PowerPoint`, context: 'skill.label' }),+ ),+ description: i18nLabel(+ msg({+ message: `Use whenever a PowerPoint deck is the input or the output, including slides, templates, tables and charts`,+ context: 'skill.description',+ }),+ ),icon: 'IconPresentation',content: `# PowerPoint Processing Skill@@ -1562,9 +1631,13 @@ python /home/user/scripts/pptx/replace.py input.pptx '{"{{company}}": "Acme Corpcontext: {skillName: 'roles',name: 'roles',- label: 'Roles',- description:- 'Use when the user asks who can see or change what: creating a role, editing permissions, or assigning a role to someone',+ label: i18nLabel(msg({ message: `Roles`, context: 'skill.label' })),+ description: i18nLabel(+ msg({+ message: `Use when the user asks who can see or change what: creating a role, editing permissions, or assigning a role to someone`,+ context: 'skill.description',+ }),+ ),icon: 'IconLockAccess',content: `# Roles Skill@@ -1663,9 +1736,15 @@ Report what changed in plain terms: which role, what it can now do, and who is acontext: {skillName: 'meeting-prep',name: 'meeting-prep',- label: 'Meeting Prep',- description:- 'Use before a call or a meeting, and whenever the user asks who am I talking to, brief me on this account, or what do I need to know before this conversation',+ label: i18nLabel(+ msg({ message: `Meeting Prep`, context: 'skill.label' }),+ ),+ description: i18nLabel(+ msg({+ message: `Use before a call or a meeting, and whenever the user asks who am I talking to, brief me on this account, or what do I need to know before this conversation`,+ context: 'skill.description',+ }),+ ),icon: 'IconCalendarEvent',content: `# Meeting Prep Skill@@ -1711,9 +1790,15 @@ Reference every record you name so the user can click through to it.context: {skillName: 'deal-review',name: 'deal-review',- label: 'Deal Review',- description:- 'Use when the user asks how a deal is doing, which deals are at risk, what is stuck or going quiet, or asks for a pipeline review',+ label: i18nLabel(+ msg({ message: `Deal Review`, context: 'skill.label' }),+ ),+ description: i18nLabel(+ msg({+ message: `Use when the user asks how a deal is doing, which deals are at risk, what is stuck or going quiet, or asks for a pipeline review`,+ context: 'skill.description',+ }),+ ),icon: 'IconTargetArrow',content: `# Deal Review Skill@@ -1757,9 +1842,15 @@ Say which signals you could not evaluate and why. A review that hides its gaps icontext: {skillName: 'crm-hygiene',name: 'crm-hygiene',- label: 'CRM Hygiene',- description:- 'Use when the user asks to clean up the CRM, find duplicates, fill in missing fields, or asks why the data is messy or which records are stale',+ label: i18nLabel(+ msg({ message: `CRM Hygiene`, context: 'skill.label' }),+ ),+ description: i18nLabel(+ msg({+ message: `Use when the user asks to clean up the CRM, find duplicates, fill in missing fields, or asks why the data is messy or which records are stale`,+ context: 'skill.description',+ }),+ ),icon: 'IconListCheck',content: `# CRM Hygiene Skill@@ -1805,9 +1896,13 @@ Always confirm before writing. Show what you will change and wait.context: {skillName: 'enrich',name: 'enrich',- label: 'Enrich',- description:- 'Use when the user asks to research or enrich a company or a person, fill in what the CRM does not know about them, or find out what a company actually does',+ label: i18nLabel(msg({ message: `Enrich`, context: 'skill.label' })),+ description: i18nLabel(+ msg({+ message: `Use when the user asks to research or enrich a company or a person, fill in what the CRM does not know about them, or find out what a company actually does`,+ context: 'skill.description',+ }),+ ),icon: 'IconSearch',content: `# Enrich Skilldiff --git a/packages/twenty-server/src/engine/workspace-manager/workspace-cleaner/services/cleaner.workspace-service.ts b/packages/twenty-server/src/engine/workspace-manager/workspace-cleaner/services/cleaner.workspace-service.tsindex a17567b33e3..7724b14ec0d 100644--- a/packages/twenty-server/src/engine/workspace-manager/workspace-cleaner/services/cleaner.workspace-service.ts+++ b/packages/twenty-server/src/engine/workspace-manager/workspace-cleaner/services/cleaner.workspace-service.ts@@ -213,6 +213,9 @@ export class CleanerWorkspaceService {const html = await renderEmail(emailTemplate, { pretty: true });const text = await renderEmail(emailTemplate, { plainText: true });+ const i18n = this.i18nService.getI18nInstance(workspaceMember.locale);+ const subject = i18n._(msg`Your workspace has been deleted`);+if (!isDefined(workspaceMember.userEmail)) {throw new Error('Workspace member email is missing');}@@ -222,7 +225,7 @@ export class CleanerWorkspaceService {from: `${this.twentyConfigService.get('EMAIL_FROM_NAME',)} <${this.twentyConfigService.get('EMAIL_FROM_ADDRESS')}>`,- subject: 'Your workspace has been deleted',+ subject,html,text,});diff --git a/packages/twenty-server/src/modules/calendar/calendar-event-creation-manager/resolvers/__tests__/create-calendar-event.resolver.spec.ts b/packages/twenty-server/src/modules/calendar/calendar-event-creation-manager/resolvers/__tests__/create-calendar-event.resolver.spec.tsnew file mode 100644index 00000000000..45b9b2bb874--- /dev/null+++ b/packages/twenty-server/src/modules/calendar/calendar-event-creation-manager/resolvers/__tests__/create-calendar-event.resolver.spec.ts@@ -0,0 +1,111 @@+import { type MessageDescriptor } from '@lingui/core';++import { type I18nContext } from 'src/engine/core-modules/i18n/types/i18n-context.type';+import { type WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';+import { type CreateCalendarEventInput } from 'src/modules/calendar/calendar-event-creation-manager/dtos/create-calendar-event.input';+import {+ CalendarEventCreationException,+ CalendarEventCreationExceptionCode,+} from 'src/modules/calendar/calendar-event-creation-manager/exceptions/calendar-event-creation.exception';+import { CreateCalendarEventResolver } from 'src/modules/calendar/calendar-event-creation-manager/resolvers/create-calendar-event.resolver';++const WORKSPACE_ID = '33333333-3333-4333-8333-333333333333';+const USER_WORKSPACE_ID = '66666666-6666-4666-8666-666666666666';++describe('CreateCalendarEventResolver errors', () => {+ const workspace = { id: WORKSPACE_ID } as WorkspaceEntity;+ const context: I18nContext = { req: { locale: 'fr-FR' } };+ const input = {+ connectedAccountId: 'connected-account-id',+ title: 'Kickoff',+ startsAt: '2026-07-01T15:00:00Z',+ endsAt: '2026-07-01T16:00:00Z',+ } as CreateCalendarEventInput;++ const buildResolver = ({+ composeCalendarEvent,+ createComposedCalendarEvent = jest.fn(),+ }: {+ composeCalendarEvent: jest.Mock;+ createComposedCalendarEvent?: jest.Mock;+ }) => {+ const i18nService = {+ getI18nInstance: jest.fn((locale: string) => ({+ _: (descriptor: MessageDescriptor) => `${locale}:${descriptor.message}`,+ })),+ };++ return new CreateCalendarEventResolver(+ { verifyUsableByCaller: jest.fn() } as never,+ { composeCalendarEvent } as never,+ { createComposedCalendarEvent } as never,+ i18nService as never,+ );+ };++ it('translates a composition failure for the request locale', async () => {+ const resolver = buildResolver({+ composeCalendarEvent: jest.fn().mockResolvedValue({+ success: false,+ error: { id: 'title-required', message: 'A title is required' },+ }),+ });++ const result = await resolver.createCalendarEvent(+ input,+ workspace,+ USER_WORKSPACE_ID,+ context,+ );++ expect(result).toEqual({+ success: false,+ error: 'fr-FR:A title is required',+ });+ });++ it('returns the translated user-friendly message of a provider failure', async () => {+ const exception = new CalendarEventCreationException(+ 'Google Calendar API returned 403: insufficientPermissions',+ CalendarEventCreationExceptionCode.PROVIDER_REQUEST_FAILED,+ );+ const resolver = buildResolver({+ composeCalendarEvent: jest+ .fn()+ .mockResolvedValue({ success: true, data: {} }),+ createComposedCalendarEvent: jest.fn().mockRejectedValue(exception),+ });++ const result = await resolver.createCalendarEvent(+ input,+ workspace,+ USER_WORKSPACE_ID,+ context,+ );++ expect(result).toEqual({+ success: false,+ error: `fr-FR:${exception.userFriendlyMessage.message}`,+ });+ });++ it('returns no error text for an unexpected error so the client shows its fallback', async () => {+ const resolver = buildResolver({+ composeCalendarEvent: jest+ .fn()+ .mockResolvedValue({ success: true, data: {} }),+ createComposedCalendarEvent: jest+ .fn()+ .mockRejectedValue(new Error('socket hang up')),+ });++ const result = await resolver.createCalendarEvent(+ input,+ workspace,+ USER_WORKSPACE_ID,+ context,+ );++ expect(result).toStrictEqual({ success: false });+ });+});diff --git a/packages/twenty-server/src/modules/calendar/calendar-event-creation-manager/resolvers/create-calendar-event.resolver.ts b/packages/twenty-server/src/modules/calendar/calendar-event-creation-manager/resolvers/create-calendar-event.resolver.tsindex 4540811d850..9ce4c8e9acb 100644--- a/packages/twenty-server/src/modules/calendar/calendar-event-creation-manager/resolvers/create-calendar-event.resolver.ts+++ b/packages/twenty-server/src/modules/calendar/calendar-event-creation-manager/resolvers/create-calendar-event.resolver.ts@@ -5,13 +5,15 @@ import {UseGuards,UsePipes,} from '@nestjs/common';-import { Args, Mutation } from '@nestjs/graphql';+import { Args, Context, Mutation } from '@nestjs/graphql';import { PermissionFlagType } from 'twenty-shared/constants';import { MetadataResolver } from 'src/engine/api/graphql/graphql-config/decorators/metadata-resolver.decorator';import { AuthGraphqlApiExceptionFilter } from 'src/engine/core-modules/auth/filters/auth-graphql-api-exception.filter';import { ResolverValidationPipe } from 'src/engine/core-modules/graphql/pipes/resolver-validation.pipe';+import { I18nService } from 'src/engine/core-modules/i18n/i18n.service';+import { type I18nContext } from 'src/engine/core-modules/i18n/types/i18n-context.type';import { WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';import { AuthUserWorkspaceId } from 'src/engine/decorators/auth/auth-user-workspace-id.decorator';import { AuthWorkspace } from 'src/engine/decorators/auth/auth-workspace.decorator';@@ -22,6 +24,7 @@ import { CreateCalendarEventOutputDTO } from 'src/modules/calendar/calendar-evenimport { CreateCalendarEventInput } from 'src/modules/calendar/calendar-event-creation-manager/dtos/create-calendar-event.input';import { CalendarEventComposerService } from 'src/modules/calendar/calendar-event-creation-manager/services/calendar-event-composer.service';import { CreateCalendarEventService } from 'src/modules/calendar/calendar-event-creation-manager/services/create-calendar-event.service';+import { CustomException } from 'src/utils/custom-exception';@MetadataResolver()@UsePipes(ResolverValidationPipe)@@ -47,6 +50,7 @@ export class CreateCalendarEventResolver {private readonly connectedAccountMetadataService: ConnectedAccountMetadataService,private readonly calendarEventComposerService: CalendarEventComposerService,private readonly createCalendarEventService: CreateCalendarEventService,+ private readonly i18nService: I18nService,) {}@Mutation(() => CreateCalendarEventOutputDTO)@@ -54,6 +58,7 @@ export class CreateCalendarEventResolver {@Args('input') input: CreateCalendarEventInput,@AuthWorkspace() workspace: WorkspaceEntity,@AuthUserWorkspaceId() userWorkspaceId: string,+ @Context() context: I18nContext,): Promise<CreateCalendarEventOutputDTO> {try {await this.connectedAccountMetadataService.verifyUsableByCaller({@@ -83,7 +88,9 @@ export class CreateCalendarEventResolver {if (!result.success) {return {success: false,- error: result.error,+ error: this.i18nService+ .getI18nInstance(context.req.locale)+ ._(result.error),};}@@ -112,13 +119,16 @@ export class CreateCalendarEventResolver {this.logger.error(`Failed to create calendar event: ${error}`);- return {- success: false,- error:- error instanceof Error- ? error.message- : 'Failed to create calendar event',- };+ if (error instanceof CustomException) {+ return {+ success: false,+ error: this.i18nService+ .getI18nInstance(context.req.locale)+ ._(error.userFriendlyMessage),+ };+ }++ return { success: false };}}}diff --git a/packages/twenty-server/src/modules/calendar/calendar-event-creation-manager/services/calendar-event-composer.service.ts b/packages/twenty-server/src/modules/calendar/calendar-event-creation-manager/services/calendar-event-composer.service.tsindex 2b3ca786bb4..d1b646cfbea 100644--- a/packages/twenty-server/src/modules/calendar/calendar-event-creation-manager/services/calendar-event-composer.service.ts+++ b/packages/twenty-server/src/modules/calendar/calendar-event-creation-manager/services/calendar-event-composer.service.ts@@ -1,6 +1,8 @@import { Injectable } from '@nestjs/common';import { InjectRepository } from '@nestjs/typeorm';+import { type MessageDescriptor } from '@lingui/core';+import { msg } from '@lingui/core/macro';import { isNonEmptyString } from '@sniptt/guards';import { MAX_EMAIL_RECIPIENTS } from 'twenty-shared/constants';import { isDefined, isValidUuid } from 'twenty-shared/utils';@@ -28,7 +30,7 @@ type ResolvedCalendarAccount =connectedAccount: ConnectedAccountEntity;calendarChannel: CalendarChannelEntity;}- | { error: string };+ | { error: MessageDescriptor };@Injectable()export class CalendarEventComposerService {@@ -65,9 +67,11 @@ export class CalendarEventComposerService {const missingScopes = getMissingCreateEventScopes(connectedAccount);if (missingScopes.length > 0) {+ const missingScopeList = missingScopes.join(', ');+return {success: false,- error: `The connected ${connectedAccount.provider} account is missing calendar permissions (${missingScopes.join(', ')}). Please reconnect the account to grant calendar access.`,+ error: msg`The connected ${connectedAccount.provider} account is missing calendar permissions (${missingScopeList}). Please reconnect the account to grant calendar access.`,};}@@ -79,11 +83,11 @@ export class CalendarEventComposerService {private normalizeAndValidateInput(params: ComposeCalendarEventParams,- ): CalendarEventToCreate | { error: string } {+ ): CalendarEventToCreate | { error: MessageDescriptor } {const title = params.title?.trim();if (!isNonEmptyString(title)) {- return { error: 'A title is required to create a calendar event' };+ return { error: msg`A title is required to create a calendar event` };}const isFullDay = params.isFullDay ?? false;@@ -101,7 +105,9 @@ export class CalendarEventComposerService {const timeZone = resolveCalendarEventTimeZone(params.timeZone);if (!isValidTimeZone(timeZone)) {- return { error: `timeZone '${timeZone}' is not a valid IANA time zone` };+ return {+ error: msg`timeZone "${timeZone}" is not a valid IANA time zone`,+ };}const sendInvitations = params.sendInvitations ?? false;@@ -112,8 +118,10 @@ export class CalendarEventComposerService {: [];if (attendeeEmails.length > MAX_EMAIL_RECIPIENTS) {+ const attendeeCount = attendeeEmails.length;+return {- error: `Too many attendees: ${attendeeEmails.length}. Maximum allowed is ${MAX_EMAIL_RECIPIENTS}.`,+ error: msg`Too many attendees: ${attendeeCount}. Maximum allowed is ${MAX_EMAIL_RECIPIENTS}.`,};}@@ -122,8 +130,10 @@ export class CalendarEventComposerService {);if (invalidAttendees.length > 0) {+ const invalidAttendeeList = invalidAttendees.join(', ');+return {- error: `Invalid attendee email addresses: ${invalidAttendees.join(', ')}`,+ error: msg`Invalid attendee email addresses: ${invalidAttendeeList}`,};}@@ -147,7 +157,7 @@ export class CalendarEventComposerService {startsAt: string,endsAt: string,isFullDay: boolean,- ): string | undefined {+ ): MessageDescriptor | undefined {if (isFullDay) {const startDate = startsAt.slice(0, 10);const endDate = endsAt.slice(0, 10);@@ -156,11 +166,11 @@ export class CalendarEventComposerService {!dateSchema.safeParse(startDate).success ||!dateSchema.safeParse(endDate).success) {- return 'startsAt and endsAt must be valid ISO 8601 dates';+ return msg`startsAt and endsAt must be valid ISO 8601 dates`;}if (endDate <= startDate) {- return 'endsAt must be a later day than startsAt for all-day events';+ return msg`endsAt must be a later day than startsAt for all-day events`;}return undefined;@@ -170,11 +180,11 @@ export class CalendarEventComposerService {!offsetDateTimeSchema.safeParse(startsAt).success ||!offsetDateTimeSchema.safeParse(endsAt).success) {- return 'startsAt and endsAt must be ISO 8601 date-times with an offset (e.g. 2026-07-01T15:00:00Z)';+ return msg`startsAt and endsAt must be ISO 8601 date-times with an offset (e.g. 2026-07-01T15:00:00Z)`;}if (Date.parse(endsAt) <= Date.parse(startsAt)) {- return 'endsAt must be after startsAt';+ return msg`endsAt must be after startsAt`;}return undefined;@@ -194,7 +204,9 @@ export class CalendarEventComposerService {// A blank id (the workflow node's default) falls back to the default account.if (isNonEmptyString(connectedAccountId)) {if (!isValidUuid(connectedAccountId)) {- return { error: 'The provided connectedAccountId is not a valid UUID' };+ return {+ error: msg`The provided connectedAccountId is not a valid UUID`,+ };}const connectedAccount = await this.connectedAccountRepository.findOne({@@ -203,13 +215,13 @@ export class CalendarEventComposerService {if (!isDefined(connectedAccount)) {return {- error: `No connected account found for id '${connectedAccountId}'`,+ error: msg`No connected account found for id "${connectedAccountId}"`,};}if (!isCalendarCreationSupportedProvider(connectedAccount.provider)) {return {- error: `Calendar event creation is only supported for Google, Microsoft and CalDAV accounts (got ${connectedAccount.provider})`,+ error: msg`Calendar event creation is only supported for Google, Microsoft and CalDAV accounts (got ${connectedAccount.provider})`,};}@@ -220,7 +232,7 @@ export class CalendarEventComposerService {if (!isDefined(calendarChannel)) {return {- error: `Connected account '${connectedAccountId}' has no calendar channel with sync enabled. Enable calendar sync for this account first.`,+ error: msg`Connected account "${connectedAccountId}" has no calendar channel with sync enabled. Enable calendar sync for this account first.`,};}@@ -250,8 +262,7 @@ export class CalendarEventComposerService {if (!isDefined(calendarChannel)) {return {- error:- 'No Google, Microsoft or CalDAV account with calendar sync is connected in this workspace',+ error: msg`No Google, Microsoft or CalDAV account with calendar sync is connected in this workspace`,};}diff --git a/packages/twenty-server/src/modules/calendar/calendar-event-creation-manager/types/calendar-event-composer-result.type.ts b/packages/twenty-server/src/modules/calendar/calendar-event-creation-manager/types/calendar-event-composer-result.type.tsindex a2bc7609cb7..b1cf72fa92d 100644--- a/packages/twenty-server/src/modules/calendar/calendar-event-creation-manager/types/calendar-event-composer-result.type.ts+++ b/packages/twenty-server/src/modules/calendar/calendar-event-creation-manager/types/calendar-event-composer-result.type.ts@@ -1,5 +1,7 @@+import { type MessageDescriptor } from '@lingui/core';+import { type ComposedCalendarEvent } from 'src/modules/calendar/calendar-event-creation-manager/types/composed-calendar-event.type';export type CalendarEventComposerResult =| { success: true; data: ComposedCalendarEvent }- | { success: false; error: string };+ | { success: false; error: MessageDescriptor };diff --git a/packages/twenty-server/src/modules/dashboard/chart-data/resolvers/bar-chart-data.resolver.ts b/packages/twenty-server/src/modules/dashboard/chart-data/resolvers/bar-chart-data.resolver.tsindex 0e382a0639f..18dfcc52fa2 100644--- a/packages/twenty-server/src/modules/dashboard/chart-data/resolvers/bar-chart-data.resolver.ts+++ b/packages/twenty-server/src/modules/dashboard/chart-data/resolvers/bar-chart-data.resolver.ts@@ -1,9 +1,10 @@import { UseFilters, UseGuards, UsePipes } from '@nestjs/common';-import { Args, Query } from '@nestjs/graphql';+import { Args, Context, Query } from '@nestjs/graphql';import { MetadataResolver } from 'src/engine/api/graphql/graphql-config/decorators/metadata-resolver.decorator';import { getWorkspaceAuthContext } from 'src/engine/core-modules/auth/storage/workspace-auth-context.storage';import { ResolverValidationPipe } from 'src/engine/core-modules/graphql/pipes/resolver-validation.pipe';+import { type I18nContext } from 'src/engine/core-modules/i18n/types/i18n-context.type';import { NoPermissionGuard } from 'src/engine/guards/no-permission.guard';import { AuthPrincipalGuard } from 'src/engine/guards/auth-principal.guard';import { BarChartDataDTO } from 'src/modules/dashboard/chart-data/dtos/bar-chart-data.dto';@@ -34,6 +35,7 @@ export class BarChartDataResolver {@UseGuards(NoPermissionGuard)async barChartData(@Args('input') input: BarChartDataInput,+ @Context() context: I18nContext,): Promise<BarChartDataDTO> {const authContext = getWorkspaceAuthContext();@@ -42,6 +44,7 @@ export class BarChartDataResolver {configuration: input.configuration,workspaceId: authContext.workspace.id,authContext,+ locale: context.req.locale,});}}diff --git a/packages/twenty-server/src/modules/dashboard/chart-data/resolvers/line-chart-data.resolver.ts b/packages/twenty-server/src/modules/dashboard/chart-data/resolvers/line-chart-data.resolver.tsindex 0cd8936a5ad..90e6994fd1b 100644--- a/packages/twenty-server/src/modules/dashboard/chart-data/resolvers/line-chart-data.resolver.ts+++ b/packages/twenty-server/src/modules/dashboard/chart-data/resolvers/line-chart-data.resolver.ts@@ -1,9 +1,10 @@import { UseFilters, UseGuards, UsePipes } from '@nestjs/common';-import { Args, Query } from '@nestjs/graphql';+import { Args, Context, Query } from '@nestjs/graphql';import { MetadataResolver } from 'src/engine/api/graphql/graphql-config/decorators/metadata-resolver.decorator';import { getWorkspaceAuthContext } from 'src/engine/core-modules/auth/storage/workspace-auth-context.storage';import { ResolverValidationPipe } from 'src/engine/core-modules/graphql/pipes/resolver-validation.pipe';+import { type I18nContext } from 'src/engine/core-modules/i18n/types/i18n-context.type';import { NoPermissionGuard } from 'src/engine/guards/no-permission.guard';import { AuthPrincipalGuard } from 'src/engine/guards/auth-principal.guard';import { LineChartDataInput } from 'src/modules/dashboard/chart-data/dtos/inputs/line-chart-data.input';@@ -34,6 +35,7 @@ export class LineChartDataResolver {@UseGuards(NoPermissionGuard)async lineChartData(@Args('input') input: LineChartDataInput,+ @Context() context: I18nContext,): Promise<LineChartDataDTO> {const authContext = getWorkspaceAuthContext();@@ -42,6 +44,7 @@ export class LineChartDataResolver {configuration: input.configuration,workspaceId: authContext.workspace.id,authContext,+ locale: context.req.locale,});}}diff --git a/packages/twenty-server/src/modules/dashboard/chart-data/services/bar-chart-data.service.ts b/packages/twenty-server/src/modules/dashboard/chart-data/services/bar-chart-data.service.tsindex 9918f0bc83e..4ea67df0e31 100644--- a/packages/twenty-server/src/modules/dashboard/chart-data/services/bar-chart-data.service.ts+++ b/packages/twenty-server/src/modules/dashboard/chart-data/services/bar-chart-data.service.ts@@ -1,9 +1,11 @@import { Injectable } from '@nestjs/common';import { CalendarStartDay } from 'twenty-shared/constants';+import { type APP_LOCALES } from 'twenty-shared/translations';import { isDefined } from 'twenty-shared/utils';import { type WorkspaceAuthContext } from 'src/engine/core-modules/auth/types/workspace-auth-context.type';+import { I18nService } from 'src/engine/core-modules/i18n/i18n.service';import { WorkspaceManyOrAllFlatEntityMapsCacheService } from 'src/engine/metadata-modules/flat-entity/services/workspace-many-or-all-flat-entity-maps-cache.service';import { findFlatEntityByIdInFlatEntityMaps } from 'src/engine/metadata-modules/flat-entity/utils/find-flat-entity-by-id-in-flat-entity-maps.util';import { FlatFieldMetadata } from 'src/engine/metadata-modules/flat-field-metadata/types/flat-field-metadata.type';@@ -33,6 +35,7 @@ type GetBarChartDataParams = {objectMetadataId: string;configuration: BarChartConfigurationDTO;authContext: WorkspaceAuthContext;+ locale: keyof typeof APP_LOCALES;};@Injectable()@@ -41,6 +44,7 @@ export class BarChartDataService {private readonly workspaceManyOrAllFlatEntityMapsCacheService: WorkspaceManyOrAllFlatEntityMapsCacheService,private readonly chartDataQueryService: ChartDataQueryService,private readonly chartRelationLabelService: ChartRelationLabelService,+ private readonly i18nService: I18nService,) {}async getBarChartData({@@ -48,6 +52,7 @@ export class BarChartDataService {objectMetadataId,configuration,authContext,+ locale,}: GetBarChartDataParams): Promise<BarChartDataDTO> {try {const { flatObjectMetadataMaps, flatFieldMetadataMaps } =@@ -181,6 +186,8 @@ export class BarChartDataService {secondaryRelationLabelResolution: relationLabelResolutions.secondary,});+ const i18n = this.i18nService.getI18nInstance(locale);+if (isTwoDimensional && isDefined(secondaryAxisGroupByField)) {return transformToTwoDimensionalBarChartData({filteredRawResults: resolvedResults,@@ -192,6 +199,7 @@ export class BarChartDataService {firstDayOfTheWeek,primaryRelationLabelResolution: relationLabelResolutions.primary,secondaryRelationLabelResolution: relationLabelResolutions.secondary,+ i18n,});}@@ -203,6 +211,7 @@ export class BarChartDataService {userTimezone,firstDayOfTheWeek,relationLabelResolution: relationLabelResolutions.primary,+ i18n,});} catch (error) {throw wrapChartDataQueryError(error, 'Bar chart data retrieval failed');diff --git a/packages/twenty-server/src/modules/dashboard/chart-data/services/line-chart-data.service.ts b/packages/twenty-server/src/modules/dashboard/chart-data/services/line-chart-data.service.tsindex 8b263d3414e..c292374704a 100644--- a/packages/twenty-server/src/modules/dashboard/chart-data/services/line-chart-data.service.ts+++ b/packages/twenty-server/src/modules/dashboard/chart-data/services/line-chart-data.service.ts@@ -1,9 +1,11 @@import { Injectable } from '@nestjs/common';import { CalendarStartDay } from 'twenty-shared/constants';+import { type APP_LOCALES } from 'twenty-shared/translations';import { isDefined } from 'twenty-shared/utils';import { type WorkspaceAuthContext } from 'src/engine/core-modules/auth/types/workspace-auth-context.type';+import { I18nService } from 'src/engine/core-modules/i18n/i18n.service';import { findFlatEntityByIdInFlatEntityMaps } from 'src/engine/metadata-modules/flat-entity/utils/find-flat-entity-by-id-in-flat-entity-maps.util';import { WorkspaceManyOrAllFlatEntityMapsCacheService } from 'src/engine/metadata-modules/flat-entity/services/workspace-many-or-all-flat-entity-maps-cache.service';import { FlatFieldMetadata } from 'src/engine/metadata-modules/flat-field-metadata/types/flat-field-metadata.type';@@ -34,6 +36,7 @@ type GetLineChartDataParams = {objectMetadataId: string;configuration: LineChartConfigurationDTO;authContext: WorkspaceAuthContext;+ locale: keyof typeof APP_LOCALES;};@Injectable()@@ -42,6 +45,7 @@ export class LineChartDataService {private readonly workspaceManyOrAllFlatEntityMapsCacheService: WorkspaceManyOrAllFlatEntityMapsCacheService,private readonly chartDataQueryService: ChartDataQueryService,private readonly chartRelationLabelService: ChartRelationLabelService,+ private readonly i18nService: I18nService,) {}async getLineChartData({@@ -49,6 +53,7 @@ export class LineChartDataService {objectMetadataId,configuration,authContext,+ locale,}: GetLineChartDataParams): Promise<LineChartDataDTO> {try {const { flatObjectMetadataMaps, flatFieldMetadataMaps } =@@ -189,6 +194,8 @@ export class LineChartDataService {secondaryRelationLabelResolution: relationLabelResolutions.secondary,});+ const i18n = this.i18nService.getI18nInstance(locale);+if (isTwoDimensional && isDefined(secondaryAxisGroupByField)) {return transformToTwoDimensionalLineChartData({filteredRawResults: resolvedResults,@@ -201,6 +208,7 @@ export class LineChartDataService {seriesIdPrefix,primaryRelationLabelResolution: relationLabelResolutions.primary,secondaryRelationLabelResolution: relationLabelResolutions.secondary,+ i18n,});}@@ -213,6 +221,7 @@ export class LineChartDataService {firstDayOfTheWeek,seriesIdPrefix,relationLabelResolution: relationLabelResolutions.primary,+ i18n,});} catch (error) {throw wrapChartDataQueryError(error, 'Line chart data retrieval failed');diff --git a/packages/twenty-server/src/modules/dashboard/chart-data/utils/__tests__/get-aggregate-value-label.util.spec.ts b/packages/twenty-server/src/modules/dashboard/chart-data/utils/__tests__/get-aggregate-value-label.util.spec.tsnew file mode 100644index 00000000000..e0b8221e033--- /dev/null+++ b/packages/twenty-server/src/modules/dashboard/chart-data/utils/__tests__/get-aggregate-value-label.util.spec.ts@@ -0,0 +1,51 @@+import { type Messages, setupI18n } from '@lingui/core';+import { compileMessage } from '@lingui/message-utils/compileMessage';+import { msg } from '@lingui/core/macro';+import { AggregateOperations } from 'twenty-shared/types';++import { getAggregateOperationLabel } from 'src/modules/dashboard/chart-data/utils/get-aggregate-operation-label.util';+import { getAggregateValueLabel } from 'src/modules/dashboard/chart-data/utils/get-aggregate-value-label.util';++const operationLabel = '';+const aggregateFieldLabel = '';+const VALUE_LABEL_MESSAGE_ID = msg`${operationLabel} of ${aggregateFieldLabel}`+ .id;++const buildI18n = (locale: string, messages: Messages) => {+ const i18n = setupI18n();++ i18n.setMessagesCompiler(compileMessage);+ i18n.load(locale, messages);+ i18n.activate(locale);++ return i18n;+};++describe('getAggregateValueLabel', () => {+ it('should translate the operation and compose the label with the locale template', () => {+ const i18n = buildI18n('fr-FR', {+ [getAggregateOperationLabel(AggregateOperations.SUM).id]: 'Somme',+ [VALUE_LABEL_MESSAGE_ID]: '{operationLabel} de {aggregateFieldLabel}',+ });++ const result = getAggregateValueLabel({+ aggregateOperation: AggregateOperations.SUM,+ aggregateFieldLabel: 'Montant',+ i18n,+ });++ expect(result).toBe('Somme de Montant');+ });++ it('should keep the source messages when the locale has no translation', () => {+ const i18n = buildI18n('fr-FR', {});++ const result = getAggregateValueLabel({+ aggregateOperation: AggregateOperations.COUNT,+ aggregateFieldLabel: 'Amount',+ i18n,+ });++ expect(result).toBe('Count all of Amount');+ });+});diff --git a/packages/twenty-server/src/modules/dashboard/chart-data/utils/get-aggregate-operation-label.util.ts b/packages/twenty-server/src/modules/dashboard/chart-data/utils/get-aggregate-operation-label.util.tsindex 31d628f7186..b50874d9e64 100644--- a/packages/twenty-server/src/modules/dashboard/chart-data/utils/get-aggregate-operation-label.util.ts+++ b/packages/twenty-server/src/modules/dashboard/chart-data/utils/get-aggregate-operation-label.util.ts@@ -1,34 +1,36 @@+import { type MessageDescriptor } from '@lingui/core';+import { msg } from '@lingui/core/macro';import { AggregateOperations } from 'twenty-shared/types';export const getAggregateOperationLabel = (operation: AggregateOperations,-): string => {+): MessageDescriptor => {switch (operation) {case AggregateOperations.MIN:- return 'Min';+ return msg`Min`;case AggregateOperations.MAX:- return 'Max';+ return msg`Max`;case AggregateOperations.AVG:- return 'Average';+ return msg`Average`;case AggregateOperations.SUM:- return 'Sum';+ return msg`Sum`;case AggregateOperations.COUNT:- return 'Count all';+ return msg`Count all`;case AggregateOperations.COUNT_EMPTY:- return 'Count empty';+ return msg`Count empty`;case AggregateOperations.COUNT_NOT_EMPTY:- return 'Count not empty';+ return msg`Count not empty`;case AggregateOperations.COUNT_UNIQUE_VALUES:- return 'Count unique values';+ return msg`Count unique values`;case AggregateOperations.PERCENTAGE_EMPTY:- return 'Percent empty';+ return msg`Percent empty`;case AggregateOperations.PERCENTAGE_NOT_EMPTY:- return 'Percent not empty';+ return msg`Percent not empty`;case AggregateOperations.COUNT_TRUE:- return 'Count true';+ return msg`Count true`;case AggregateOperations.COUNT_FALSE:- return 'Count false';+ return msg`Count false`;default:- return 'Count';+ return msg`Count`;}};diff --git a/packages/twenty-server/src/modules/dashboard/chart-data/utils/get-aggregate-value-label.util.ts b/packages/twenty-server/src/modules/dashboard/chart-data/utils/get-aggregate-value-label.util.tsnew file mode 100644index 00000000000..6dfce1cc770--- /dev/null+++ b/packages/twenty-server/src/modules/dashboard/chart-data/utils/get-aggregate-value-label.util.ts@@ -0,0 +1,19 @@+import { type I18n } from '@lingui/core';+import { msg } from '@lingui/core/macro';+import { type AggregateOperations } from 'twenty-shared/types';++import { getAggregateOperationLabel } from 'src/modules/dashboard/chart-data/utils/get-aggregate-operation-label.util';++export const getAggregateValueLabel = ({+ aggregateOperation,+ aggregateFieldLabel,+ i18n,+}: {+ aggregateOperation: AggregateOperations;+ aggregateFieldLabel: string;+ i18n: I18n;+}): string => {+ const operationLabel = i18n._(getAggregateOperationLabel(aggregateOperation));++ return i18n._(msg`${operationLabel} of ${aggregateFieldLabel}`);+};diff --git a/packages/twenty-server/src/modules/dashboard/chart-data/utils/transform-to-one-dimensional-bar-chart-data.util.ts b/packages/twenty-server/src/modules/dashboard/chart-data/utils/transform-to-one-dimensional-bar-chart-data.util.tsindex e167257db75..1822261878b 100644--- a/packages/twenty-server/src/modules/dashboard/chart-data/utils/transform-to-one-dimensional-bar-chart-data.util.ts+++ b/packages/twenty-server/src/modules/dashboard/chart-data/utils/transform-to-one-dimensional-bar-chart-data.util.ts@@ -1,3 +1,4 @@+import { type I18n } from '@lingui/core';import { CalendarStartDay } from 'twenty-shared/constants';import { FirstDayOfTheWeek } from 'twenty-shared/types';import {@@ -17,7 +18,7 @@ import { RelationLabelResolution } from 'src/modules/dashboard/chart-data/types/import { applyCumulativeToOneDimensionalBarData } from 'src/modules/dashboard/chart-data/utils/apply-cumulative-to-one-dimensional-bar-data.util';import { applyGapFilling } from 'src/modules/dashboard/chart-data/utils/apply-gap-filling.util';import { buildFormattedToRawLookupDto } from 'src/modules/dashboard/chart-data/utils/build-formatted-to-raw-lookup-dto.util';-import { getAggregateOperationLabel } from 'src/modules/dashboard/chart-data/utils/get-aggregate-operation-label.util';+import { getAggregateValueLabel } from 'src/modules/dashboard/chart-data/utils/get-aggregate-value-label.util';import { getSelectOptions } from 'src/modules/dashboard/chart-data/utils/get-select-options.util';import { processOneDimensionalResults } from 'src/modules/dashboard/chart-data/utils/process-one-dimensional-results.util';import { sortChartDataIfNeeded } from 'src/modules/dashboard/chart-data/utils/sort-chart-data-if-needed.util';@@ -30,6 +31,7 @@ export const transformToOneDimensionalBarChartData = ({userTimezone,firstDayOfTheWeek,relationLabelResolution,+ i18n,}: {filteredRawResults: GroupByRawResult[];primaryAxisGroupByField: FlatFieldMetadata;@@ -38,6 +40,7 @@ export const transformToOneDimensionalBarChartData = ({userTimezone: string;firstDayOfTheWeek: CalendarStartDay;relationLabelResolution: RelationLabelResolution | undefined;+ i18n: I18n;}): BarChartDataDTO => {const layout = configuration.layout ?? BarChartLayout.VERTICAL;const isHorizontal = layout === BarChartLayout.HORIZONTAL;@@ -119,7 +122,11 @@ export const transformToOneDimensionalBarChartData = ({];const categoryLabel = primaryAxisGroupByField.label;- const valueLabel = `${getAggregateOperationLabel(configuration.aggregateOperation)} of ${aggregateField.label}`;+ const valueLabel = getAggregateValueLabel({+ aggregateOperation: configuration.aggregateOperation,+ aggregateFieldLabel: aggregateField.label,+ i18n,+ });const xAxisLabel = isHorizontal ? valueLabel : categoryLabel;const yAxisLabel = isHorizontal ? categoryLabel : valueLabel;diff --git a/packages/twenty-server/src/modules/dashboard/chart-data/utils/transform-to-one-dimensional-line-chart-data.util.ts b/packages/twenty-server/src/modules/dashboard/chart-data/utils/transform-to-one-dimensional-line-chart-data.util.tsindex 6055aee44fe..c67fcedd04a 100644--- a/packages/twenty-server/src/modules/dashboard/chart-data/utils/transform-to-one-dimensional-line-chart-data.util.ts+++ b/packages/twenty-server/src/modules/dashboard/chart-data/utils/transform-to-one-dimensional-line-chart-data.util.ts@@ -1,3 +1,4 @@+import { type I18n } from '@lingui/core';import { CalendarStartDay } from 'twenty-shared/constants';import { FirstDayOfTheWeek } from 'twenty-shared/types';import { convertCalendarStartDayNonIsoNumberToFirstDayOfTheWeek } from 'twenty-shared/utils';@@ -12,7 +13,7 @@ import { RelationLabelResolution } from 'src/modules/dashboard/chart-data/types/import { applyCumulativeToLineDataPoints } from 'src/modules/dashboard/chart-data/utils/apply-cumulative-to-line-data-points.util';import { applyGapFilling } from 'src/modules/dashboard/chart-data/utils/apply-gap-filling.util';import { buildFormattedToRawLookupDto } from 'src/modules/dashboard/chart-data/utils/build-formatted-to-raw-lookup-dto.util';-import { getAggregateOperationLabel } from 'src/modules/dashboard/chart-data/utils/get-aggregate-operation-label.util';+import { getAggregateValueLabel } from 'src/modules/dashboard/chart-data/utils/get-aggregate-value-label.util';import { getSelectOptions } from 'src/modules/dashboard/chart-data/utils/get-select-options.util';import { processOneDimensionalResults } from 'src/modules/dashboard/chart-data/utils/process-one-dimensional-results.util';import { sortChartDataIfNeeded } from 'src/modules/dashboard/chart-data/utils/sort-chart-data-if-needed.util';@@ -26,6 +27,7 @@ export const transformToOneDimensionalLineChartData = ({firstDayOfTheWeek,seriesIdPrefix,relationLabelResolution,+ i18n,}: {filteredRawResults: GroupByRawResult[];primaryAxisGroupByField: FlatFieldMetadata;@@ -35,6 +37,7 @@ export const transformToOneDimensionalLineChartData = ({firstDayOfTheWeek: CalendarStartDay;seriesIdPrefix: string;relationLabelResolution: RelationLabelResolution | undefined;+ i18n: I18n;}): LineChartDataDTO => {const isDescOrder =configuration.primaryAxisOrderBy === GraphOrderBy.FIELD_DESC;@@ -111,7 +114,11 @@ export const transformToOneDimensionalLineChartData = ({];const xAxisLabel = primaryAxisGroupByField.label;- const yAxisLabel = `${getAggregateOperationLabel(configuration.aggregateOperation)} of ${aggregateField.label}`;+ const yAxisLabel = getAggregateValueLabel({+ aggregateOperation: configuration.aggregateOperation,+ aggregateFieldLabel: aggregateField.label,+ i18n,+ });return {series,diff --git a/packages/twenty-server/src/modules/dashboard/chart-data/utils/transform-to-two-dimensional-bar-chart-data.util.ts b/packages/twenty-server/src/modules/dashboard/chart-data/utils/transform-to-two-dimensional-bar-chart-data.util.tsindex d64978713de..82fc35a485a 100644--- a/packages/twenty-server/src/modules/dashboard/chart-data/utils/transform-to-two-dimensional-bar-chart-data.util.ts+++ b/packages/twenty-server/src/modules/dashboard/chart-data/utils/transform-to-two-dimensional-bar-chart-data.util.ts@@ -1,3 +1,4 @@+import { type I18n } from '@lingui/core';import { isNumber } from '@sniptt/guards';import { CalendarStartDay } from 'twenty-shared/constants';import { FirstDayOfTheWeek } from 'twenty-shared/types';@@ -19,7 +20,7 @@ import { RelationLabelResolution } from 'src/modules/dashboard/chart-data/types/import { applyCumulativeToTwoDimensionalBarData } from 'src/modules/dashboard/chart-data/utils/apply-cumulative-to-two-dimensional-bar-data.util';import { applyGapFilling } from 'src/modules/dashboard/chart-data/utils/apply-gap-filling.util';import { buildFormattedToRawLookupDto } from 'src/modules/dashboard/chart-data/utils/build-formatted-to-raw-lookup-dto.util';-import { getAggregateOperationLabel } from 'src/modules/dashboard/chart-data/utils/get-aggregate-operation-label.util';+import { getAggregateValueLabel } from 'src/modules/dashboard/chart-data/utils/get-aggregate-value-label.util';import { getSelectOptions } from 'src/modules/dashboard/chart-data/utils/get-select-options.util';import { processTwoDimensionalResults } from 'src/modules/dashboard/chart-data/utils/process-two-dimensional-results.util';import { sortChartDataIfNeeded } from 'src/modules/dashboard/chart-data/utils/sort-chart-data-if-needed.util';@@ -35,6 +36,7 @@ export const transformToTwoDimensionalBarChartData = ({firstDayOfTheWeek,primaryRelationLabelResolution,secondaryRelationLabelResolution,+ i18n,}: {filteredRawResults: GroupByRawResult[];primaryAxisGroupByField: FlatFieldMetadata;@@ -45,6 +47,7 @@ export const transformToTwoDimensionalBarChartData = ({firstDayOfTheWeek: CalendarStartDay;primaryRelationLabelResolution: RelationLabelResolution | undefined;secondaryRelationLabelResolution: RelationLabelResolution | undefined;+ i18n: I18n;}): BarChartDataDTO => {const layout = configuration.layout ?? BarChartLayout.VERTICAL;const isHorizontal = layout === BarChartLayout.HORIZONTAL;@@ -194,7 +197,11 @@ export const transformToTwoDimensionalBarChartData = ({}));const categoryLabel = primaryAxisGroupByField.label;- const valueLabel = `${getAggregateOperationLabel(configuration.aggregateOperation)} of ${aggregateField.label}`;+ const valueLabel = getAggregateValueLabel({+ aggregateOperation: configuration.aggregateOperation,+ aggregateFieldLabel: aggregateField.label,+ i18n,+ });const xAxisLabel = isHorizontal ? valueLabel : categoryLabel;const yAxisLabel = isHorizontal ? categoryLabel : valueLabel;diff --git a/packages/twenty-server/src/modules/dashboard/chart-data/utils/transform-to-two-dimensional-line-chart-data.util.ts b/packages/twenty-server/src/modules/dashboard/chart-data/utils/transform-to-two-dimensional-line-chart-data.util.tsindex 3150f34b45f..67e5d8011f3 100644--- a/packages/twenty-server/src/modules/dashboard/chart-data/utils/transform-to-two-dimensional-line-chart-data.util.ts+++ b/packages/twenty-server/src/modules/dashboard/chart-data/utils/transform-to-two-dimensional-line-chart-data.util.ts@@ -1,3 +1,4 @@+import { type I18n } from '@lingui/core';import { CalendarStartDay } from 'twenty-shared/constants';import { FirstDayOfTheWeek } from 'twenty-shared/types';import {@@ -18,7 +19,7 @@ import { RelationLabelResolution } from 'src/modules/dashboard/chart-data/types/import { applyCumulativeToLineDataPoints } from 'src/modules/dashboard/chart-data/utils/apply-cumulative-to-line-data-points.util';import { applyGapFilling } from 'src/modules/dashboard/chart-data/utils/apply-gap-filling.util';import { buildFormattedToRawLookupDto } from 'src/modules/dashboard/chart-data/utils/build-formatted-to-raw-lookup-dto.util';-import { getAggregateOperationLabel } from 'src/modules/dashboard/chart-data/utils/get-aggregate-operation-label.util';+import { getAggregateValueLabel } from 'src/modules/dashboard/chart-data/utils/get-aggregate-value-label.util';import { getSelectOptions } from 'src/modules/dashboard/chart-data/utils/get-select-options.util';import { processTwoDimensionalResults } from 'src/modules/dashboard/chart-data/utils/process-two-dimensional-results.util';import { sortChartDataIfNeeded } from 'src/modules/dashboard/chart-data/utils/sort-chart-data-if-needed.util';@@ -35,6 +36,7 @@ export const transformToTwoDimensionalLineChartData = ({seriesIdPrefix,primaryRelationLabelResolution,secondaryRelationLabelResolution,+ i18n,}: {filteredRawResults: GroupByRawResult[];primaryAxisGroupByField: FlatFieldMetadata;@@ -46,6 +48,7 @@ export const transformToTwoDimensionalLineChartData = ({seriesIdPrefix: string;primaryRelationLabelResolution: RelationLabelResolution | undefined;secondaryRelationLabelResolution: RelationLabelResolution | undefined;+ i18n: I18n;}): LineChartDataDTO => {const isStacked = configuration.isStacked ?? false;@@ -189,7 +192,11 @@ export const transformToTwoDimensionalLineChartData = ({});const xAxisLabel = primaryAxisGroupByField.label;- const yAxisLabel = `${getAggregateOperationLabel(configuration.aggregateOperation)} of ${aggregateField.label}`;+ const yAxisLabel = getAggregateValueLabel({+ aggregateOperation: configuration.aggregateOperation,+ aggregateFieldLabel: aggregateField.label,+ i18n,+ });const hasTooManySeries = seriesIds.length > maxSeries;const hasTooManyDataPoints =diff --git a/packages/twenty-server/src/modules/dashboard/services/dashboard-to-page-layout-sync.service.ts b/packages/twenty-server/src/modules/dashboard/services/dashboard-to-page-layout-sync.service.tsindex ad92f0cbcc9..9825674de03 100644--- a/packages/twenty-server/src/modules/dashboard/services/dashboard-to-page-layout-sync.service.ts+++ b/packages/twenty-server/src/modules/dashboard/services/dashboard-to-page-layout-sync.service.ts@@ -1,5 +1,6 @@import { Injectable } from '@nestjs/common';+import { msg } from '@lingui/core/macro';import { isDefined } from 'twenty-shared/utils';import { In } from 'typeorm';@@ -8,6 +9,7 @@ import { PageLayoutType } from 'twenty-shared/types';import { PageLayoutService } from 'src/engine/metadata-modules/page-layout/services/page-layout.service';import { WorkspaceOrmManager } from 'src/engine/twenty-orm/workspace-orm.manager';import { buildSystemAuthContext } from 'src/engine/twenty-orm/utils/build-system-auth-context.util';+import { i18nLabel } from 'src/engine/workspace-manager/twenty-standard-application/utils/i18n-label.util';import type { DashboardWorkspaceEntity } from 'src/modules/dashboard/standard-objects/dashboard.workspace-entity';@Injectable()@@ -34,7 +36,9 @@ export class DashboardToPageLayoutSyncService {await this.pageLayoutTabService.create({createPageLayoutTabInput: {- title: 'Tab 1',+ title: i18nLabel(+ msg({ message: `Tab 1`, context: 'pageLayoutTab.title' }),+ ),pageLayoutId: pageLayout.id,},workspaceId,diff --git a/packages/twenty-server/src/modules/messaging/message-outbound-manager/drivers/email-group/services/email-group-message-outbound.service.ts b/packages/twenty-server/src/modules/messaging/message-outbound-manager/drivers/email-group/services/email-group-message-outbound.service.tsindex 585842ce858..3a9602a65c8 100644--- a/packages/twenty-server/src/modules/messaging/message-outbound-manager/drivers/email-group/services/email-group-message-outbound.service.ts+++ b/packages/twenty-server/src/modules/messaging/message-outbound-manager/drivers/email-group/services/email-group-message-outbound.service.ts@@ -1,5 +1,6 @@import { Injectable } from '@nestjs/common';+import { msg } from '@lingui/core/macro';import { isNonEmptyString } from '@sniptt/guards';import { isDefined } from 'twenty-shared/utils';import { v4 } from 'uuid';@@ -66,6 +67,9 @@ export class EmailGroupMessageOutboundService implements MessageOutboundDriver {throw new MessageChannelException(`Cannot send from ${connectedAccount.handle}: domain ${emailingDomain.domain} is not verified for outbound (status: ${emailingDomain.status}).`,MessageChannelExceptionCode.EMAIL_GROUP_NOT_CONFIGURED,+ {+ userFriendlyMessage: msg`Cannot send from ${connectedAccount.handle}: domain ${emailingDomain.domain} is not verified for outbound.`,+ },);}@@ -133,6 +137,9 @@ export class EmailGroupMessageOutboundService implements MessageOutboundDriver {throw new MessageChannelException('Email handle channels do not support drafts.',MessageChannelExceptionCode.INVALID_MESSAGE_CHANNEL_INPUT,+ {+ userFriendlyMessage: msg`Email handle channels do not support drafts.`,+ },);}@@ -140,6 +147,9 @@ export class EmailGroupMessageOutboundService implements MessageOutboundDriver {throw new MessageChannelException('Email handle channels do not support drafts.',MessageChannelExceptionCode.INVALID_MESSAGE_CHANNEL_INPUT,+ {+ userFriendlyMessage: msg`Email handle channels do not support drafts.`,+ },);}@@ -152,6 +162,9 @@ export class EmailGroupMessageOutboundService implements MessageOutboundDriver {throw new MessageChannelException(`Email group ${connectedAccount.handle} has no domain.`,MessageChannelExceptionCode.EMAIL_GROUP_NOT_CONFIGURED,+ {+ userFriendlyMessage: msg`Email group ${connectedAccount.handle} has no domain.`,+ },);}@@ -166,6 +179,9 @@ export class EmailGroupMessageOutboundService implements MessageOutboundDriver {throw new MessageChannelException(`No outbound domain configured for ${handleDomain}. Verify it under Outbound Domains to send from ${connectedAccount.handle}.`,MessageChannelExceptionCode.EMAIL_GROUP_NOT_CONFIGURED,+ {+ userFriendlyMessage: msg`No outbound domain configured for ${handleDomain}. Verify it under Outbound Domains to send from ${connectedAccount.handle}.`,+ },);}@@ -203,6 +219,9 @@ export class EmailGroupMessageOutboundService implements MessageOutboundDriver {throw new ThrottlerException(`Email group send limit reached: ${EMAIL_GROUP_SEND_THROTTLE.maxRecipients} recipients per day.`,ThrottlerExceptionCode.LIMIT_REACHED,+ {+ userFriendlyMessage: msg`Email group send limit reached: ${EMAIL_GROUP_SEND_THROTTLE.maxRecipients} recipients per day.`,+ },);}diff --git a/packages/twenty-server/src/modules/messaging/message-outbound-manager/resolvers/__tests__/send-email.resolver.spec.ts b/packages/twenty-server/src/modules/messaging/message-outbound-manager/resolvers/__tests__/send-email.resolver.spec.tsnew file mode 100644index 00000000000..ee4aca11b2d--- /dev/null+++ b/packages/twenty-server/src/modules/messaging/message-outbound-manager/resolvers/__tests__/send-email.resolver.spec.ts@@ -0,0 +1,98 @@+import { type MessageDescriptor } from '@lingui/core';++import { type I18nContext } from 'src/engine/core-modules/i18n/types/i18n-context.type';+import {+ EmailToolException,+ EmailToolExceptionCode,+} from 'src/engine/core-modules/tool/tools/email-tool/exceptions/email-tool.exception';+import { type WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';+import { type SendEmailInput } from 'src/modules/messaging/message-outbound-manager/dtos/send-email.input';+import { SendEmailResolver } from 'src/modules/messaging/message-outbound-manager/resolvers/send-email.resolver';++const WORKSPACE_ID = '33333333-3333-4333-8333-333333333333';+const USER_WORKSPACE_ID = '66666666-6666-4666-8666-666666666666';++describe('SendEmailResolver errors', () => {+ const workspace = { id: WORKSPACE_ID } as WorkspaceEntity;+ const context: I18nContext = { req: { locale: 'fr-FR' } };+ const input = {+ connectedAccountId: 'connected-account-id',+ to: '[email protected]',+ subject: 'Subject',+ body: '<p>body</p>',+ } as SendEmailInput;++ const buildResolver = (composeEmail: jest.Mock) => {+ const i18nService = {+ getI18nInstance: jest.fn((locale: string) => ({+ _: (descriptor: MessageDescriptor) => `${locale}:${descriptor.message}`,+ })),+ };++ const resolver = new SendEmailResolver(+ { verifyUsableByCaller: jest.fn() } as never,+ { composeEmail } as never,+ {} as never,+ {} as never,+ i18nService as never,+ );++ return { resolver, i18nService };+ };++ it('translates a composition failure for the request locale', async () => {+ const { resolver } = buildResolver(+ jest.fn().mockResolvedValue({+ success: false,+ error: { id: 'no-recipients', message: 'No recipients specified' },+ }),+ );++ const result = await resolver.sendEmail(+ input,+ workspace,+ USER_WORKSPACE_ID,+ context,+ );++ expect(result).toEqual({+ success: false,+ error: 'fr-FR:No recipients specified',+ });+ });++ it('returns the translated user-friendly message of a custom exception', async () => {+ const exception = new EmailToolException(+ 'No connected account in this workspace can send email',+ EmailToolExceptionCode.NO_EMAIL_CAPABLE_CONNECTED_ACCOUNT,+ );+ const { resolver } = buildResolver(jest.fn().mockRejectedValue(exception));++ const result = await resolver.sendEmail(+ input,+ workspace,+ USER_WORKSPACE_ID,+ context,+ );++ expect(result).toEqual({+ success: false,+ error: `fr-FR:${exception.userFriendlyMessage.message}`,+ });+ });++ it('returns no error text for an unexpected error so the client shows its fallback', async () => {+ const { resolver } = buildResolver(+ jest.fn().mockRejectedValue(new Error('connect ECONNREFUSED 10.0.0.1')),+ );++ const result = await resolver.sendEmail(+ input,+ workspace,+ USER_WORKSPACE_ID,+ context,+ );++ expect(result).toStrictEqual({ success: false });+ });+});diff --git a/packages/twenty-server/src/modules/messaging/message-outbound-manager/resolvers/send-email.resolver.ts b/packages/twenty-server/src/modules/messaging/message-outbound-manager/resolvers/send-email.resolver.tsindex 17cb97309bf..e98a638d438 100644--- a/packages/twenty-server/src/modules/messaging/message-outbound-manager/resolvers/send-email.resolver.ts+++ b/packages/twenty-server/src/modules/messaging/message-outbound-manager/resolvers/send-email.resolver.ts@@ -6,7 +6,7 @@ import {UseGuards,UsePipes,} from '@nestjs/common';-import { Args, Mutation } from '@nestjs/graphql';+import { Args, Context, Mutation } from '@nestjs/graphql';import { PermissionFlagType } from 'twenty-shared/constants';@@ -14,6 +14,8 @@ import { MetadataResolver } from 'src/engine/api/graphql/graphql-config/decoratoimport { AuthGraphqlApiExceptionFilter } from 'src/engine/core-modules/auth/filters/auth-graphql-api-exception.filter';import { FileEmailAttachmentService } from 'src/engine/core-modules/file/file-email-attachment/services/file-email-attachment.service';import { ResolverValidationPipe } from 'src/engine/core-modules/graphql/pipes/resolver-validation.pipe';+import { I18nService } from 'src/engine/core-modules/i18n/i18n.service';+import { type I18nContext } from 'src/engine/core-modules/i18n/types/i18n-context.type';import { WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';import { EmailComposerService } from 'src/engine/core-modules/tool/tools/email-tool/email-composer.service';import { AuthUserWorkspaceId } from 'src/engine/decorators/auth/auth-user-workspace-id.decorator';@@ -24,6 +26,7 @@ import { ConnectedAccountMetadataService } from 'src/engine/metadata-modules/conimport { SendEmailOutputDTO } from 'src/modules/messaging/message-outbound-manager/dtos/send-email-output.dto';import { SendEmailInput } from 'src/modules/messaging/message-outbound-manager/dtos/send-email.input';import { SendEmailService } from 'src/modules/messaging/message-outbound-manager/services/send-email.service';+import { CustomException } from 'src/utils/custom-exception';import { isDefined } from 'twenty-shared/utils';import { isNonEmptyString } from '@sniptt/guards';@@ -52,6 +55,7 @@ export class SendEmailResolver {private readonly emailComposerService: EmailComposerService,private readonly fileEmailAttachmentService: FileEmailAttachmentService,private readonly sendEmailService: SendEmailService,+ private readonly i18nService: I18nService,) {}@Mutation(() => SendEmailOutputDTO)@@ -59,6 +63,7 @@ export class SendEmailResolver {@Args('input') input: SendEmailInput,@AuthWorkspace() workspace: WorkspaceEntity,@AuthUserWorkspaceId() userWorkspaceId: string,+ @Context() context: I18nContext,): Promise<SendEmailOutputDTO> {try {await this.connectedAccountMetadataService.verifyUsableByCaller({@@ -88,7 +93,9 @@ export class SendEmailResolver {if (!result.success) {return {success: false,- error: result.output.error ?? result.output.message,+ error: this.i18nService+ .getI18nInstance(context.req.locale)+ ._(result.error),};}@@ -155,10 +162,16 @@ export class SendEmailResolver {this.logger.error(`Failed to send email: ${error}`);- return {- success: false,- error: error instanceof Error ? error.message : 'Failed to send email',- };+ if (error instanceof CustomException) {+ return {+ success: false,+ error: this.i18nService+ .getI18nInstance(context.req.locale)+ ._(error.userFriendlyMessage),+ };+ }++ return { success: false };}}}diff --git a/packages/twenty-server/test/integration/google/messaging/outbound.integration-spec.ts b/packages/twenty-server/test/integration/google/messaging/outbound.integration-spec.tsindex d08e1e07ac7..424b1747041 100644--- a/packages/twenty-server/test/integration/google/messaging/outbound.integration-spec.ts+++ b/packages/twenty-server/test/integration/google/messaging/outbound.integration-spec.ts@@ -279,9 +279,7 @@ describe('Gmail outbound messaging and calendar creation (integration)', () => {expect(result).toMatchObject({success: false,- error: expect.stringContaining(- 'is not the connected account handle nor one of its verified aliases',- ),+ error: 'You cannot send from this address.',});expect(google.sentMessages).toHaveLength(sentMessageCount);}, 60000);diff --git a/packages/twenty-server/test/integration/imap/suites/imap-smtp-outbound.integration-spec.ts b/packages/twenty-server/test/integration/imap/suites/imap-smtp-outbound.integration-spec.tsindex 6d3273feaae..66b5640c031 100644--- a/packages/twenty-server/test/integration/imap/suites/imap-smtp-outbound.integration-spec.ts+++ b/packages/twenty-server/test/integration/imap/suites/imap-smtp-outbound.integration-spec.ts@@ -151,9 +151,7 @@ describe('IMAP/SMTP outbound messaging (integration)', () => {expect(result).toMatchObject({success: false,- error: expect.stringContaining(- 'is not the connected account handle nor one of its verified aliases',- ),+ error: 'You cannot send from this address.',});expect(await findRecordNodesByFilter<{ id: string }>(diff --git a/packages/twenty-server/test/integration/microsoft/messaging/outbound.integration-spec.ts b/packages/twenty-server/test/integration/microsoft/messaging/outbound.integration-spec.tsindex 82bfe384acf..338bf43c559 100644--- a/packages/twenty-server/test/integration/microsoft/messaging/outbound.integration-spec.ts+++ b/packages/twenty-server/test/integration/microsoft/messaging/outbound.integration-spec.ts@@ -291,9 +291,7 @@ describe('Microsoft outbound messaging and calendar creation (integration)', ()expect(result).toMatchObject({success: false,- error: expect.stringContaining(- 'is not the connected account handle nor one of its verified aliases',- ),+ error: 'You cannot send from this address.',});expect(microsoft.createdMessages).toEqual([]);}, 60000);diff --git a/packages/twenty-shared/src/i18n/translatable-properties-by-metadata-name.ts b/packages/twenty-shared/src/i18n/translatable-properties-by-metadata-name.tsindex 325db385999..d7e76e7f60d 100644--- a/packages/twenty-shared/src/i18n/translatable-properties-by-metadata-name.ts+++ b/packages/twenty-shared/src/i18n/translatable-properties-by-metadata-name.ts@@ -13,6 +13,7 @@ export const TRANSLATABLE_PROPERTIES_BY_METADATA_NAME = {navigationMenuItem: ['name'],timelineActivityType: ['label'],settingsMenuItem: ['title'],+ skill: ['label', 'description'],} as const satisfies Partial<Record<AllMetadataName, readonly string[]>>;export type TranslatableMetadataName =