You are here

function uc_extra_fields_pane_i18n_get_strings in Extra Fields Checkout Pane 7

Returns translatable strings for an UCXF Field.

Parameters

UCXF_Field $field: The field to get strings for.

Return value

array Translatable strings, keyed by string ID.

2 calls to uc_extra_fields_pane_i18n_get_strings()
uc_extra_fields_pane_i18n_string_list in ./uc_extra_fields_pane.i18n.inc
Implements hook_i18n_string_list().
uc_extra_fields_pane_ucxf_field in ./uc_extra_fields_pane.module
Implementation of hook_ucxf_field().

File

./uc_extra_fields_pane.i18n.inc, line 62
Internationalization (i18n) hooks.

Code

function uc_extra_fields_pane_i18n_get_strings($field) {
  $strings = array(
    'label' => $field->label,
    'description' => $field->description,
  );
  switch ($field->value_type) {

    // Make labels of options in select fields translatable.
    case UCXF_Field::UCXF_WIDGET_TYPE_SELECT:
    case UCXF_Field::UCXF_WIDGET_TYPE_PHP_SELECT:
      $values = $field
        ->generate_value(FALSE);
      foreach ($values as $key => $label) {
        $strings['value:' . $key] = $label;
      }
      break;

    // Make default values translatable.
    case UCXF_Field::UCXF_WIDGET_TYPE_TEXTFIELD:
    case UCXF_Field::UCXF_WIDGET_TYPE_PHP:
    case UCXF_Field::UCXF_WIDGET_TYPE_CONSTANT:
      $value = $field
        ->generate_value(FALSE);
      if (!empty($value)) {
        $strings['value'] = $value;
      }
      break;
  }
  return $strings;
}