diff --git a/field_collection.module b/field_collection.module index 53128e5..66a7ac0 100644 --- a/field_collection.module +++ b/field_collection.module @@ -1175,7 +1175,6 @@ function field_collection_field_formatter_info() { 'settings' => array( 'edit' => t('Edit'), 'translate' => t('Translate'), - 'translate' => t('Translate'), 'delete' => t('Delete'), 'add' => t('Add'), 'description' => TRUE, @@ -1372,14 +1371,23 @@ function field_collection_get_operations($settings, $add = FALSE) { } $operations[] = 'delete'; - $keys = array_flip($operations); - $operations = array_filter(array_intersect_key($settings, $keys)); - uksort($operations, function($a, $b) use ($keys) { return $keys[$a] - $keys[$b]; }); + global $field_collection_operation_keys; + $field_collection_operation_keys = array_flip($operations); + $operations = array_filter(array_intersect_key($settings, $field_collection_operation_keys)); + uksort($operations, "_field_collection_compare_operation_keys_by_name"); return $operations; } /** + * Comparison function used in field_collection_get_operations + */ +function _field_collection_compare_operation_keys_by_name($a, $b) { + global $field_collection_operation_keys; + return $field_collection_operation_keys[$a] - $field_collection_operation_keys[$b]; +} + +/** * Helper function to add links to a field collection field. */ function field_collection_field_formatter_links(&$element, $entity_type, $entity, $field, $instance, $langcode, $items, $display) { diff --git a/includes/translation.handler.field_collection_item.inc b/includes/translation.handler.field_collection_item.inc index 55898b0..2eaea26 100644 --- a/includes/translation.handler.field_collection_item.inc +++ b/includes/translation.handler.field_collection_item.inc @@ -36,7 +36,7 @@ class EntityTranslationFieldCollectionItemHandler extends EntityTranslationDefau * {@inheritdoc} */ public function getLanguage() { - $langcode = $this->entity->langcode() ?: LANGUAGE_NONE; + $langcode = $this->entity->langcode() ? $this->entity->langcode() : LANGUAGE_NONE; // Use the field language as entity language. If the current field is // untranslatable inherit the host entity language. if ($langcode == LANGUAGE_NONE && ($host_entity_type = $this->entity->hostEntityType()) && ($host_entity = $this->entity->hostEntity())) {