So say we want to enable a field for translation, and this field is part of a content type that has already been translated.
When I do this, I only get the data for this field copied across for the original language. The translations (which before were sharing the field) lose the content.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Leon Kessler’s picture

Here's what we did (in case anyone else is interested).
An extra checkbox just before the bulk update batch operation, to check if the user wants to copy data for all translations.

plach’s picture

Status: Active » Needs review

Thanks, this sounds like an interesting feature, we could also default to TRUE. Anyway, here is a quick code review. Before commit will have to test this.

+++ b/sites/all/modules/contrib/entity_translation/entity_translation.admin.inc
@@ -442,6 +446,7 @@ function entity_translation_translatable_form_submit($form, $form_state) {
+  $copy_all_languages = isset($form_state['values']['copy_all_languages']) ? $form_state['values']['copy_all_languages'] : FALSE;

This can be simplified: !empty($form_state['values']['copy_all_languages']).

+++ b/sites/all/modules/contrib/entity_translation/entity_translation.admin.inc
@@ -533,7 +538,7 @@ function entity_translation_translatable_batch($translatable, $field_name, &$con
+      ¶

@@ -548,7 +553,17 @@ function entity_translation_translatable_batch($translatable, $field_name, &$con
+        ¶

Trailing whitespaces.

Status: Needs review » Needs work
Leon Kessler’s picture

Status: Needs work » Needs review
FileSize
3.08 KB

Okay great! Here's a new patch with the suggestions you made.
I also made an addition to the description on the checkbox, as it didn't describe what the behaviour was if it was disabled.

plach’s picture

+++ b/entity_translation.admin.inc
@@ -412,6 +412,11 @@ function entity_translation_translatable_form($form, &$form_state, $field_name)
+      '#title' => t('Copy current data for <em>all</em> translations (else data will only be copied for the original language).'),

I'd move this to a #description key and use just "Copy translations" as checkbox label. I'd also remove the parentheses: "Copy the current field data to all translations, otherwise data will only be stored for the original language."

Leon Kessler’s picture

Okay, that sounds good.
Here's the new patch.

plach’s picture

Thanks! I will test this as soon as I have some spare time and if don't find any functional issue I'll commit it. Meanwhile, to get more bouns points, you may want to provide some test coverage ;)

plach’s picture

Status: Needs review » Fixed

Great work! Sorry for taking so long.

Committed and pushed, thanks!

Status: Fixed » Closed (fixed)

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

  • Commit 195e814 on 7.x-1.x, factory, et-fc, revisions authored by leon.nk, committed by plach:
    Issue #1907456 by leon.nk: Added Allow bulk field updates to copy data...

  • Commit 195e814 on 7.x-1.x, factory, et-fc, revisions, workbench authored by leon.nk, committed by plach:
    Issue #1907456 by leon.nk: Added Allow bulk field updates to copy data...