Hi, I need to make the title translatable in code, specifically in a hook_update_n() function in my site deployment module. I'm trying to get information on the best way to accomplish this, thanks!

Comments

alberto56’s picture

Status: Active » Fixed

Here is how I deployed this:

First, on my dev site, use the GUI to manually replace the title with a translatable title.

Then, export the node type as a feature.

Then revert the feature on the target sites, for example using:

/**
* Revert fields
*/
function mysite_deploy_update_7088() {
features_revert(array('mysite_feature' => array('node')));
features_revert(array('mysite_feature' => array('field_instance')));
features_revert(array('mysite_feature' => array('field_base')));
}

Now calling drush updb on the target site will make the title translatable (in my tests anyway).

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

SandraVdv’s picture

You can do the following in your code (I did it in hook_install after creating a vocabulary programmatically):

if (title_field_replacement_toggle($entity_type, $entity_bundle, $legacy_field)) {
  title_field_replacement_batch_set($entity_type, $entity_bundle, $legacy_field);
}
deivamagalhaes’s picture

For me, this creates the fields but does not initialize their values. I'm trying to replace name and description fields for a taxonomy vocabulary with existing terms.