Problem/Motivation

Labels of subfields are translated (when translations are provided) when displaying the custom field, but when editing it they are not translated. Due to https://www.drupal.org/project/drupal/issues/2546212, display settings currently have no translation UI. The current form element labels are required in the manage form display settings and since they are not translatable, there is only 1 language value that is saved to config.

Steps to reproduce

  • Create a custom field with a couple of subfields (e.g. an entity reference and a number).
  • Translate the custom field, especially the labels of the subfields
  • Switch to non default language
  • Create a new entity containing the custom field: subfield labels translation are NOT used

Proposed resolution

Make form element labels optional and use the fallback label from field settings which IS translatable.

Remaining tasks

User interface changes

n/a

API changes

none

Data model changes

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

giuse69 created an issue. See original summary.

giuse69’s picture

Probably the configuration of the flexbox widget (when sub fields labels are again to be specified) overrides the field translation

apmsooner’s picture

Status: Active » Postponed (maintainer needs more info)

The manage form display settings label takes priority over default label. You should set that translated value and expect that for the form element label. Can you verify that works for you?

giuse69’s picture

Hi, but how can the flexbox parameters be translated..?

apmsooner’s picture

I'm not sure what you mean. Are you asking how the flexbox dropdown options would get translated ie; "1 column", "2 columns", etc..? If so, those would be handled in the /admin/config/regional/translate section. You would need to enable interface translations module. Id that doesn't answer your question, please provide more info or screenshare perhaps because I'm unsure of what is missing for you.

giuse69’s picture

Hi, as the title says, I am referring to the labels of the subfields. They are translated in the "manage fields" tabs and the translations works for display, while in the manage form the flexbox widget requires to specify again the labels of each subfields and these override the translation done, so in the form display the labels of subfields are always taken from the configuration of the flexbox so they are the same in each language. The subfields labels are not translatable in admin/config/regional/translate.
Did I succeed in explaining the problem?
Cheers

apmsooner’s picture

Ahh, I think I understand and it seems this is a known limitation that is a work in progress in Core here: https://www.drupal.org/project/drupal/issues/2546212. I havn't tested the patch. Which version of core are you on?

apmsooner’s picture

I wonder if for now I could look at making the label optional in the form display settings so it uses the fallback from the field settings form which is translatable?

apmsooner’s picture

Title: Subfield labels not translated in form » Make form element labels optional
Version: 4.0.3 » 4.0.x-dev
Issue summary: View changes
Status: Postponed (maintainer needs more info) » Active
apmsooner’s picture

Category: Bug report » Feature request
Status: Active » Needs review

Try the patch which makes the form element labels in display optional and therefore use the field settings label (which is translatable) as fallback. Let me know if this works for you.

giuse69’s picture

hi, now labels in the flexbox are never used, both when left blank but also when filled - is it the desired behavior?

apmsooner’s picture

No, they are supposed to be used if they are set. I just tested again and verified that myself. Can you shared screenshots of exactly where you are seeing this?

giuse69’s picture

hi, here you have:
-) the configuration of the custom field "Base info" with subfields "type" and "status": https://bit.ly/3MLYeUg and https://bit.ly/4akishG
-) the modified code with the fix: https://bit.ly/4q92tHK
-) the configuration of the flexbox: https://bit.ly/4pO5Nsi
-) how the node form appears not using the labels of the flexbox: https://bit.ly/3KYJ1yw

apmsooner’s picture

I can't reproduce your issue and not sure I understand the modified code fix screenshot. That doesn't match the actual patch here: https://git.drupalcode.org/project/custom_field/-/merge_requests/192.diff so not sure if you are doing something in addition to the patch or what but the code is definitely working on my end for the fallback value. Maybe reapply the patch and clear cache or something and make sure you don't have any manually modified files in the module.

giuse69’s picture

You are right: I reapply the patch and now it works. Sorry for message #14.
For me it's ok!

apmsooner’s picture

Status: Needs review » Fixed

Thank you for testing.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

apmsooner’s picture

Status: Fixed » Closed (fixed)