0

I have created two field groups on the manage form display tab for a content type. I have added some description also.

On the interface translation, I can translate the field group labels but there I can't translate the description of a field group. As when I search the description there I can't find any results.

I also checked it in the config translation but field group is not present on that page.

Is there any way I can translate the field group translation?

1

As far as I know there is no proper UI for this yet, but field groups are config, so you should be able to translate all strings by creating/editing translated versions of those config files.

First, export your current config, e.g. drush config:export

Then, in your config/sync directory look for files like core.entity_form_display.ENTITY.BUNDLE.FORMMODE.yml. In those files you will see a structure like

langcode: ISO2CODE
status: true
depenencies:
  config:
    - ...
third_party_settings:
  field_group:
    GROUP_ID:
      children:
        - field_foo
        - field_bar
      label: MY_GROUP_LABEL
      format_settings:
        description: 'MY DESCRIPTION'
...some more stuff...

The third_party_settings/field_group contains your group labels in your primary language. To translate a label, create a file language/LANGCODE/core.entity_form_display.ENTITY.BUNDLE.FORMMODE.yml below your config/sync directory.

This file must contain the same structure as the one in the main config file, but remove everything that is not translateable:

third_party_settings:
  field_group:
    GROUP_ID:
      label: MY_TRANSLATED_LABEL
      format_settings:
        description: 'MY TRANSLATED DESCRIPTION'

Finally, reimport the config with the translated labels, e.g. drush config:import

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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