In order for Feeds to support Entity translation, and have field translations import properly, Entity translation must record the translations in its own database table. This ticket makes the translation-saving possible.

The Feeds initiative to handle all of this is #1183440: Multilingual Feeds - Make field import language-aware.

As soon as #1362378: Provide entity post-save hook gets committed, the code will get activated, but the code for this can be committed at any time without having to wait for it.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

colan’s picture

Assigned: colan » Unassigned
Status: Active » Needs review
FileSize
2.84 KB

...and here they are.

colan’s picture

Mismatch with latest dev branch, re-rolling.

plach’s picture

Status: Needs review » Needs work

@Colan:

Would you please update the issue summary to provide a bit more context for this issue?

Quick code review:

+++ b/entity_translation.info
@@ -6,4 +6,5 @@ configure = admin/config/regional/entity_translation
+files[] = includes/translation.handler.feeds.inc

Please rename this file to entity_translation.feeds.inc, "translation.handler.*.inc" files are supposed to hold classes implementing the EntityTranslationHandlerInterface.

+++ b/includes/translation.handler.feeds.inc
@@ -0,0 +1,58 @@
+      if (!in_array($mapping['language'], array_merge(
+          $translations, array($default, 'und')
+      ))) {

Can we have a single line here?

+++ b/includes/translation.handler.feeds.inc
@@ -0,0 +1,58 @@
+    ->condition('entity_type', $entity->feeds_item->entity_type)
+    ->condition('entity_id',   $entity->feeds_item->entity_id)
+    ->condition('language',    $entity->language, '<>')
+    ->condition('source',      '')

Core does not use space padding.

There are also some empty balnk lines around that should be removed.

rtdean93’s picture

Goal: Using Drupal 7, use feeds import to upload single CSV file to populate multilingual commerce shopping systems.

Modules Used:
-Feeds - Used to import files to content or products
-Entity - Creates products via Commerce
-Entity Translate - Translates entities - used instead of/in conjunction with Multilingual Content (which only translates Nodes)
-Title - Replaces default title filed with one that is translatable (since Entity Tranlsate does not accomplish this)
-i18n (International)

Patches Applied
- Make Imports Language Aware - Changes the import form to assign languages
- Add Entity Save Hooks < broken on latest dev release -
- Record Translations created by Feeds

Prerequisites/Config:
-Title (When mapping, select the second "Title" in the list. The first one is the core one not provided by the Title module.)
-Entity translation
-Multilingual content (Both options "Set current language as default for new content" and "Require language (Do not allow Language Neutral)" need to be checked in the Multilingual settings of each content type being imported.)

Testing:
-entity_translation 7.x-1.0-alpha1, entity 7.x-1.0-rc1, i18n 7.x-1.3,
-Feeds - Dec 7 commit

Successes:
-Feed import form is language aware and Product language fields are mapping.

Issues:
-Products are being created as Language Neutral instead of the sites default language. When I save it as English, I get a translate tab... then each additional language is pre-filled with the appropriate fields.
-Product Titles are blank in the Products list... appears Title module is not overriding Product-Title.
-Product Displays are not behaving this way. Since they are originally nodes, they are being created in the site’s default language, but when I click on the translate tab and try to create a new translation, they fields are not pre-populated with the language field.

Any help is appreciated... I’ve been at this for a few weeks and my brain is quite tired.

colan’s picture

@plach: Thanks for the review. I cleaned up the description. Leaving as needs work, as I don't have time to work on this right now. The Feeds hook names are in the process of changing, so it will also need a re-roll for that reason.

colan’s picture

Status: Needs work » Needs review
FileSize
2.66 KB

Fixes for the above are included. The hook names are now correct, although the post-save one hasn't been added to #1362378: Provide entity post-save hook yet. When it is added, this will work.

Status: Needs review » Needs work

The last submitted patch, record_translations_created_by_feeds-1364070-6.patch, failed testing.

colan’s picture

Status: Needs work » Needs review
FileSize
2.63 KB

Sorry. Function headers were off.

rtdean93’s picture

Thanks for this... funny - I am getting no errors with all of the patches applied, but its not working still... Its just importing the English (default) language for Product Displays and still mapping the correct language fields for products (an entity)

Looks like the only thing thats not working is that pesky post-save hook. I'm using a dev release of Feeds from Dec 7 and have applied the patch for the feeds processor - but no luck. Is there any direction you can give me as I try to tackle this?

colan’s picture

@rtdean93: I updated #1362378: Provide entity post-save hook for you. There should now be enough info in there for you to come up with a new patch for it. Thanks! Sorry about my lack of time right now.

rtdean93’s picture

I understand lack of time - and appreciate your guidance.

I have been working on this all day and continue to have trouble... Here's my snapshot...

Entity Translation - Feb 13 Dev release plus patch from #8
Title Module - Dev and patched to remove the watchdog warning

I am using feeds with a node processor to import a csv file. to test this, I created a brand new content type with only a title field. I have enabled the title module for that field and the feed mapper is mapped to an English and French translation. I have also set the node translation type to Multilingual Support with Field Translation.

First of all - I don't think my hooks are being run... I have added watchdog functions as shown...

function entity_translation_feeds_presave($source, $entity) {
watchdog("et_feeds", "presave", array(), WATCHDOG_DEBUG , $link = NULL);

But no result are being fired. I have created a custom module to test the hook and it is working.

function blueline_extra_feeds_presave(FeedsSource $source, $entity) {
watchdog("blueline_extra_feeds", "presave", array(), WATCHDOG_DEBUG , $link = NULL);
}

I do have positive news - after import the nodes are in the defaul language. When I click on the translate tab, no translations exists, but when I add a translation, the fields are pre-populated with the french title.

So - its clear to me - that this post save hook remains my next step.. but its hard to debug if I can't even make sure the presave (and new postsave) hook are being fired.

One more thing - I have a pending issue at Undefined property in node translation handler which is not resolved, but I think related. The #1362790: Undefined property: stdClass::$title in title_entity_update() patch correted the Title, but I still get the error for other translated fields.

Again, guidance is appreciated.

trebormc’s picture

Tagging.

Mohammed J. Razem’s picture

I'm sorry I had to do this in a separate module. Feeds: Entity Translation

plach’s picture

Component: Code » Base system
Status: Needs review » Closed (won't fix)

Ok, let's close this then.

plach’s picture

Issue summary: View changes

Made description clearer.