-
-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create content in language with field translation. #11
Conversation
Create content in language with field translation.
Awesome, thanks! |
Create content in language with field translation. Signed-off-by: Jonathan Hedstrom <[email protected]>
@jhedstrom @dutchiexl : I'm afraid the proposed solution breaks in Drupal 8 since With current master branch of both drupal extension and drupal driver, when running D8 tests, I get:
|
We could actually add the $entity object to the field handler constructor, so we delegate all core specific logic the handler implementations, so from: public function getFieldHandler($entity_type, $field_name, $language); We would have: public function getFieldHandler($entity, $entity_type, $field_name); |
$this->field_info = field_info_field($field_name); | ||
$this->language = field_is_translatable('node', $this->field_info) ? $language : LANGUAGE_NONE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Field handlers are actually supposed to work with all type of entities, so any specific entity type reference (i.w. 'node'
in this case) should be removed, $entity_type
should be used instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could actually use something similar to what core does for comments:
$langcode = field_is_translatable('comment', $field) ? entity_language('comment', $comment) : LANGUAGE_NONE;
So:
$langcode = field_is_translatable($entity_type, $this->field_info) ? entity_language($entity_type, $entity) : LANGUAGE_NONE;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, comments is where I got my mustard from. I can check out the entity_language if you like and refactor the update.
You can add a language in the table hash
Every field that is translatable, will be set in this language