Commit 0b3bcb91 authored by John Fiala's avatar John Fiala
Browse files

Issue #949604 by zilverdistel: Added i18n support for the static link text field option.

parent d519981b
......@@ -476,6 +476,10 @@ function _link_sanitize(&$item, $delta, &$field, $instance, &$entity) {
// Use the title defined at the instance level.
if ($instance['settings']['title'] == 'value' && strlen(trim($instance['settings']['title_value']))) {
$title = $instance['settings']['title_value'];
if (function_exists('i18n_string_translate')) {
$i18n_string_name = "field:{$instance['field_name']}:{$instance['bundle']}:title_value";
$title = i18n_string_translate($i18n_string_name, $title);
}
}
// Use the title defined by the user at the widget level.
elseif (isset($item['title'])) {
......@@ -623,7 +627,7 @@ function link_theme() {
'variables' => array('element' => NULL),
),
'link_formatter_link_domain' => array(
'variables' => array('element' => NULL),
'variables' => array('element' => NULL, 'display' => NULL),
),
'link_formatter_link_title_plain' => array(
'variables' => array('element' => NULL),
......@@ -635,7 +639,7 @@ function link_theme() {
'variables' => array('element' => NULL),
),
'link_formatter_link_label' => array(
'variables' => array('element' => NULL),
'variables' => array('element' => NULL, 'field' => NULL),
),
'link_formatter_link_separate' => array(
'variables' => array('element' => NULL),
......@@ -1293,3 +1297,24 @@ function link_field_item_property_info() {
);
return $properties;
}
/**
* Implements hook_field_update_instance().
*/
function link_field_update_instance($instance, $prior_instance) {
if (function_exists('i18n_string_update') && $prior_instance['settings']['title_value'] != $instance['settings']['title_value']) {
$i18n_string_name = "field:{$instance['field_name']}:{$instance['bundle']}:title_value";
i18n_string_update($i18n_string_name, $instance['settings']['title_value']);
}
}
/**
* Implements hook_i18n_string_list_TEXTGROUP_alter().
*/
function link_i18n_string_list_field_alter(&$strings, $type = NULL, $object = NULL) {
if ($type == 'field_instance' && $object && $object['widget']['type'] == 'link_field') {
if (isset($object['settings']['title_value'])) {
$strings['field'][$object['field_name']][$object['bundle']]['title_value']['string'] = $object['settings']['title_value'];
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment