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.
When using block title as field label
And the block is a view the title doesn't get translated even when I translated the title of the view
Comment | File | Size | Author |
---|---|---|---|
#12 | block-title-translatable-2835537-12.patch | 4.12 KB | swentel |
#7 | block_view_title_not_translatable-2835537-7.patch | 609 bytes | bceyssens |
#5 | block_view_title_not_translatable-2835537-5.patch | 448 bytes | bceyssens |
Comments
Comment #2
myLies CreditAttribution: myLies as a volunteer commentedCan confirm - when view title are translated - it don't show translated title in block
But, I translated it using block translation
Comment #3
aspilicious CreditAttribution: aspilicious commentedWhat happens when you select "use block title as the field label"
Comment #4
aspilicious CreditAttribution: aspilicious commentedComment #5
bceyssensComment #7
bceyssensComment #8
swentel CreditAttribution: swentel at eps & kaas for Dropsolid commentedMmm, using $this->t() seems weird. How does core translate this?
Comment #9
swentel CreditAttribution: swentel at eps & kaas for Dropsolid commentedComment #10
swentel CreditAttribution: swentel at eps & kaas commentedWe should change type_label to 'label' so config translation can kick in.
Comment #11
swentel CreditAttribution: swentel at eps & kaas commentedComment #12
swentel CreditAttribution: swentel at eps & kaas commentedGetting close with this patch. To fix:
- Adding translation acts a bit weird, it overwrites the original initially as well (but does save the translated label)
- getting to use the translated version of the title in the frontend
- clear cache when adding/deleting ds field (to trigger ds_config_translation_info_alter()).
(this would have probably been easier and more logic if our fields were config entities, but oh well)
Comment #13
swentel CreditAttribution: swentel at eps & kaas commentedSo ironically, if you use the title from the field itself, you can translate via the translate ui - cf DynamicField class. Completely missed that.
Adding t() around the title when it comes from a block or views is not my favorite option here, so simply closing.