Add server translation (#9847)

First proof of concept for server-side translation.

The goal was to translate one metadata item:

<img width="939" alt="Screenshot 2025-01-26 at 08 18 41"
src="https://github.com/user-attachments/assets/e42a3f7f-f5e3-4ee7-9be5-272a2adccb23"
/>
This commit is contained in:
Félix Malfait
2025-01-27 21:07:49 +01:00
committed by GitHub
parent 2a911b4305
commit 549c3faf71
35 changed files with 412 additions and 131 deletions

View File

@ -150,5 +150,5 @@ export class CustomWorkspaceEntity extends BaseWorkspaceEntity {
@WorkspaceIsNullable()
@WorkspaceIsSystem()
@WorkspaceFieldIndex({ indexType: IndexType.GIN })
[SEARCH_VECTOR_FIELD.name]: any;
searchVector: any;
}

View File

@ -1,3 +1,5 @@
import { MessageDescriptor } from '@lingui/core';
import { metadataArgsStorage } from 'src/engine/twenty-orm/storage/metadata-args.storage';
import { BASE_OBJECT_STANDARD_FIELD_IDS } from 'src/engine/workspace-manager/workspace-sync-metadata/constants/standard-field-ids';
import { convertClassNameToObjectMetadataName } from 'src/engine/workspace-manager/workspace-sync-metadata/utils/convert-class-to-object-metadata-name.util';
@ -6,9 +8,9 @@ import { TypedReflect } from 'src/utils/typed-reflect';
interface WorkspaceEntityOptions {
standardId: string;
namePlural: string;
labelSingular: string;
labelPlural: string;
description?: string;
labelSingular: MessageDescriptor | string; // Todo: remove string when translations are added
labelPlural: MessageDescriptor | string; // Todo: remove string when translations are added
description?: MessageDescriptor | string; // Todo: remove string when translations are added
icon?: string;
shortcut?: string;
labelIdentifierStandardId?: string;
@ -38,9 +40,18 @@ export function WorkspaceEntity(
standardId: options.standardId,
nameSingular: objectName,
namePlural: options.namePlural,
labelSingular: options.labelSingular,
labelPlural: options.labelPlural,
description: options.description,
labelSingular:
typeof options.labelSingular === 'string'
? options.labelSingular
: (options.labelSingular?.message ?? ''),
labelPlural:
typeof options.labelPlural === 'string'
? options.labelPlural
: (options.labelPlural?.message ?? ''),
description:
typeof options.description === 'string'
? options.description
: (options.description?.message ?? ''),
labelIdentifierStandardId:
options.labelIdentifierStandardId ?? BASE_OBJECT_STANDARD_FIELD_IDS.id,
imageIdentifierStandardId: options.imageIdentifierStandardId ?? null,