Translate the filemanager

This commit is contained in:
Johannes Zellner
2020-11-10 00:59:03 +01:00
parent 89cde563f6
commit ec00eecab3
3 changed files with 176 additions and 108 deletions

View File

@@ -59,9 +59,6 @@ angular.forEach(
angular.module('ngDrag', []).directive(ngDragEventDirectives);
app.controller('FileManagerController', ['$scope', '$translate', '$timeout', 'Client', function ($scope, $translate, $timeout, Client) {
var title = $translate.instant('filemanager.title');
if (title !== 'filemanager.title') window.document.title = title;
var search = decodeURIComponent(window.location.search).slice(1).split('&').map(function (item) { return item.split('='); }).reduce(function (o, k) { o[k[0]] = k[1]; return o; }, {});
$scope.initialized = false;
@@ -96,27 +93,7 @@ app.controller('FileManagerController', ['$scope', '$translate', '$timeout', 'Cl
|| f.match(/\.tar\.bz2$/);
}
$scope.menuOptions = [
{
text: 'Rename',
click: function ($itemScope, $event, entry) { $scope.renameEntry.show(entry); }
}, {
text: 'Change Ownership',
click: function ($itemScope, $event, entry) { $scope.chownEntry.show(entry); }
}, {
text: 'Extract Here',
displayed: function ($itemScope, $event, entry) { return !entry.isDirectory && isArchive(entry.fileName); },
click: function ($itemScope, $event, entry) { extract(entry); }
}, {
text: 'Download',
displayed: function ($itemScope, $event, entry) { return !entry.isDirectory; },
click: function ($itemScope, $event, entry) { download(entry); }
}, {
text: 'Delete',
hasTopDivider: true,
click: function ($itemScope, $event, entry) { $scope.entryRemove.show(entry); }
}
];
$scope.menuOptions = [];
var LANGUAGES = [];
require(['vs/editor/editor.main'], function() {
@@ -166,7 +143,7 @@ app.controller('FileManagerController', ['$scope', '$translate', '$timeout', 'Cl
if (error) {
console.error(error);
$scope.extractStatus.error = 'Failed to extract: ' + error.message;
$scope.extractStatus.error = $translate.instant('filemanager.extract.error', error);
return;
}
@@ -463,7 +440,7 @@ app.controller('FileManagerController', ['$scope', '$translate', '$timeout', 'Cl
Client.filesCreateDirectory($scope.id, $scope.type, filePath, function (error) {
$scope.newDirectory.busy = false;
if (error && error.statusCode === 409) return $scope.newDirectory.error = 'Already exists';
if (error && error.statusCode === 409) return $scope.newDirectory.error = 'exists';
if (error) return Client.error(error);
$scope.refresh();
@@ -497,7 +474,7 @@ app.controller('FileManagerController', ['$scope', '$translate', '$timeout', 'Cl
Client.filesUpload($scope.id, $scope.type, filePath, new File([], $scope.newFile.name), false, function () {}, function (error) {
$scope.newFile.busy = false;
if (error && error.statusCode === 409) return $scope.newFile.error = 'Already exists';
if (error && error.statusCode === 409) return $scope.newFile.error = 'exists';
if (error) return Client.error(error);
$scope.refresh();
@@ -754,6 +731,32 @@ app.controller('FileManagerController', ['$scope', '$translate', '$timeout', 'Cl
});
});
$translate([ 'filemanager.title', 'filemanager.list.menu.rename', 'filemanager.list.menu.chown', 'filemanager.list.menu.extract', 'filemanager.list.menu.download', 'filemanager.list.menu.delete' ]).then(function (tr) {
if (tr.title !== 'filemanager.title') window.document.title = tr.title;
$scope.menuOptions = [
{
text: tr['filemanager.list.menu.rename'],
click: function ($itemScope, $event, entry) { $scope.renameEntry.show(entry); }
}, {
text: tr['filemanager.list.menu.chown'],
click: function ($itemScope, $event, entry) { $scope.chownEntry.show(entry); }
}, {
text: tr['filemanager.list.menu.extract'],
displayed: function ($itemScope, $event, entry) { return !entry.isDirectory && isArchive(entry.fileName); },
click: function ($itemScope, $event, entry) { extract(entry); }
}, {
text: tr['filemanager.list.menu.download'],
displayed: function ($itemScope, $event, entry) { return !entry.isDirectory; },
click: function ($itemScope, $event, entry) { download(entry); }
}, {
text: tr['filemanager.list.menu.delete'],
hasTopDivider: true,
click: function ($itemScope, $event, entry) { $scope.entryRemove.show(entry); }
}
];
});
$('.file-list').on('scroll', function (event) {
if (event.target.scrollTop > 10) event.target.classList.add('top-scroll-indicator');
else event.target.classList.remove('top-scroll-indicator');