diff --git a/features.export.inc b/features.export.inc index 2f32c95..8f7bb0d 100644 --- a/features.export.inc +++ b/features.export.inc @@ -622,17 +622,25 @@ function features_var_export($var, $prefix = '', $init = TRUE, $count = 0) { * export so that string extractors like potx can detect them. */ function features_translatables_export($translatables, $indent = '') { - $output = ''; - $translatables = array_filter(array_unique($translatables)); - if (!empty($translatables)) { - $output .= "{$indent}// Translatables\n"; - $output .= "{$indent}// Included for use with string extractors like potx.\n"; - sort($translatables); - foreach ($translatables as $string) { - $output .= "{$indent}t(" . features_var_export($string) . ");\n"; + if (empty($translatables)) { + return; + } + + $output = array(); + foreach ($translatables as $string) { + if (is_array($string)) { + $output[] = "{$indent}t(" . features_var_export($string["value"]) . ", array(), array('context' => '" . $string["context"] . "'));"; + } + else { + $output[] = "{$indent}t(" . features_var_export($string) . ");"; } } - return $output; + array_unique($output); + + $header = "{$indent}// Translatables\n"; + $header .= "{$indent}// Included for use with string extractors like potx.\n"; + return $header . implode("\n", $output); } /** diff --git a/includes/features.field.inc b/includes/features.field.inc index 09104a3..17367e6 100644 --- a/includes/features.field.inc +++ b/includes/features.field.inc @@ -196,10 +196,20 @@ function field_instance_features_export_render($module, $data, $export = NULL) { $code[] = ""; if (!empty($instance['label'])) { - $translatables[] = $instance['label']; + $translatables[] = array("value" => $instance['label'], "context" => $instance['field_name'] . ':' . $instance['bundle'] . ':label'); } if (!empty($instance['description'])) { - $translatables[] = $instance['description']; + $translatables[] = array("value" => $instance['description'], "context" => $instance['field_name'] . ':' . $instance['bundle'] . ':description'); + } + // support for allowed_values + if ($field = features_field_load($identifier)) { + if (!empty($field['field_config']['settings']['allowed_values'])) { + foreach($field['field_config']['settings']['allowed_values'] as $key => $value) { + if (is_string($value) && !empty($value)) { + $translatables[] = array("value" => $value, "context" => $field['field_config']['field_name'] . ':#allowed_values:' . $key); + } + } + } } } } @@ -410,10 +420,19 @@ function field_features_export_render($module, $data, $export = NULL) { // Add label and description to translatables array. if (!empty($field['field_instance']['label'])) { - $translatables[] = $field['field_instance']['label']; + $translatables[] = array("value" => $field['field_instance']['label'], "context" => $field['field_config']['field_name'] . ':' . $field['field_instance']['bundle'] . ':label'); } if (!empty($field['field_instance']['description'])) { - $translatables[] = $field['field_instance']['description']; + $translatables[] = array("value" => $field['field_instance']['description'], "context" => $field['field_config']['field_name'] . ':' . $field['field_instance']['bundle'] . ':description'); + } + + // support for allowed_values + if (!empty($field['field_config']['settings']['allowed_values'])) { + foreach($field['field_config']['settings']['allowed_values'] as $key => $value) { + if (is_string($value) && !empty($value)) { + $translatables[] = array("value" => $value, "context" => $field['field_config']['field_name'] . ':#allowed_values:' . $key); + } + } } } }