Created a Node (Article) before enabling Content Translation. Then started a translation request (EN->DE) with the MS translator.

Reviewing the translation results in an error:

Drupal\Core\Entity\EntityStorageException: Invalid translation language (und) specified. in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 757 of core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).
Drupal\content_translation\FieldTranslationSynchronizer->synchronizeFields(Object, 'de', 'und')
content_translation_entity_presave(Object)
etc.

The patch prevents this error.

Comments

cgalli created an issue. See original summary.

Status: Needs review » Needs work

The last submitted patch, set_source_language_in_content_entity_source.patch, failed testing.

mpp’s picture

Priority: Normal » Major

Tested the patch, while it does fix the issue, it also breaks the tests.

Setting to major as I get this when translating an article with an image on a standard Drupal 8 installation.

@cgalli, can you provide me your translation config? I can only reproduce it when I mark "Article" and its image's "Alt" & "Title" as translatable.

The last submitted patch, set_source_language_in_content_entity_source.patch, failed testing.

berdir’s picture

Issue tags: +Needs tests
thenchev’s picture

Assigned: Unassigned » thenchev
thenchev’s picture

Status: Needs work » Needs review
StatusFileSize
new837 bytes

Re-uploading patch to see what tests are failing.

Status: Needs review » Needs work

The last submitted patch, 7: set_source_language_in_content_entity_source-2593509-7.patch, failed testing.

thenchev’s picture

Status: Needs work » Needs review
StatusFileSize
new2.08 KB
new1.26 KB

I might need some more info on this. Here are the steps i tried:
1. Clean drupal install
2. Create node(s) type article
3. Install content entity source
4. Install Microsoft Translator
5. In admin/config/regional/content-language check article
6. In admin/tmgmt/sources request translation

Here i get a fatal but not the one described, i get:
Fatal error: Call to a member function getName() on a non-object in /var/www/html/modules/tmgmt/src/TranslatorPluginBase.php on line 61

target language is here null in case only one language is currently defined.

witch i fixed with this patch

7. Adding second language

other then that can't seem to get any other fatals. Maybe someone can confirm?

mpp’s picture

The issue remains using Drupal 8.0.5 Standard profile. Make sure the article has an image with an alt text and enable "Image", "title" and "alt" on admin/config/regional/content-language.

After further investigation it seems this might be an issue related to the plugin system, it only occurs when "Auto accept finished translations" is enabled.

Steps to reproduce:

  1. Install Drupal 8.0.5 standard profile, tmgmt, tmgmt_microsoft
  2. Configure Microsoft plugin (make sure "Auto accept finished translations" is enabled)
  3. Add some languages
  4. Make article translatable
  5. Create an article with an image and an alt text
  6. Click translate tab
  7. Choose a language and click "Request translation"
  8. Error occurs: Drupal\Core\Entity\EntityStorageException: Invalid translation language (und) specified. in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 757 of /core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).
thenchev’s picture

@mpp thanks for the details, yes there is an issue and the patch fixes it.
Lets see if this fixes the tests.

berdir’s picture

Status: Needs review » Needs work

Test fix looks good, but I'd like to see explicit test coverage for this now.

Should be pretty easy, at the end where we test the stuff, just do the same getTranslationMetadata($translation) call and check getSource().

thenchev’s picture

Status: Needs work » Needs review
StatusFileSize
new883 bytes
new2.65 KB

Expanded test coverage.

  • Berdir committed a28d972 on 8.x-1.x authored by Denchev
    Issue #2593509 by Denchev, cgalli: Set source language in content entity...
berdir’s picture

Status: Needs review » Fixed
Issue tags: -Needs tests

Thanks. committed.

@mpp: While this is definitely something that we were not doing properly, core IMHO really shouldn't fail so bad. I'd suggest you open a core issue to make core more resilient.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.