Untranslated translatable fields on translations of nodes are not marked for Language of Parts

Created on 25 May 2023, over 1 year ago
Updated 31 May 2023, over 1 year ago

Problem/Motivation

If content translation has been enabled for a website, and a field within a content type has been designated as translatable, then when a node in the site's primary language gets a new translation, the translatable fields in the new translation are pre-populated with the original contents in the website's language. Until such time as the contents of the field are translated, I would expect that content to be surrounded with a tag that marks its language as not being in the page's language. However, as of Drupal 10.0.9, the content is not being so marked.

Steps to reproduce

As an administrator:
1. Create an English-language website
2. Add Spanish as a content translation language
3. Make the Article content type translatable and hide untranslatable fields from translation edits
4. Make all the existing fields translatable
7. Add Content > Article
8. Enter a title "English page with translatable content"
9. Enter body text "This content is translatable."
10. Leave the page language as English
11. Save/publish
12. Click the Translate tab
13. Replace the title with "Página en inglés con contenido traducible"
14. Do not edit the body field
15. Save/publish
17. Right-click the words "This content is translatable."

Expected result:
<div class="field__item" lang="en"><p>This content is translatable.</p></div>

Actual result:
<div class="field__item"><p>This content is translatable.</p></div>

Proposed resolution

Option 1:
Assume that if an editor has edited the field, that the contents of the field are now translated. While this is a risky assumption, at least formattable text fields can take appropriate within-field language attributes. This option is probably not appropriate for any plain-text fields, since those cannot take in-field language attributes.

  • If the translatable field on the translated instance has not been edited before saving, then on rendering the translated instance, wrap the field in a language attribute for the original node language.
  • If the translatable field on the translated instance has been edited before saving, then on rendering the translated instance, do not wrap the field in a language attribute for the original node language.

Option 2:
Require the editor to confirm whether they have translated each edited field on the translated instance.

  • Whenever an editor types into a translatable field on a translated instance, add a checkbox below the field "This field has been translated".
  • If the checkbox has not been checked before saving, then on rendering the translated instance, wrap the field in a language attribute for the original node language.
  • If the checkbox has been checked before saving, then on rendering the translated instance, do not wrap the field in a language attribute for the original node language.

Remaining tasks

User interface changes

If option 2 is chosen, adding a "This field has been translated" checkbox.

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Active

Version

10.0

Component
Language system 

Last updated about 15 hours ago

  • Maintained by
  • 🇩🇪Germany @sun
Created by

🇺🇸United States charles belov San Francisco, CA, US

Live updates comments and jobs are added and updated live.
  • Accessibility

    It affects the ability of people with disabilities or special needs (such as blindness or color-blindness) to use Drupal.

Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024