Programmatically translate a string in hook_update_N()
Yes, you can check in the locale module how it's done and replicate to use the same queries like this : 

/**
 * Translating some pagination strings.
 */
function hook_update_XXXX() {
  $translations = array(
   'last' =&gt; array(
     'fr' =&gt; 'dernière page',
     'en-en' =&gt; 'last',
   ),
   'first' =&gt; array(
     'fr' =&gt; 'première page',
     'en-en' =&gt; 'first',
   ),
 );

 foreach ($translations as $string =&gt; $values) {
   $source = db_query('SELECT lid, source, context, textgroup, location FROM {locales_source} WHERE source = :string', array(':string' =&gt; $string))-&gt;fetchObject();
  if (!$source) {
    watchdog('update_hook', 'Translation of string "%string" failed.', array('%string%' =&gt; $string));
    continue;
  }

  foreach ($values as $langcode =&gt; $translated) {
    $translation = db_query('SELECT translation FROM {locales_target} WHERE lid = :lid AND language = :language', array(':lid' =&gt; $source-&gt;lid, ':language' =&gt; $langcode))-&gt;fetchField();
    if (is_string($translation)) {
      db_update('locales_target')
      -&gt;fields(array('translation' =&gt; $translated))
      -&gt;condition('lid', $source-&gt;lid)
      -&gt;condition('language', $langcode)
      -&gt;execute();
    }
    else {
      db_insert('locales_target')
      -&gt;fields(array(
        'lid' =&gt; $source-&gt;lid,
        'translation' =&gt; $translated,
        'language' =&gt; $langcode,
      ))
      -&gt;execute();
      }
    }
  }
}


I'm using such code to update strings in code instead of having to this manually when deploying code. So a simple "drush updb" can do the job for me.

OR as I've found out recently, a faster version exists like this :

/**
 * Translating some strings.
 */
function hook_update_X() {
  $report = array(
    'skips'=&gt; 0,
    'updates'=&gt; 0,
    'deletes'=&gt; 0,
    'additions'=&gt; 0
  );

  // Translate strings.
  _locale_import_one_string_db($report, 'fr', '', 'Your shipping address book is currently empty.', 'Votre carnet d\'adresses de livraison est actuellement vide.', 'default', '', LOCALE_IMPORT_OVERWRITE);
  _locale_import_one_string_db($report, 'fr', '', 'Your billing address book is currently empty.', 'Votre carnet d\'adresses de facturation est actuellement vide.', 'default', '', LOCALE_IMPORT_OVERWRITE);

  // Clear locale cache.
  cache_clear_all('locale:', 'cache', TRUE);
}


For Drupal 8, please see this answer : https://drupal.stackexchange.com/a/220608/61138