Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
Make Pet entity translatable.
Proposed resolution
Add translatable TRUE in the entity definition.
Add langcode as entity key.
Set translatable to TRUE for the fields that should be translatable.
Comment | File | Size | Author |
---|---|---|---|
#12 | make_pet_translatable-2747525-12.patch | 4.14 KB | adinac |
#11 | make_pet_translatable-2747525-11.patch | 3.18 KB | adinac |
#3 | make_pet_translatable-2747525-3.patch | 2.94 KB | bogdan.racz |
Comments
Comment #2
bogdan.racz CreditAttribution: bogdan.racz at Dream Production commentedAttached a patch.
Please review.
Comment #3
bogdan.racz CreditAttribution: bogdan.racz at Dream Production commentedForgot to leave the add form in the annotation.
Attached a complete patch.
Comment #4
ayalon CreditAttribution: ayalon at Liip commentedHere is my own attempt to make PETs translatable.
After applying the patch you need to run "drush entup". Then you can go to "/admin/config/regional/content-language" and enable "Translation" for the Pet Entity.
Comment #5
andreasderijckeTried both patches, both work, 0001-Translatable-PETs.patch seems a bit more concise although patch file itself needs a clean.
However, "drush entup" won't run if pet entities are already present. Update hook needs to added.
Comment #6
andreasderijcke0001-Translatable-PETs.patch throws errors on uninstall of the module, while make_pet_translatable-2747525-3.patch does not.
Comment #7
andreasderijckeComment #9
Sharique CreditAttribution: Sharique as a volunteer commentedComment #11
adinac CreditAttribution: adinac as a volunteer commentedAlthough the entity type is translated, the translation is not used in pet_send_mail(). I also added the possibility to pass the language to pet_send_mail().
Comment #12
adinac CreditAttribution: adinac as a volunteer commentedOther improvements, like sending the language as option to the token replacement callback.
Comment #13
Sharique CreditAttribution: Sharique as a volunteer commentedPlease create a new ticket as this closed long back.
Comment #14
camilo.escobar CreditAttribution: camilo.escobar at Urban Insight commentedThe point that @adinac made is important: it is not enough to make the PET entity translatable. All the code involved in sending the emails must be adapted to be able to receive a language parameter, otherwise, just making the entity translatable is useless.
A new issue was created: https://www.drupal.org/project/pet/issues/3366542