function drush_language_translations_export_all_ng in Drush Language Commands 7
Export all translations to files with customizable pattern.
1 string reference to 'drush_language_translations_export_all_ng'
- language_translations_drush_command in ./
language_translations.drush.inc - Implements of hook_drush_command().
File
- ./
language_translations.drush.inc, line 450 - Drush language commands related to translations.
Code
function drush_language_translations_export_all_ng() {
$langcodes = drush_get_option_list('langcode');
if (!$langcodes) {
$languages = l10n_update_translatable_language_list();
$langcodes = array_keys($languages);
}
$textgroups = drush_get_option_list('groups');
if (!$textgroups) {
$textgroups = array_keys(module_invoke_all('locale', 'groups'));
}
$default_file_pattern = drush_get_option('status') === 'not-translated' ? '../translations/custom/%group.%language.pot' : '../translations/custom/%group.%language.po';
$file_pattern = drush_get_option('file-pattern', $default_file_pattern);
$options = [
'status' => drush_get_option('status'),
'force' => drush_get_option('force'),
];
foreach ($langcodes as $langcode) {
foreach ($textgroups as $textgroup) {
$options['group'] = $textgroup;
$file_path_relative = preg_replace(array(
'/%language/u',
'/%group/u',
), array(
$langcode,
$textgroup,
), $file_pattern);
$file_name_absolute = drush_is_absolute_path($file_path_relative) ? $file_path_relative : drush_get_context('DRUSH_DRUPAL_ROOT') . '/' . $file_path_relative;
drush_invoke_process('@self', 'language-export-translations-ng', [
$langcode,
$file_name_absolute,
], $options);
$t_args = [
'!language' => $langcode,
'!file' => $file_path_relative,
];
drush_log(dt('Exported translations for language !language to file !file.', $t_args), 'ok');
}
}
}