You are here

function scald_string_translate in Scald: Media Management made easy 7

Translates a dynamic string.

This uses dynamic string translation from Internationalization module if available. Falls back to basic translation support if it is not.

Parameters

array|string $name: Array or string concatenated with ':' that contains textgroup and string context.

string $string: The string to translate.

array $options: An associative array of options as used by i18n_string_translate().

Return value

string The translated string, or if i18n_string is not enabled, the input string.

See also

i18n_string_translate()

1 call to scald_string_translate()
scald_type_property_translate in ./scald.module
Returns a translated property of a Scald atom type.

File

./scald.module, line 2333
The Scald Core, which handles all Scald Registries and dispatch.

Code

function scald_string_translate($name, $string, $options = array()) {
  if (module_exists('i18n_string')) {

    // Do not sanitize, to have parity with the untranslated string which should
    // also be sanitized by the calling function.
    $options['sanitize'] = FALSE;
    $string = i18n_string_translate($name, $string, $options);
  }
  else {

    // If i18n_string is not enabled, fall back to t() to translate the string.
    // @see https://www.drupal.org/node/2291875
    $options = array_intersect_key($options, array_flip(array(
      'langcode',
    )));

    // @codingStandardsIgnoreStart
    $string = t($string, array(), $options);

    // @codingStandardsIgnoreEnd
  }
  return $string;
}