function _drush_language_translations_export_file in Drush Language Commands 7
Saving function for language exports.
@option bool $replace Replace existing translations in the file-system. Defaults to 'false'. @option bool $sort Sorts the generated po file by source and context, defaults to 'true'. @option bool $filter Removes empty translations from the generated po file, defaults to 'true'.
Parameters
string $file_path: Absolute file path.
string $language: Language code.
string $group: Text group to export (fields, default).
Return value
void Saves the export file to file system.
1 call to _drush_language_translations_export_file()
- drush_language_translations_export in ./
language_translations.drush.inc - Export translations from one or more locale groups.
File
- ./
language_translations.drush.inc, line 625 - Drush language commands related to translations.
Code
function _drush_language_translations_export_file($file_path = '-', $language, $group) {
// Don't override destination file
// Unlike file_exists(), this condition allow the use of /dev/stdin.
if (!drush_get_option('replace') && (is_file($file_path) || is_dir($file_path))) {
drush_log(dt('drush language-export: will not override destination file: ' . $file_path), 'warning');
return;
}
$strings = _locale_export_get_strings($language, $group);
// In the case the filter option is given, we remove all empty translations.
if (drush_get_option('filter', TRUE)) {
$strings = array_filter($strings, '_drush_language_translations_strings_filter');
}
// In case the sort option is given, we sort the strings by source string and
// context.
if (drush_get_option('sort', TRUE)) {
uasort($strings, '_drush_language_translations_strings_sort');
}
if ($file_path == '-') {
echo _locale_export_po_generate($language, $strings);
}
else {
file_put_contents($file_path, _locale_export_po_generate($language, $strings));
drush_log(dt('drush language-export: ' . $file_path), 'success');
}
}