- Issue created by @giuse69
- 🇺🇸United States apmsooner
The logic for this was accounted for. Are you sure you're viewing the entity that contains the token for the term in the same translated language? So if you have a translated term in 'es', are you viewing the node also with the 'es' and is the custom_field marked as a translatable field?
- 🇺🇸United States apmsooner
I just double checked this with taxonomy reference on my custom field and it indeed works as designed. I think you need to recheck your settings and make sure that that:
- The taxonomy term has a translation
- The node with the custom_field referencing the term has a translation
- The custom_field is marked as translatable
- You're viewing the node with the tokens template in the desired language.
- 🇮🇹Italy giuse69
Hi, thanks but I am referring to another case:
- the custom field is in a paragraph type that is marked as non translatable, since the user should not be able to translate it;
- the subfield of the custom field is an entity reference to a taxonomy term that IS translatable and has translations.The custom field in the paragraph should show the name of the referenced taxonomy term translated in current language, instead the name in the original language is always shown.
Could you please confirm the issue in this case?
thanks - 🇺🇸United States apmsooner
This works as designed. I tested also in paragraphs. The translated field is going to inherit the language settings of the parent entity. If your custom field is attached to a paragraph entity that is non translatable... thats exactly the problem. You can't expect a translated value for a field on an entity that is not translated. Enable translations on the paragraph and it will work as designed. This is the way translated fields work across Drupal.
- 🇮🇹Italy giuse69
Sorry since I made a mistake in the description of the scenario:
- the paragraph IS translatable
- the custom field in the paragraph is NOT translatable (since it does not have to be translated because...)
- ...the sub-field in the custom field is an entity reference to a taxonomy term (here's why is not translatable)
- the referenced taxonomy term IS translatable and HAS translations.Effect: the referenced taxonomy term is not shown translated.
I find it wrong since if I use directly an entity reference field instead of the custom field with the entity reference inside as a subfield, the translation works.thanks
- 🇺🇸United States apmsooner
I'm sorry but you pretty much lost me. Are you asking to have a setting that hides subfields that shouldn't be translated? That really has nothing to do at all with token support so if you are asking for something completely unrelated, please open a different ticket. Otherwise, I'm getting really confused on what the issue is for you.
- 🇺🇸United States apmsooner
I figured out what you're asking for and how to solve it. The language just needs to be passed into the formatters which is an easy fix. I do think we should eventually consider also a setting that hides the field from form similar to regular fields so you could have granular flexibility at the sub-field level of what to allow for translating. I'll open a separate ticket and at the very least solve the original issue.
- 🇮🇹Italy giuse69
Hi Andy, I try to re-explain.
Scenario:
- an article ART which has a field paragraph P, P IS translatable
- P has two fields:
- a custom field CF in P, where CF is NOT translatable
- a subfield SF in CF that is an entity reference field to a taxonomy term.
- an entity reference field ER to a taxonomy term (exactly the same as SF).
- taxonomy terms ARE translatable and have translations.
Now let's display ART:
- CF is displayed with the taxonomy name always in the original language - WRONG
- ER is displayed with the taxonomy name in current language - CORRECT.So the same entity reference field is not being translated when it is used inside a custom field.
That happens in custom field not only using advanced template as formatters but also using default formatters.
Have I been able to explain the issue more clearly?
If you have questions, do not hesitate.
thanks again - 🇺🇸United States apmsooner
Patch created in this ticket: https://www.drupal.org/project/custom_field/issues/3492350 🐛 Translated entity reference not displaying in correct language Active