Skip to content

Instantly share code, notes, and snippets.

@citlacom
Created July 23, 2014 15:36
Show Gist options
  • Save citlacom/10ff1b4cb6566c7f2572 to your computer and use it in GitHub Desktop.
Save citlacom/10ff1b4cb6566c7f2572 to your computer and use it in GitHub Desktop.
Programmatically set strings translations in hook_update_N()
/**
* Implements hook_update_N().
*/
function hook_update_N(&$sandbox) {
$report = array(
'skips' => 0,
'updates' => 0,
'deletes' => 0,
'additions' => 0
);
$translations = array(
array(
'src' => 'What is PayPal?',
'tr' => 'Was ist PayPal?',
'lc' => 'de',
),
array(
'src' => 'What is PayPal?',
'tr' => '¿Qué es PayPal?',
'lc' => 'es',
),
array(
'src' => 'How PayPal works',
'tr' => 'So funktioniert PayPal',
'lc' => 'de',
),
array(
'src' => 'How PayPal works',
'tr' => 'Cómo funciona PayPal',
'lc' => 'es',
),
);
foreach ($translations as $tr) {
_locale_import_one_string_db($report, $tr['lc'], '', $tr['src'], $tr['tr'], 'default', '', LOCALE_IMPORT_OVERWRITE);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment