Add field description+label translations (#9899)

Add translations for field descriptions
This commit is contained in:
Félix Malfait
2025-01-28 23:20:28 +01:00
committed by GitHub
parent b1219ff107
commit f74bb5a60b
47 changed files with 4210 additions and 720 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,7 @@
import { msg } from '@lingui/core/macro';
export const SEARCH_VECTOR_FIELD = {
name: 'searchVector',
label: 'Search vector',
description: 'Field used for full-text search',
label: msg`Search vector`,
description: msg`Field used for full-text search`,
} as const;

View File

@ -56,8 +56,8 @@ export class SearchService {
isSystem: true,
type: FieldMetadataType.TS_VECTOR,
name: SEARCH_VECTOR_FIELD.name,
label: SEARCH_VECTOR_FIELD.label,
description: SEARCH_VECTOR_FIELD.description,
label: SEARCH_VECTOR_FIELD.label.message ?? '',
description: SEARCH_VECTOR_FIELD.description.message ?? '',
isNullable: true,
});

View File

@ -1,3 +1,4 @@
import { msg } from '@lingui/core/macro';
import { FieldMetadataType } from 'twenty-shared';
import { WorkspaceField } from 'src/engine/twenty-orm/decorators/workspace-field.decorator';
@ -10,8 +11,8 @@ export abstract class BaseWorkspaceEntity {
@WorkspaceField({
standardId: BASE_OBJECT_STANDARD_FIELD_IDS.id,
type: FieldMetadataType.UUID,
label: 'Id',
description: 'Id',
label: msg`Id`,
description: msg`Id`,
defaultValue: 'uuid',
icon: 'Icon123',
})
@ -22,8 +23,8 @@ export abstract class BaseWorkspaceEntity {
@WorkspaceField({
standardId: BASE_OBJECT_STANDARD_FIELD_IDS.createdAt,
type: FieldMetadataType.DATE_TIME,
label: 'Creation date',
description: 'Creation date',
label: msg`Creation date`,
description: msg`Creation date`,
icon: 'IconCalendar',
defaultValue: 'now',
settings: {
@ -35,8 +36,8 @@ export abstract class BaseWorkspaceEntity {
@WorkspaceField({
standardId: BASE_OBJECT_STANDARD_FIELD_IDS.updatedAt,
type: FieldMetadataType.DATE_TIME,
label: 'Last update',
description: 'Last time the record was changed',
label: msg`Last update`,
description: msg`Last time the record was changed`,
icon: 'IconCalendarClock',
defaultValue: 'now',
settings: {
@ -48,8 +49,8 @@ export abstract class BaseWorkspaceEntity {
@WorkspaceField({
standardId: BASE_OBJECT_STANDARD_FIELD_IDS.deletedAt,
type: FieldMetadataType.DATE_TIME,
label: 'Deleted at',
description: 'Date when the record was deleted',
label: msg`Deleted at`,
description: msg`Date when the record was deleted`,
icon: 'IconCalendarMinus',
settings: {
displayAsRelativeDate: true,

View File

@ -1,3 +1,4 @@
import { msg } from '@lingui/core/macro';
import { FieldMetadataType } from 'twenty-shared';
import { SEARCH_VECTOR_FIELD } from 'src/engine/metadata-modules/constants/search-vector-field.constants';
@ -39,8 +40,8 @@ export const SEARCH_FIELDS_FOR_CUSTOM_OBJECT: FieldTypeAndNameMetadata[] = [
export class CustomWorkspaceEntity extends BaseWorkspaceEntity {
@WorkspaceField({
standardId: CUSTOM_OBJECT_STANDARD_FIELD_IDS.name,
label: 'Name',
description: 'Name',
label: msg`Name`,
description: msg`Name`,
type: FieldMetadataType.TEXT,
icon: 'IconAbc',
})
@ -48,8 +49,8 @@ export class CustomWorkspaceEntity extends BaseWorkspaceEntity {
@WorkspaceField({
standardId: CUSTOM_OBJECT_STANDARD_FIELD_IDS.position,
label: 'Position',
description: 'Position',
label: msg`Position`,
description: msg`Position`,
type: FieldMetadataType.POSITION,
icon: 'IconHierarchy2',
defaultValue: 0,
@ -60,9 +61,9 @@ export class CustomWorkspaceEntity extends BaseWorkspaceEntity {
@WorkspaceField({
standardId: CUSTOM_OBJECT_STANDARD_FIELD_IDS.createdBy,
type: FieldMetadataType.ACTOR,
label: 'Created by',
label: msg`Created by`,
icon: 'IconCreativeCommonsSa',
description: 'The creator of the record',
description: msg`The creator of the record`,
defaultValue: {
source: `'${FieldActorSource.MANUAL}'`,
name: "''",
@ -72,10 +73,13 @@ export class CustomWorkspaceEntity extends BaseWorkspaceEntity {
@WorkspaceRelation({
standardId: CUSTOM_OBJECT_STANDARD_FIELD_IDS.noteTargets,
label: 'Notes',
label: msg`Notes`,
type: RelationMetadataType.ONE_TO_MANY,
description: (objectMetadata) =>
`Notes tied to the ${objectMetadata.labelSingular}`,
description: (objectMetadata) => {
const label = objectMetadata.labelSingular;
return msg`Notes tied to the ${label}`;
},
icon: 'IconNotes',
inverseSideTarget: () => NoteTargetWorkspaceEntity,
onDelete: RelationOnDeleteAction.CASCADE,
@ -85,10 +89,13 @@ export class CustomWorkspaceEntity extends BaseWorkspaceEntity {
@WorkspaceRelation({
standardId: CUSTOM_OBJECT_STANDARD_FIELD_IDS.taskTargets,
label: 'Tasks',
label: msg`Tasks`,
type: RelationMetadataType.ONE_TO_MANY,
description: (objectMetadata) =>
`Tasks tied to the ${objectMetadata.labelSingular}`,
description: (objectMetadata) => {
const label = objectMetadata.labelSingular;
return msg`Tasks tied to the ${label}`;
},
icon: 'IconCheckbox',
inverseSideTarget: () => TaskTargetWorkspaceEntity,
onDelete: RelationOnDeleteAction.CASCADE,
@ -98,10 +105,13 @@ export class CustomWorkspaceEntity extends BaseWorkspaceEntity {
@WorkspaceRelation({
standardId: CUSTOM_OBJECT_STANDARD_FIELD_IDS.favorites,
label: 'Favorites',
label: msg`Favorites`,
type: RelationMetadataType.ONE_TO_MANY,
description: (objectMetadata) =>
`Favorites tied to the ${objectMetadata.labelSingular}`,
description: (objectMetadata) => {
const label = objectMetadata.labelSingular;
return msg`Favorites tied to the ${label}`;
},
icon: 'IconHeart',
inverseSideTarget: () => FavoriteWorkspaceEntity,
onDelete: RelationOnDeleteAction.CASCADE,
@ -112,10 +122,13 @@ export class CustomWorkspaceEntity extends BaseWorkspaceEntity {
@WorkspaceRelation({
standardId: CUSTOM_OBJECT_STANDARD_FIELD_IDS.attachments,
label: 'Attachments',
label: msg`Attachments`,
type: RelationMetadataType.ONE_TO_MANY,
description: (objectMetadata) =>
`Attachments tied to the ${objectMetadata.labelSingular}`,
description: (objectMetadata) => {
const label = objectMetadata.labelSingular;
return msg`Attachments tied to the ${label}`;
},
icon: 'IconFileImport',
inverseSideTarget: () => AttachmentWorkspaceEntity,
onDelete: RelationOnDeleteAction.CASCADE,
@ -125,10 +138,13 @@ export class CustomWorkspaceEntity extends BaseWorkspaceEntity {
@WorkspaceRelation({
standardId: CUSTOM_OBJECT_STANDARD_FIELD_IDS.timelineActivities,
label: 'Timeline Activities',
label: msg`Timeline Activities`,
type: RelationMetadataType.ONE_TO_MANY,
description: (objectMetadata) =>
`Timeline Activities tied to the ${objectMetadata.labelSingular}`,
description: (objectMetadata) => {
const label = objectMetadata.labelSingular;
return msg`Timeline Activities tied to the ${label}`;
},
icon: 'IconIconTimelineEvent',
inverseSideTarget: () => TimelineActivityWorkspaceEntity,
onDelete: RelationOnDeleteAction.CASCADE,

View File

@ -16,13 +16,11 @@ export interface WorkspaceFieldOptions<
standardId: string;
type: T;
label:
| string
| MessageDescriptor
| ((objectMetadata: ObjectMetadataEntity) => string);
| ((objectMetadata: ObjectMetadataEntity) => MessageDescriptor);
description?:
| string
| MessageDescriptor
| ((objectMetadata: ObjectMetadataEntity) => string);
| ((objectMetadata: ObjectMetadataEntity) => MessageDescriptor);
icon?: string;
defaultValue?: FieldMetadataDefaultValue<T>;
options?: FieldMetadataOptions<T>;
@ -80,14 +78,24 @@ export function WorkspaceField<T extends FieldMetadataType>(
standardId: options.standardId,
name: propertyKey.toString(),
label:
typeof options.label === 'object'
? (options.label.message ?? '')
: options.label,
typeof options.label === 'function'
? (objectMetadata: ObjectMetadataEntity) =>
(
options.label as (
obj: ObjectMetadataEntity,
) => MessageDescriptor
)(objectMetadata).message ?? ''
: (options.label.message ?? ''),
type: options.type,
description:
typeof options.description === 'object'
? (options.description.message ?? '')
: options.description,
typeof options.description === 'function'
? (objectMetadata: ObjectMetadataEntity) =>
(
options.description as (
obj: ObjectMetadataEntity,
) => MessageDescriptor
)(objectMetadata).message ?? ''
: (options.description?.message ?? ''),
icon: options.icon,
defaultValue,
options: options.options,

View File

@ -1,17 +1,22 @@
import { MessageDescriptor } from '@lingui/core';
import { ObjectType } from 'typeorm';
import { ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
import {
RelationMetadataType,
RelationOnDeleteAction,
} from 'src/engine/metadata-modules/relation-metadata/relation-metadata.entity';
import { metadataArgsStorage } from 'src/engine/twenty-orm/storage/metadata-args.storage';
import { TypedReflect } from 'src/utils/typed-reflect';
import { ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
interface WorkspaceRelationOptions<TClass> {
standardId: string;
label: string | ((objectMetadata: ObjectMetadataEntity) => string);
description?: string | ((objectMetadata: ObjectMetadataEntity) => string);
label:
| MessageDescriptor
| ((objectMetadata: ObjectMetadataEntity) => MessageDescriptor);
description?:
| MessageDescriptor
| ((objectMetadata: ObjectMetadataEntity) => MessageDescriptor);
icon?: string;
type: RelationMetadataType;
inverseSideTarget: () => ObjectType<TClass>;
@ -51,9 +56,25 @@ export function WorkspaceRelation<TClass extends object>(
target: object.constructor,
standardId: options.standardId,
name: propertyKey.toString(),
label: options.label,
label:
typeof options.label === 'function'
? (objectMetadata: ObjectMetadataEntity) =>
(
options.label as (
obj: ObjectMetadataEntity,
) => MessageDescriptor
)(objectMetadata).message ?? ''
: (options.label.message ?? ''),
type: options.type,
description: options.description,
description:
typeof options.description === 'function'
? (objectMetadata: ObjectMetadataEntity) =>
(
options.description as (
obj: ObjectMetadataEntity,
) => MessageDescriptor
)(objectMetadata).message ?? ''
: (options.description?.message ?? ''),
icon: options.icon,
inverseSideTarget: options.inverseSideTarget,
inverseSideFieldKey: options.inverseSideFieldKey as string | undefined,