drush --yes translation-import --language=de --customized=true sites/default/translations/de.po
Last active
July 14, 2016 14:50
-
-
Save webflo/42e53d724c1bf6c98fd66e35f66a729a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @file | |
* Custom drush commands. | |
*/ | |
/** | |
* Implements hook_drush_command(). | |
* | |
* @return array | |
*/ | |
function translation_drush_command() { | |
$items['translation-import'] = array( | |
'description' => 'Import custom translations', | |
'arguments' => array( | |
'file' => 'The po file.', | |
), | |
'options' => array( | |
'language' => array( | |
'required' => TRUE, | |
), | |
'customized' => array( | |
'required' => TRUE, | |
), | |
), | |
'required-arguments' => TRUE, | |
); | |
return $items; | |
} | |
/** | |
* Import translations. | |
*/ | |
function drush_translation_import($filepath) { | |
if (!file_exists($filepath)) { | |
drush_set_error('error', '*.po file not found.'); | |
return; | |
} | |
$file = new stdClass(); | |
$file->langcode = drush_get_option('language'); | |
$file->uri = $filepath; | |
Drupal\locale\Gettext::fileToDatabase($file, ['customized' => (int) drush_get_option('customized')]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment