You are here

function commerce_cart_i18n_string_list_field_alter in Commerce Core 7

Implements hook_i18n_string_list_TEXTGROUP_alter().

File

modules/cart/commerce_cart.module, line 2917
Implements the shopping cart system and add to cart features.

Code

function commerce_cart_i18n_string_list_field_alter(&$strings, $type = NULL, $object = NULL) {

  // Add to cart button text translatable strings.
  $field = field_info_field($object['field_name']);
  if (in_array($field['type'], array(
    'commerce_product_reference',
    'entityreference',
  )) && !empty($object['display'])) {
    foreach ($object['display'] as $display_name => $display) {
      if (!empty($display['settings']['button_text'])) {
        $strings['field'][$object['field_name']][$object['bundle']]['add_to_cart_form-button_text-' . $display_name] = array(
          'string' => $display['settings']['button_text'],
          'title' => t('Add to cart button text') . ' (view mode: ' . $display_name . ')',
        );
      }
    }
  }

  // Attribute widget title translatable string.
  if (!isset($strings['field']) || !is_array($object) || !commerce_cart_field_instance_is_attribute($object)) {
    return;
  }
  if (!empty($object['commerce_cart_settings']['attribute_widget_title'])) {
    $strings['field'][$object['field_name']][$object['bundle']]['attribute_widget_title'] = array(
      'string' => $object['commerce_cart_settings']['attribute_widget_title'],
      'title' => t('Attribute widget title'),
    );
  }
}