Posted by oskar_calvo on December 16, 2016 at 4:50pm
Buenas, he estado mirando por internet, y la verdad es que no he encontrado nada, únicamente esta pregunta: http://drupal.stackexchange.com/questions/176120/entity-translation-for-... pero que no tiene respuesta.
El caso es que tengo esta entidad:
/**
* Implements hook_entity_info().
*/
function territory_entity_info() {
$info = array();
$info['territory'] = array(
'label' => t('Territory'),
'base table' => 'territory',
'entity class' => 'Territory',
'controller class' => 'EntityAPIControllerExportable',
'label callback' => 'entity_class_label',
'uri callback' => 'entity_class_uri',
'fieldable' => TRUE,
'entity keys' => array(
'id' => 'territory_id',
'name' => 'machine_name',
'label' => 'name',
),
'view modes' => array(
'full' => array(
'label' => t('Territory page'),
'custom settings' => FALSE,
),
),
);
return $info;
}
este el hook_schema:
/**
* Implements hook_schema().
*/
function territory_schema() {
$schema = array();
$schema['territory'] = array(
'description' => 'Stores territory information.',
'fields' => array(
'territory_id' => array(
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => 'Primary Key: Unique territory ID.',
),
'name' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
'description' => 'Name of the territory.',
),
'machine_name' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
'description' => 'The territory machine name.',
),
'theater_id' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => '{theater}.theater_id for this territory.',
),
),
'primary key' => array('territory_id'),
'unique keys' => array(
'machine_name' => array('theater_id', 'machine_name'),
),
'foreign keys' => array(
'theater' => array(
'table' => 'theater',
'columns' => array('theater_id' => 'theater_id'),
),
),
);
return $schema;
}
Y me gustaría saber que tengo que hacer para que sea traducible, no he encontrado nada de como hacerlo, alguna idea?
Gracias.
Oskar
Comments
Entity translation
Yo me fijaría en como lo hace un módulo contribuido que ya tenga algo parecido, por ejemplo de Drupal Commerce el módulo commerce_product.module en el hook_entity_info incluye estas líneas:
<?php
// Add translation support.
'translation' => array(
'locale' => TRUE,
'entity_translation' => array(
'class' => 'EntityTranslationCommerceProductHandler',
'bundle callback' => 'commerce_product_entity_translation_supported_type',
'default settings' => array(
'default_language' => LANGUAGE_NONE,
'hide_language_selector' => FALSE,
),
),
),
?>
Además sabiendo que en en la documentación de Drupal Commerce recomiendan Entity Translation pues creo que tenemos la combinación de la posible solución.
No lo he hecho pero bueno creo que es el camino más factible y lógico.
Edito: Se me olvidó anotar que habría que crear la clase que define el manejador de traducciones según se especifica en el código indicado más arriba.
Saludos.
Gracia, me lo miraré, y
Gracia, me lo miraré, y también he encontrado este hilo que puede ayudar : https://www.drupal.org/node/2442703