typeorm-translatable
Version:
Translation classes, utils and decorators for i18n in TypeORM
25 lines (24 loc) • 1.28 kB
TypeScript
import { ObjectLiteral } from 'typeorm';
import { TranslatableEntity } from './TranslatableEntity';
import { ITranslationEntity } from './TranslationEntity';
import { ITranslationOptions, Translation } from './types';
/**
* Get translatable fields from translatable entity
*/
export declare const getTranslatableFields: <T>(entity: TranslatableEntity<T>) => Set<string> | undefined;
export declare const isTranslation: (translation: unknown) => translation is Translation<unknown>;
/**
* Check if an entity is translatable or not
* @param entity Entity to check
* @returns True if entity is translatable, false otherwise
*/
export declare const isTranslatable: (entity: TranslatableEntity<ObjectLiteral>) => entity is TranslatableEntity<ITranslationEntity<ObjectLiteral>>;
/**
* Translate the entity to the given locale
* @param entity The entity to translate
* @param locale The locale to translate
* @param options Translation options
* @throws {NotTranslatableException} If entity is not translatable
* @returns Translated entity
*/
export declare const translateEntity: <T extends TranslatableEntity<ITranslationEntity<ObjectLiteral>>>(entity: T, locale?: string | undefined, { shouldDelete, shouldMutate, }?: ITranslationOptions) => T;