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:
@ -1,5 +1,12 @@
|
||||
import { UseGuards } from '@nestjs/common';
|
||||
import { Args, Mutation, Resolver } from '@nestjs/graphql';
|
||||
import {
|
||||
Args,
|
||||
Context,
|
||||
Mutation,
|
||||
Parent,
|
||||
ResolveField,
|
||||
Resolver,
|
||||
} from '@nestjs/graphql';
|
||||
|
||||
import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity';
|
||||
import { AuthWorkspace } from 'src/engine/decorators/auth/auth-workspace.decorator';
|
||||
@ -22,6 +29,30 @@ export class ObjectMetadataResolver {
|
||||
private readonly beforeUpdateOneObject: BeforeUpdateOneObject<UpdateObjectPayload>,
|
||||
) {}
|
||||
|
||||
@ResolveField(() => String, { nullable: true })
|
||||
async labelPlural(
|
||||
@Parent() objectMetadata: ObjectMetadataDTO,
|
||||
@Context() context,
|
||||
): Promise<string> {
|
||||
return this.objectMetadataService.resolveTranslatableString(
|
||||
objectMetadata,
|
||||
'labelPlural',
|
||||
context.req.headers['x-locale'],
|
||||
);
|
||||
}
|
||||
|
||||
@ResolveField(() => String, { nullable: true })
|
||||
async labelSingular(
|
||||
@Parent() objectMetadata: ObjectMetadataDTO,
|
||||
@Context() context,
|
||||
): Promise<string> {
|
||||
return this.objectMetadataService.resolveTranslatableString(
|
||||
objectMetadata,
|
||||
'labelSingular',
|
||||
context.req.headers['x-locale'],
|
||||
);
|
||||
}
|
||||
|
||||
@Mutation(() => ObjectMetadataDTO)
|
||||
async deleteOneObject(
|
||||
@Args('input') input: DeleteOneObjectInput,
|
||||
|
||||
Reference in New Issue
Block a user