Incorrect export of the translations

Created on 5 April 2023, over 1 year ago
Updated 7 April 2023, over 1 year ago

Problem/Motivation

The export service excludes the default language of the site from the translation list.
But the entity defaultLangcode and defaultLangcode of the site are different cases and they could be different.
For example - the default language of the site could be EN, but the default language could be NL at the same time.

The issue caused by #3282218: Importing content with translations not in standard language environment throws error if translation already exists

Steps to reproduce

- Make a clean Drupal site.
- Add several languages to the site: EN, NL, FR, where EN is the default
- Create new content in the NL language - it means that NL is the default language now.
- Make translations into EN and FR
- Install single_content_sync module
- Export created content with all translations
EXPECTED RESULT: The content must be exported with 2 translations: EN and FR
ACTUAL RESULT: Content exported only with 2 translations - FR and NL

Example of the wrong result:

site_uuid: <uuid>
uuid: <uuid>
entity_type: node
bundle: blog
base_fields:
  title: 'Test NL'
  status: true
  langcode: nl
  created: '1680701082'
  author: swift+dstny@dropsolid.com
  url: /blog/test-nl
  revision_log_message: null
  revision_uid: '1'
custom_fields:
  body:
    -
      value: "<p>Test NL</p>\r\n"
      summary: ''
      format: full_html
......................................................
translations:
  nl:
    base_fields:
      title: 'Test NL'
      status: true
      langcode: nl
      created: '1680701082'
      author: swift+dstny@dropsolid.com
      url: /blog/test-nl
      revision_log_message: null
      revision_uid: '1'
    custom_fields:
      body:
        -
          value: "<p>Test NL</p>\r\n"
          summary: ''
          format: full_html
......................................................
  fr:
    base_fields:
      title: 'Test FR'
      status: true
      langcode: fr
      created: '1680701107'
      author: swift+dstny@dropsolid.com
      url: /blog/test-fr
      revision_log_message: null
      revision_uid: '1'
    custom_fields:
      body:
        -
          value: "<p>Test FR</p>\r\n"
          summary: ''
          format: full_html
......................................................

Proposed resolution

Use

$translations = $entity->getTranslationLanguages(FALSE);

in doExportToArray() instead of the current solution.

🐛 Bug report
Status

Fixed

Version

1.3

Component

Code

Created by

🇺🇦Ukraine HitchShock Ukraine

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024