Dear all,

I just create a custom entity in Drupal 7. I would like to make it work with entity translation as I plan to use in multilingual website.
The custom entity seem working find with Drupal field API and any entity operations (CRUD operation). I tried to enable Entity Translation, the "Translate" tab is displayed and also can see translation overview page. When I click to add translate, it saved the data (it mean when visiting page with certain language, it display correctly with current data language), but when I go to translate overview page again, it still have no translated. How come? Help please......

Please see the image below:

Before and after translated, this page still the same.

No Translate

The original source:
Source

Translated:

Translated

- Here is my table schema:

$schema = array(
        'description' => 'Stores identity information of users.',
        'fields' => array(
            'uid' => array(
                'type' => 'int',
                'not null' => TRUE,
                'disp-width' => '11',
            ),
            'name' => array(
                'type' => 'varchar',
                'length' => '255',
                'not null' => TRUE,
                'default' => '',
            ),
            'language' => array(
                'type' => 'varchar',
                'length' => 32,
                'not null' => FALSE,
            ),
            'created' => array(
                'type' => 'int',
                'not null' => TRUE,
                'disp-width' => '11',
                'default' => 0,
            ),
            'changed' => array(
                'type' => 'int',
                'not null' => TRUE,
                'disp-width' => '11',
                'default' => 0,
            ),
            'updater_uid' => array(
                'type' => 'int',
                'not null' => TRUE,
                'disp-width' => '11',
                'default' => 0,
            )
        ),
        'primary key' => array('uid'),
    );

- hook_entity_info:


function identity_entity_info() {
    $return['identity'] = array(
        'label' => t('Identity'),
        'entity class' => 'Identity',
        'plural label' => t('Identities'),
        'base table' => 'identity',
        'revision table' => 'identity_revision',
        'description' => t('Identity information of users.'),
        'controller class' => 'EntityIdentityController',
        'fieldable' => TRUE,
        'exportable' => FALSE,
        'entity keys' => array(
            'id' => 'uid',
            'label' => 'name',
            'translations' => 'translations'
        ),
        'bundles' => array(
            'identity' => array(
                'label' => t('Identity'),
                'admin' => array(
                    'path' => 'admin/structure/identity/manage/identity',
                    'real path' => 'admin/structure/identity/manage/identity',
                ),
            ),
        ),
        'view modes' => array(
            'full' => array(
                'label' => t('User account'),
                'custom settings' => FALSE,
            ),
        ),
        'admin ui' => array(
            'path' => 'admin/structure/identity',
            'controller class' => 'IdentityUIController',
        ),
        'access callback' => 'identity_access',
        'module' => 'identity',
        'translation' => array(
            'locale' => TRUE,
            'entity_translation' => array(
                'class' => 'EntityTranslationDefaultHandler',
                'default settings' => array(
                    'default_language' => LANGUAGE_NONE,
                    'hide_language_selector' => FALSE,
                ),
                'base path' => 'identity/%identity',
                'path wildcard' => '%identity',
                'access callback' => 'identity_entity_translation_tab_access'
            ),
        ),
    );
    return $return;
}

Really appreciate for your help!

CommentFileSizeAuthor
#2 2-Translated.PNG34.87 KBkriyar
2-Translated.PNG34.87 KBkriyar
2-Orignal.PNG22.96 KBkriyar
no_translate.PNG12.98 KBkriyar
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

kriyar created an issue. See original summary.

kriyar’s picture

Issue summary: View changes
FileSize
34.87 KB
kriyar’s picture

Issue summary: View changes
stefanos.petrakis@gmail.com’s picture

Hey there,

Let's have a look at this together.
Here is a first question:

Do you get new entries for your new 'identity' entities in the tables 'entity_translation' and 'entity_translation_revision'?

plach’s picture

Status: Active » Postponed (maintainer needs more info)
kriyar’s picture

Hi Stefanous,

Yes, I saw the new entries in the table 'entity_translation', but did not see in the table 'entity_translation_revision'.

So how?

kriyar’s picture

Status: Postponed (maintainer needs more info) » Active
plach’s picture

Status: Active » Needs review

This may be related to the BC killswitch we introduced to add revision support without breaking old sites: check whether the entity_translation_revision_enabled variable evaluates to true.

Another possibility could be that your entity type does not define a revision entity key, see:

http://cgit.drupalcode.org/entity_translation/tree/includes/translation....

To fix that you could either define the revision entity key in the entity info or extend the translation handler class and initialize the $revisionable property to TRUE.

kriyar’s picture

I debug the vairiable entity_translation_revision_enabled, it return TRUE.

Any other suggestion?

plach’s picture

What about the second part of my comment above?

Another possibility could be that your entity type does not define a revision entity key, see:

http://cgit.drupalcode.org/entity_translation/tree/includes/translation....

To fix that you could either define the revision entity key in the entity info or extend the translation handler class and initialize the $revisionable property to TRUE.

kriyar’s picture

ciss’s picture

Status: Needs review » Postponed (maintainer needs more info)