Index: language_translations.drush.inc
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- a/language_translations.drush.inc	(revision f85ea274f208187550eb7e0d7f015309d409b43d)
+++ b/language_translations.drush.inc	(revision )
@@ -110,6 +110,36 @@
     'callback' => 'drush_language_translations_refresh',
   );

+  $commands['language-add-translation'] = array(
+    'description' => 'Add one translation for one locale group (from locale or i18n modules).',
+    'arguments' => array(
+      'langcode' => array(
+        'description' => 'The langcode of the language to be translated.',
+        'value' => 'required'
+      ),
+      'source-string' => array(
+        'description' => 'Source string to be translated for default translation group or context for other groups.',
+        'value' => 'required'
+      ),
+      'target-string' => array(
+        'description' => 'Target string to be saved.',
+        'value' => 'required'
+      ),
+    ),
+    'options' => array(
+      'group' => array(
+        'description' => "Translation group. Default 'default/build-in'.",
+        'value' => 'optional',
+      ),
+    ),
+    'examples' => array(
+      'Translate one string to Spanish' => "$ drush language-add-translation es 'Hello!' '¡Hola!'",
+      'Translate string from i18n-field group' => "$ drush language-add-translation es 'field_description:article:label' 'Descripción' --group=field",
+    ),
+    'aliases' => array('language-translate'),
+    'callback' => 'drush_language_translations_add',
+  );
+
   return $commands;
 }

@@ -499,4 +529,105 @@
   }

   drush_log(dt("drush language: langcode '" . $langcode . "' not installed . "), 'error');
+}
+
+/**
+ * Add one translation for one locale group.
+ *
+ * @param string $langcode
+ *   The langcode of the language to be translated.
+ * @param string $source_string
+ *   Source string to be translated or context for some translations group.
+ * @param string $target_string
+ *   Target string to be saved.
+ *
+ * @option string $group
+ *   Translation group. Default 'default/build-in'.
+ *
+ * @return void
+ */
+function drush_language_translations_add($langcode, $source_string, $target_string) {
+  // Parse arguments and options.
+  $language = _drush_language_translations_get_language($langcode);
+
+  $group = drush_get_option('group');
+  if (empty($group)) {
+    $group = 'default';
+  }
+  $groups_found = _drush_language_translations_groups_filter(array($group));
+
+  if (empty($language) || empty($groups_found)) {
+    drush_log(dt("drush language: could not parse arguments"), 'error');
+    return;
+  }
+
+  // Translate.
+  if ($group == 'default') {
+    // For group "default" we just add or update translation.
+    // We use empty context.
+    _drush_language_add_string_translation($source_string, $target_string, $langcode, '', $group);
+  }
+  else {
+    // Otherwise, we use $source_string as context.
+    // Source is empty (it is not unique key for i18n groups).
+    _drush_language_add_string_translation('', $target_string, $langcode, $source_string, $group);
+  }
+}
+
+/**
+ * Add or update translation from "default" text group.
+ *
+ * @param string $source
+ *   Source string, must be in English
+ * @param string $translation
+ *   Translation string.
+ * @param string $langcode
+ *   Code of language.
+ * @param string $context
+ *   String of context.
+ * @param string $group
+ *   Translation group.
+ */
+function _drush_language_add_string_translation($source, $translation, $langcode, $context, $group) {
+  // Add new string if it is not exist. For default group only.
+  if ($group == 'default') {
+    locale($source, $context, $langcode);
+  }
+
+  // Get ID from source table.
+  $query = db_select('locales_source', 'ls');
+  $query->addField('ls', 'lid');
+  if ($group == 'default') {
+    $query->condition('ls.source', $source);
+  }
+  $query->condition('ls.context', $context);
+  $query->condition('ls.textgroup', $group);
+  $lid = $query->execute()->fetchField();
+
+  // Insert or update translation.
+  $fields = array(
+    'language' => $langcode,
+    'translation' => $translation,
+    'plid' => 0,
+    'plural' => 0,
+  );
+  if (module_exists('i18n_string')) {
+    $fields['i18n_status'] = I18N_STRING_STATUS_CURRENT;
+  }
+  $query = db_merge('locales_target');
+  $query->key(array('lid' => $lid));
+  $query->fields($fields);
+  $query->execute();
+
+  // Clear cache.
+  if (module_exists('i18n_string')) {
+    // If we use module i18n_string, we use special cache system.
+    if ($i18n_string_object = i18n_string_get_by_lid($lid)) {
+      $i18n_string_object->cache_reset();
+    }
+  }
+  else {
+    // If we use module locale, we use simple cache.
+    cache_clear_all('locale:', 'cache', TRUE);
+  }
 }
