Drupal API - How to add field translation for label
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$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