Translate name for "(copy)"
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
This commit is contained in:
parent
313aee91ca
commit
85a491a6fb
|
@ -2290,44 +2290,45 @@
|
|||
if ( dotIndex > 1) {
|
||||
let leftPartOfName = targetPathAndName.substr(0, dotIndex);
|
||||
let fileNumber = leftPartOfName.match(/\d+/);
|
||||
// TRANSLATORS name that is appended to copied files with the same name, will be put in parenthesis and appened with a number if it is the second+ copy
|
||||
let copyNameLocalized = t('files', 'copy');
|
||||
if (isNaN(fileNumber) ) {
|
||||
fileNumber++;
|
||||
targetPathAndName = targetPathAndName.replace(/(?=\.[^.]+$)/g, " (copy " + fileNumber + ")");
|
||||
targetPathAndName = targetPathAndName.replace(/(?=\.[^.]+$)/g, " (" + copyNameLocalized + " " + fileNumber + ")");
|
||||
}
|
||||
else {
|
||||
// Check if we have other files with 'copy X' and the same name
|
||||
let maxNum = 1;
|
||||
if (self.files !== null) {
|
||||
leftPartOfName = leftPartOfName.replace("/", "");
|
||||
leftPartOfName = leftPartOfName.replace(/\(copy\)/,"");
|
||||
leftPartOfName = leftPartOfName.replace(/\(copy \d+\)/,"");
|
||||
// find the last file with the number extention and add one to the new name
|
||||
leftPartOfName = leftPartOfName.replace(new RegExp("\\(" + copyNameLocalized + "( \\d+)?\\)"),"");
|
||||
// find the last file with the number extension and add one to the new name
|
||||
for (let j = 0; j < self.files.length; j++) {
|
||||
const cName = self.files[j].name;
|
||||
if (cName.indexOf(leftPartOfName) > -1) {
|
||||
if (cName.indexOf("(copy)") > 0) {
|
||||
targetPathAndName = targetPathAndName.replace(/ \(copy\)/,"");
|
||||
if (cName.indexOf("(" + copyNameLocalized + ")") > 0) {
|
||||
targetPathAndName = targetPathAndName.replace(new RegExp(" \\(" + copyNameLocalized + "\\)"),"");
|
||||
if (maxNum == 1) {
|
||||
maxNum = 2;
|
||||
}
|
||||
}
|
||||
else {
|
||||
let cFileNumber = cName.match(/\(copy (\d+)\)/);
|
||||
let cFileNumber = cName.match(new RegExp("\\(" + copyNameLocalized + " (\\d+)\\)"));
|
||||
if (cFileNumber && parseInt(cFileNumber[1]) >= maxNum) {
|
||||
maxNum = parseInt(cFileNumber[1]) + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
targetPathAndName = targetPathAndName.replace(/ \(copy \d+\)/,"");
|
||||
targetPathAndName = targetPathAndName.replace(new RegExp(" \\(" + copyNameLocalized + " \\d+\\)"),"");
|
||||
}
|
||||
// Create the new file name with _x at the end
|
||||
// Start from 2 per a special request of the 'standard'
|
||||
let extntionName = " (copy " + maxNum +")";
|
||||
let extensionName = " (" + copyNameLocalized + " " + maxNum +")";
|
||||
if (maxNum == 1) {
|
||||
extntionName = " (copy)";
|
||||
extensionName = " (" + copyNameLocalized + ")";
|
||||
}
|
||||
targetPathAndName = targetPathAndName.replace(/(?=\.[^.]+$)/g, extntionName);
|
||||
targetPathAndName = targetPathAndName.replace(/(?=\.[^.]+$)/g, extensionName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue