Skip to content

How do you define translatable entities? #974

Answered by michaelbromley
skid asked this question in Q&A
Discussion options

You must be logged in to vote

Yes there are no docs on this, so I'll write a rough guide here and add some docs in future:

(using the Product entity as an example)

  1. Any fields that should be translated are given the type LocaleString, and are not decorated with @Column() as they are not actually stored in the DB, but are populated at runtime:
    name: LocaleString;
    
    slug: LocaleString;
    
    description: LocaleString;
  2. The entity should implement the Translatable interface, which means it will have a property translations which looks like this :
     @OneToMany(type => ProductTranslation, translation => translation.base, { eager: true })
     translations: Array<Translation<Product>>;
  3. A corresponding <entityName>Translation entity m…

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@michaelbromley
Comment options

@skid
Comment options

@michaelbromley
Comment options

@skid
Comment options

@michaelbromley
Comment options

Answer selected by skid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants