You are here

function commerce_i18n_string in Commerce Core 7

Translate a string using i18n_string, if available.

Parameters

$name: Textgroup and context glued with ':'.

$default: String in default language. Default language may or may not be English.

$options: An associative array of additional options, with the following keys:

  • langcode: the language code to translate to a language other than what is used to display the page; defaults to the current language
  • filter: filtering callback to apply to the translated string only
  • format: input format to apply to the translated string only
  • callback: callback to apply to the result (both to the translated or untranslated string)
  • update: whether to update source table; defaults to FALSE
  • translate: whether to return a translation; defaults to TRUE

Return value

The translated string if i18n_string is available, the original otherwise.

See also

i18n_string()

2 calls to commerce_i18n_string()
commerce_checkout_completion_message_pane_checkout_form in modules/checkout/includes/commerce_checkout.checkout_pane.inc
Checkout pane callback: presents a completion message on the complete page.
commerce_order_ui_help in modules/order/commerce_order_ui.module
Implements hook_help().

File

./commerce.module, line 451
Defines features and functions common to the Commerce modules.

Code

function commerce_i18n_string($name, $default, $options = array()) {
  if (module_exists('i18n_string')) {
    $result = i18n_string($name, $default, $options);
  }
  else {
    $result = $default;
    $options += array(
      'format' => NULL,
      'sanitize' => FALSE,
    );
    if ($options['sanitize']) {
      $result = check_markup($result, $options['format']);
    }
  }
  return $result;
}