Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment #1
alberto56 CreditAttribution: alberto56 commentedHere 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).Comment #3
SandraVdv CreditAttribution: SandraVdv commentedYou can do the following in your code (I did it in hook_install after creating a vocabulary programmatically):
Comment #4
deivamagalhaes CreditAttribution: deivamagalhaes for Appnovation commentedFor 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.