You are here

function i18n_string_translate_list in Internationalization 7

Translation for list of options

Parameters

$options: Array with additional options, some changes

  • 'index' => field that will be mapped to the array key (defaults to 'property')
1 call to i18n_string_translate_list()
i18n_string_translate in i18n_string/i18n_string.module
Get translation for user defined string.

File

i18n_string/i18n_string.module, line 768
Internationalization (i18n) package - translatable strings.

Code

function i18n_string_translate_list($name, $strings, $options = array()) {
  $options['langcode'] = $langcode = isset($options['langcode']) ? $options['langcode'] : i18n_langcode();

  // If language is default, just return
  if (i18n_string_translate_langcode($langcode)) {

    // Get textgroup context, preserve placeholder
    list($textgroup, $context) = i18n_string_context($name, '*');
    $translations = i18n_string_textgroup($textgroup)
      ->multiple_translate($context, $strings, $options);

    // Add for l10n client if available, we pass translation object that contains the format
    foreach ($translations as $index => $translation) {
      i18n_string_l10n_client_add($translation, $langcode);
      $strings[$index] = $translation
        ->format_translation($langcode, $options);
    }
  }
  else {

    // Format and return
    foreach ($strings as $key => $string) {
      $strings[$key] = i18n_string_format($string, $options);
    }
  }
  return $strings;
}