nortmas
8/15/2014 - 11:30 AM

Add string to translation

$report = array(
    'skips' => 0,
    'updates' => 0,
    'deletes' => 0,
    'additions' => 0
  );

  $textgroup = 'default';
  $langcode = 'fr';
  $mode = LOCALE_IMPORT_OVERWRITE;
  $location = $context = '';

  $strings = array(
    array(
      'source' => "The specified file %name could not be uploaded.",
      'translation' => "Le document %name ne peut pas être ajouté.",
    ),
    array(
      'source' => "Only files with the following extensions are allowed: %files-allowed.",
      'translation' => "Seuls les fichiers avec les extensions suivantes sont autorisés: %files-allowed.",
    ),
  );

  foreach ($strings as $item) {
    _locale_import_one_string_db($report, $langcode, $context, $item['source'], $item['translation'], $textgroup, $location, $mode);
  }

  cache_clear_all('locale:', 'cache', TRUE);
drupal_array_get_nested_value(array &$array, array $parents, &$key_exists = NULL) // Получает значение из вложенного массива с переменной глубиной.