Skip to content

Instantly share code, notes, and snippets.

Last active August 29, 2015 14:04
What would you like to do?
Drupal API - How to add field translation for label
$entity = 'node';
$field_name = 'employee_first_name';
$bundle = 'employee';
$lang_code = 'fi';
$value = 'Nimi';
// get field instance
$instance = field_info_instance($entity, $field_name, $bundle);
// get instance of i18n_field_instance
$field_instance = i18n_object('field_instance', $instance);
// get textgroup and context
// field:$field_name:$bundle:label
list($textgroup, $context) = i18n_string_context('field:employee_first_name:employee:label');
i18n_string_textgroup($textgroup)->update_translation($context, $lang_code, $value);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment