- Issue created by @antonio.bertolini
- First commit to issue fork.
- Status changed to Needs review
over 1 year ago 5:00am 27 April 2023 - 🇮🇳India Ranjit1032002
Created MR!4 for the issue mentioned, please review.
Thank You. - Status changed to Needs work
over 1 year ago 10:46am 20 July 2023 - 🇩🇪Germany Anybody Porta Westfalica
I don't think this is right. Shouldn't this be done by config translation? Take a look at the other field group types, please. How is it done there?
- 🇮🇳India urvashi_vora Madhya Pradesh, India
Hi @anybody,
I agree; the proper approach for translating field labels should be through configuration translation rather than manually using the t() function in the code.
In Drupal, the Field Group module (now part of the core as of Drupal 8) uses configuration translation to handle the translation of field labels. The label property defined in the FieldGroupFormatter annotation can be translated using Drupal's built-in configuration translation system.
Thanks
- 🇮🇳India urvashi_vora Madhya Pradesh, India
@Ranjit1032002, (Just suggesting) to make the $field_definition->label() translatable in the FieldGroupTable class, you should remove the t() function from the code and rely on configuration translation instead.
Since, we also have FieldGroupTable class correctly annotated with the @FieldGroupFormatter annotation, by using configuration translation, we ensure that the field labels are translated without modifying the code. This approach also makes it easier for site administrators and translators to manage translations through the user interface.
- 🇮🇹Italy antonio.bertolini
Hi all,
also $this->group->label must be translateable. That's done via language translation so I think that FieldGroupTable.php row 295:
- '#caption' => $this->getSetting('label_visibility') == self::DISPLAY_CAPTION ? $this->group->label : NULL,
+ '#caption' => $this->getSetting('label_visibility') == self::DISPLAY_CAPTION ? $this->t($this->group->label) : NULL,and row 589:
- '#title' => $this->group->label,
+ '#title' => t($this->group->label),has to be changed
Antonio - First commit to issue fork.
- 🇺🇦Ukraine SmovS Lutsk
I’ve updated the MR with the current state of the dev branch. Initially, the MR branch was created from an outdated D9 branch.
I added the ability to translate the labels and titles of rendered fields in the table (buildRowView). I also added translations for the column headers in the table.
Please review