4

I made a custom entity (ty drupal console). but i would also like to make this entity translatable. I enabled all 4 multilingual core modules but i don't see the "translate" tab in my entity nor can i enable translation form the "admin/config/regional/content-language" page (it says N/A), but i can show the language selector which as no real effect.

is it possible to translate custom entity, if so, how? what am i missing?

2 Answers 2

10

You need the translatable = TRUE line in your @ContentEntityType annotation. You also need the setTranslatable(TRUE) line in your BaseFieldDefinition::create fields.

5
  • 1
    thanks a bunch, i looked everywhere for this information. you are my hero today :) Commented Jul 19, 2016 at 14:39
  • 1
    Do you not also need to specify the data_table in the annotation?
    – joachim
    Commented Mar 11, 2018 at 22:01
  • 1
    @RainderFeike and then Translate tab should be available out of the box? For me with above steps not. I have translatable title field + annotation
    – Codium
    Commented Jul 3, 2018 at 13:36
  • 2
    Do you have the core modules enabled? Content Translation and Language? Commented Jul 3, 2018 at 14:07
  • 2
    @RainerFake I've missed configuration at admin/config/regional/content-language from description, thanks
    – Codium
    Commented Jul 3, 2018 at 19:10
0

Refer this link for translating custom content entities - https://www.drupal.org/docs/develop/translating-custom-entities

Make sure to enable translation support for your custom entity under 'Content Language' configuration.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.