summaryrefslogtreecommitdiffstats
path: root/apps/files/js
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2018-11-15 14:20:47 +0100
committerMorris Jobke <hey@morrisjobke.de>2018-11-19 13:57:27 +0100
commit85a491a6fb497246e19316bd4d383e89c9fc42a5 (patch)
tree93a10ce061eff737cde8869c0397de4122a57fd7 /apps/files/js
parent313aee91ca073acb734d7e3029d6b6ce0ce1a384 (diff)
downloadnextcloud-server-85a491a6fb497246e19316bd4d383e89c9fc42a5.tar.gz
nextcloud-server-85a491a6fb497246e19316bd4d383e89c9fc42a5.zip
Translate name for "(copy)"
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Diffstat (limited to 'apps/files/js')
-rw-r--r--apps/files/js/filelist.js23
1 files changed, 12 insertions, 11 deletions
diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js
index e0edb15884f..18e2b9beed6 100644
--- a/apps/files/js/filelist.js
+++ b/apps/files/js/filelist.js
@@ -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);
}
}
}