summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--i18n_field/i18n_field.module22
1 files changed, 22 insertions, 0 deletions
diff --git a/i18n_field/i18n_field.module b/i18n_field/i18n_field.module
index 1549ec6..20851a2 100644
--- a/i18n_field/i18n_field.module
+++ b/i18n_field/i18n_field.module
@@ -256,6 +256,28 @@ function i18n_field_field_widget_form($form, $form_state, $field, $instance, $la
}
/**
+ * Implements hook_field_attach_view_alter().
+ */
+function i18n_field_field_attach_view_alter(&$output, $context) {
+ foreach (element_children($output) as $field_name) {
+ $element = &$output[$field_name];
+ if (!empty($element['#entity_type']) && !empty($element['#field_name']) && !empty($element['#bundle'])) {
+ $instance = field_read_instance($element['#entity_type'], $element['#field_name'], $element['#bundle']);
+
+ // Translate field title if set
+ if (!empty($instance['label'])) {
+ $element['#title'] = i18n_field_translate_property($instance, 'label');
+ }
+
+ // Translate field description if set
+ if (!empty($instance['description'])) {
+ $element['#description'] = i18n_field_translate_property($instance, 'description');
+ }
+ }
+ }
+}
+
+/**
* Implements hook_field_create_field().
*/
function i18n_field_field_create_field($field) {