This commit is contained in:
Ilya Tregubov 2022-10-13 14:08:35 +03:00
commit 3f6a102704
2 changed files with 7 additions and 5 deletions

View File

@ -36,7 +36,7 @@ Useful for uploading custom langstrings to AMOS or importing or syncing them to
Options:
-l, --lang Comma seperated language ids to export, default: all
-c, --components Comma seperated components to export, default: all
-t, --target Target to copy the zip files to, default: $CFG->tempdir/customlang
-t, --target Target directory to copy the zip files to, default: $CFG->tempdir/customlang
-o, --overwrite Overwrite existing files in the target folder.
Note: If the target is not set, the files are always overwritten!
-h, --help Print out this help
@ -73,9 +73,10 @@ if ($options['help']) {
echo $usage;
die;
}
if (!file_exists($options['target'])) {
mkdir($options['target'], 0777, true);
}
// Ensure target directory exists.
$options['target'] = rtrim($options['target'], '/') . '/';
check_dir_exists($options['target']);
cli_writeln(get_string('cliexportheading', 'tool_customlang'));
$langs = [];
@ -90,7 +91,7 @@ foreach ($langs as $lang) {
$filename = $options['target'] . get_string('exportzipfilename', 'tool_customlang', ['lang' => $lang]);
// If the file exists and we are not using the temp folder it requires an ovewrite.
if ($options['target'] != $dafaulttarget && file_exists($filename) && !$options['overwrite']) {
cli_problem(get_string('cliexportfileexists', 'tool_customlang', $lang));
cli_problem(get_string('cliexportfileexists', 'tool_customlang', ['lang' => $lang]));
continue;
}
cli_heading(get_string('cliexportstartexport', 'tool_customlang', $lang));

View File

@ -50,6 +50,7 @@ $string['customlang:export'] = 'Export local translation';
$string['customlang:view'] = 'View local translation';
$string['export'] = 'Export custom strings';
$string['exportfilter'] = 'Select component(s) to export';
$string['exportzipfilename'] = 'customlang-export-{$a->lang}.zip';
$string['editlangpack'] = 'Edit language pack';
$string['filter'] = 'Filter strings';
$string['filtercomponent'] = 'Show strings of these components';