Add translations to javascript files

This commit is contained in:
brantje 2016-12-21 14:06:29 +01:00
parent 5e119ff7ed
commit b1aebc4a14
No known key found for this signature in database
GPG key ID: 5FF1D117F918687F
15 changed files with 191 additions and 108 deletions

View file

@ -34,6 +34,81 @@ class TranslationController extends ApiController {
*/
public function getLanguageStrings($lang) {
$translations = array(
// js/app/controllers/bookmarklet.js
'generating.sharing.keys' => $this->trans->t('Generating sharing keys ( %step / 2)'),
'invalid.vault.key' => $this->trans->t('Incorrect vault password!'),
'password.do.not.match' => $this->trans->t('Passwords do not match'),
'general' => $this->trans->t('General'),
'custom.fields' => $this->trans->t('Custom Fields'),
'error.no.label' => $this->trans->t('Please fill in a label!'),
'error.no.value' => $this->trans->t('Please fill in a value!'),
'error.loading.file' => $this->trans->t('Error loading file'),
// js/app/controllers/credential.js
'error.decrypt' => $this->trans->t('An error happend during decryption'),
'credential.created' => $this->trans->t('Credential created!'),
'credential.deleted' => $this->trans->t('Credential deleted'),
'credential.updated' => $this->trans->t('Credential updated'),
'credential.recovered' => $this->trans->t('Credential recovered'),
'credential.destroyed' => $this->trans->t('Credential recovered'),
'error.loading.file.perm' => $this->trans->t('Error downloading file, you probably don\'t have enough permissions'),
// js/app/controllers/edit_credential.js
// js/app/controllers/export.js
'export.starting' => $this->trans->t('Starting export'),
'export.decrypt' => $this->trans->t('Decrypting credentials'),
'done' => $this->trans->t('Done'),
// js/app/controllers/import.js
'import.file.read' => $this->trans->t('File read successfully!'),
'import.no.label' => $this->trans->t('Credential has no label, skipping'),
'import.adding' => $this->trans->t('Adding {{credential}}'),
'import.added' => $this->trans->t('Added {{credential}}'),
'import.loaded' => $this->trans->t('Parsed {{num}} credentials, starting to import'),
// js/app/controllers/revision.js
'revision.deleted' => $this->trans->t('Revision deleted'),
'revision.restored' => $this->trans->t('Revision restored'),
// js/app/controllers/settings.js
'bookmarklet.text' => $this->trans->t('Save in passman'),
'settings.saved' => $this->trans->t('Settings saved'),
'settings.general' => $this->trans->t('General settings'),
'settings.audit' => $this->trans->t('Password Audit'),
'settings.password' => $this->trans->t('Password settings'),
'settings.import' => $this->trans->t('Import credentials'),
'settings.export' => $this->trans->t('Export credentials'),
'settings.sharing' => $this->trans->t('Sharing'),
'changepw.navigate.away.warning' => $this->trans->t('Are you sure you want to leave? This WILL corrupt all your credentials'),
'incorrect.password' => $this->trans->t('Your old password is incorrect!'),
'password.no.match' => $this->trans->t('New passwords do not match!'),
'login.new.pass' => $this->trans->t('Please login with your new vault password'),
// js/app/controllers/share.js
'share.u.g' => $this->trans->t('Share with users and groups'),
'share.link' => $this->trans->t('Share link'),
'share.navigate.away.warning' => $this->trans->t('Are you sure you want to leave? This will corrupt this credential'),
'credential.unshared' => $this->trans->t('Credential unshared'),
'credential.shared' => $this->trans->t('Credential shared'),
'saved' => $this->trans->t('Saved!'),
// js/app/directives/credentialfield.js
'toggle.visibility' => $this->trans->t('Toggle visibility'),
'copy' => $this->trans->t('Copy to clipboard'),
'copied' => $this->trans->t('Copied to clipboard!'),
// js/app/directives/passwordgen.js
'password.gen' => $this->trans->t('Generate password'),
'password.copy' => $this->trans->t('Copy password to clipboard'),
'password.copied' => $this->trans->t('Password copied to clipboard!'),
// js/app/directives/progressbar.js
'complete' => $this->trans->t('Complete'),
// templates/views/partials/edit_credential/basics.html
'username' => $this->trans->t('Username'),
'password.r' => $this->trans->t('Repeat password'),

View file

@ -32,8 +32,8 @@
* Controller of the passmanApp
*/
angular.module('passmanApp')
.controller('BookmarkletCtrl', ['$scope', '$rootScope', '$location', 'VaultService', 'CredentialService', 'SettingsService', 'NotificationService', 'EncryptService', 'TagService', 'FileService', 'ShareService',
function ($scope, $rootScope, $location, VaultService, CredentialService, SettingsService, NotificationService, EncryptService, TagService, FileService, ShareService) {
.controller('BookmarkletCtrl', ['$scope', '$rootScope', '$location', 'VaultService', 'CredentialService', 'SettingsService', 'NotificationService', 'EncryptService', 'TagService', 'FileService', 'ShareService', '$translate',
function ($scope, $rootScope, $location, VaultService, CredentialService, SettingsService, NotificationService, EncryptService, TagService, FileService, ShareService, $translate) {
$scope.active_vault = false;
$scope.http_warning_hidden = true;
@ -114,7 +114,9 @@
var key_size = 1024;
ShareService.generateRSAKeys(key_size).progress(function (progress) {
var p = progress > 0 ? 2 : 1;
$scope.creating_keys = 'Generating sharing keys (' + p + ' / 2)';
var msg = $translate.instant('generating.sharing.keys');
msg = msg.replace('%step', p);
$scope.creating_keys = msg;
$scope.$digest();
}).then(function (kp) {
var pem = ShareService.rsaKeyPairToPEM(kp);
@ -149,7 +151,7 @@
_loginToVault(vault, vault_key);
} catch (e) {
$scope.error = 'Incorrect vault password!';
$scope.error = $translate.instant('invalid.vault.key');
}
};
@ -157,7 +159,7 @@
$scope.createVault = function (vault_name, vault_key, vault_key2) {
if (vault_key !== vault_key2) {
$scope.error = 'Passwords do not match';
$scope.error = $translate.instant('password.do.not.match');
return;
}
VaultService.createVault(vault_name).then(function (vault) {
@ -217,29 +219,29 @@
};
$scope.currentTab = {
title: 'General',
title: $translate.instant('general'),
url: 'views/partials/forms/edit_credential/basics.html',
color: 'blue'
};
$scope.tabs = [{
title: 'General',
title: $translate.instant('general'),
url: 'views/partials/forms/edit_credential/basics.html',
color: 'blue'
}, {
title: 'Password',
title: $translate.instant('password'),
url: 'views/partials/forms/edit_credential/password.html',
color: 'green'
}, {
title: 'Custom fields',
title: $translate.instant('custom.fields'),
url: 'views/partials/forms/edit_credential/custom_fields.html',
color: 'orange'
}, {
title: 'Files',
title: $translate.instant('files'),
url: 'views/partials/forms/edit_credential/files.html',
color: 'yellow'
}, {
title: 'OTP',
title: $translate.instant('otp'),
url: 'views/partials/forms/edit_credential/otp.html',
color: 'purple'
}];
@ -249,11 +251,6 @@
return TagService.searchTag($query);
};
$scope.currentTab = {
title: 'General',
url: 'views/partials/forms/edit_credential/basics.html',
color: 'blue'
};
$scope.onClickTab = function (tab) {
$scope.currentTab = tab;
@ -284,10 +281,10 @@
var _field = angular.copy($scope.new_custom_field);
if (!_field.label) {
NotificationService.showNotification('Please fill in a label', 3000);
NotificationService.showNotification($translate.instant('error.no.label'), 3000);
}
if (!_field.value) {
NotificationService.showNotification('Please fill in a value!', 3000);
NotificationService.showNotification($translate.instant('error.no.value'), 3000);
}
if (!_field.label || !_field.value) {
return;
@ -363,7 +360,7 @@
};
$scope.fileLoadError = function (error) {
console.log('Error loading file', error);
console.log($translate.instant('error.loading.file'), error);
};
$scope.selected_file = '';
@ -409,7 +406,7 @@
$scope.storedCredential.vault_id = $scope.active_vault.vault_id;
CredentialService.createCredential($scope.storedCredential).then(function () {
NotificationService.showNotification('Credential created!', 5000);
NotificationService.showNotification($translate.instant('credential.created'), 5000);
});
}
};

View file

@ -33,8 +33,8 @@
*/
angular.module('passmanApp')
.controller('CredentialCtrl', ['$scope', 'VaultService', 'SettingsService', '$location', 'CredentialService',
'$rootScope', 'FileService', 'EncryptService', 'TagService', '$timeout', 'NotificationService', 'CacheService', 'ShareService', 'SharingACL', '$interval', '$filter', '$routeParams', '$sce',
function ($scope, VaultService, SettingsService, $location, CredentialService, $rootScope, FileService, EncryptService, TagService, $timeout, NotificationService, CacheService, ShareService, SharingACL, $interval, $filter, $routeParams, $sce) {
'$rootScope', 'FileService', 'EncryptService', 'TagService', '$timeout', 'NotificationService', 'CacheService', 'ShareService', 'SharingACL', '$interval', '$filter', '$routeParams', '$sce', '$translate',
function ($scope, VaultService, SettingsService, $location, CredentialService, $rootScope, FileService, EncryptService, TagService, $timeout, NotificationService, CacheService, ShareService, SharingACL, $interval, $filter, $routeParams, $sce, $translate) {
$scope.active_vault = VaultService.getActiveVault();
if (!SettingsService.getSetting('defaultVault') || !SettingsService.getSetting('defaultVaultPass')) {
if (!$scope.active_vault) {
@ -71,7 +71,8 @@
}
_credential.tags_raw = _credential.tags;
} catch (e) {
NotificationService.showNotification('An error happend during decryption', 5000);
NotificationService.showNotification($translate.instant('error.decrypt'), 5000);
//$rootScope.$broadcast('logout');
//SettingsService.setSetting('defaultVaultPass', null);
//.setSetting('defaultVault', null);
@ -239,7 +240,7 @@
if (notification) {
NotificationService.hideNotification(notification);
}
notification = NotificationService.showNotification('Credential deleted', 5000,
notification = NotificationService.showNotification($translate.instant('credential.deleted'), 5000,
function () {
CredentialService.updateCredential(_credential).then(function (result) {
if (result.delete_time > 0) {
@ -268,7 +269,7 @@
if (notification) {
NotificationService.hideNotification(notification);
}
NotificationService.showNotification('Credential recovered', 5000,
NotificationService.showNotification($translate.instant('credential.recovered'), 5000,
function () {
CredentialService.updateCredential(_credential).then(function () {
notification = false;
@ -284,7 +285,7 @@
for (var i = 0; i < $scope.active_vault.credentials.length; i++) {
if ($scope.active_vault.credentials[i].credential_id === credential.credential_id) {
$scope.active_vault.credentials.splice(i, 1);
NotificationService.showNotification('Credential destroyed', 5000);
NotificationService.showNotification($translate.instant('credential.destroyed)'), 5000);
break;
}
}
@ -389,7 +390,7 @@
var callback = function (result) {
var key = null;
if (!result.hasOwnProperty('file_data')) {
NotificationService.showNotification('Error downloading file, you probably don\'t have enough permissions', 5000);
NotificationService.showNotification($translate.instant('error.loading.file.perm'), 5000);
return;
}

View file

@ -32,8 +32,8 @@
* Controller of the passmanApp
*/
angular.module('passmanApp')
.controller('CredentialEditCtrl', ['$scope', 'VaultService', 'CredentialService', 'SettingsService', '$location', '$routeParams', 'FileService', 'EncryptService', 'TagService', 'NotificationService', 'ShareService',
function ($scope, VaultService, CredentialService, SettingsService, $location, $routeParams, FileService, EncryptService, TagService, NotificationService, ShareService) {
.controller('CredentialEditCtrl', ['$scope', 'VaultService', 'CredentialService', 'SettingsService', '$location', '$routeParams', 'FileService', 'EncryptService', 'TagService', 'NotificationService', 'ShareService', '$translate',
function ($scope, VaultService, CredentialService, SettingsService, $location, $routeParams, FileService, EncryptService, TagService, NotificationService, ShareService, $translate) {
$scope.active_vault = VaultService.getActiveVault();
if (!SettingsService.getSetting('defaultVault') || !SettingsService.getSetting('defaultVaultPass')) {
if (!$scope.active_vault) {
@ -67,29 +67,34 @@
});
});
$scope.currentTab = {
title: $translate.instant('general'),
url: 'views/partials/forms/edit_credential/basics.html',
color: 'blue'
};
$scope.tabs = [{
title: 'General',
title: $translate.instant('general'),
url: 'views/partials/forms/edit_credential/basics.html',
color: 'blue'
}, {
title: 'Password',
title: $translate.instant('password'),
url: 'views/partials/forms/edit_credential/password.html',
color: 'green'
}, {
title: 'Custom fields',
title: $translate.instant('custom.fields'),
url: 'views/partials/forms/edit_credential/custom_fields.html',
color: 'orange'
}, {
title: 'Files',
title: $translate.instant('files'),
url: 'views/partials/forms/edit_credential/files.html',
color: 'yellow'
}, {
title: 'OTP',
title: $translate.instant('otp'),
url: 'views/partials/forms/edit_credential/otp.html',
color: 'purple'
}];
if ($scope.active_vault) {
$scope.$parent.selectedVault = true;
}
@ -109,11 +114,6 @@
return TagService.searchTag($query);
};
$scope.currentTab = {
title: 'General',
url: 'views/partials/forms/edit_credential/basics.html',
color: 'blue'
};
$scope.onClickTab = function (tab) {
$scope.currentTab = tab;
@ -145,10 +145,10 @@
var _field = angular.copy($scope.new_custom_field);
if (!_field.label) {
NotificationService.showNotification('Please fill in a label', 3000);
NotificationService.showNotification($translate.instant('error.no.label'), 3000);
}
if (!_field.value) {
NotificationService.showNotification('Please fill in a value!', 3000);
NotificationService.showNotification($translate.instant('error.no.value'), 3000);
}
if (!_field.label || !_field.value) {
return;
@ -250,7 +250,7 @@
};
$scope.fileLoadError = function (error) {
console.log('Error loading file', error);
console.log($translate.instant('error.loading.file'), error);
};
$scope.selected_file = '';
@ -304,7 +304,7 @@
$scope.storedCredential.vault_id = $scope.active_vault.vault_id;
CredentialService.createCredential($scope.storedCredential).then(function () {
$location.path('/vault/' + $routeParams.vault_id);
NotificationService.showNotification('Credential created!', 5000);
NotificationService.showNotification($translate.instant('credential.created'), 5000);
});
} else {
@ -335,7 +335,7 @@
CredentialService.updateCredential(_credential, _useKey).then(function () {
SettingsService.setSetting('edit_credential', null);
$location.path('/vault/' + $routeParams.vault_id);
NotificationService.showNotification('Credential updated!', 5000);
NotificationService.showNotification($translate.instant('credential.updated'), 5000);
});
}

View file

@ -31,7 +31,7 @@
* Controller of the passmanApp
*/
angular.module('passmanApp')
.controller('ExportCtrl', ['$scope', '$window', 'CredentialService', 'VaultService', function ($scope, $window, CredentialService, VaultService) {
.controller('ExportCtrl', ['$scope', '$window', 'CredentialService', 'VaultService', '$translate', function ($scope, $window, CredentialService, VaultService, $translate) {
$scope.available_exporters = [];
$scope.active_vault = VaultService.getActiveVault();
@ -58,10 +58,10 @@
$scope.startExport = function () {
_log('Starting export');
_log($translate.instant('export.starting'));
var _credentials = [];
VaultService.getVault(VaultService.getActiveVault()).then(function (vault) {
_log('Decrypting credentials');
_log($translate.instant('export.decrypt'));
if (vault.hasOwnProperty('credentials')) {
if (vault.credentials.length > 0) {
for (var i = 0; i < vault.credentials.length; i++) {
@ -72,7 +72,7 @@
}
}
$window.PassmanExporter[$scope.selectedExporter.id].export(_credentials).then(function () {
_log('Done');
_log($translate.instant('done'));
});
}

View file

@ -31,7 +31,7 @@
* Controller of the passmanApp
*/
angular.module('passmanApp')
.controller('ImportCtrl', ['$scope', '$window', 'CredentialService', 'VaultService', function ($scope, $window, CredentialService, VaultService) {
.controller('ImportCtrl', ['$scope', '$window', 'CredentialService', 'VaultService', '$translate', function ($scope, $window, CredentialService, VaultService, $translate) {
$scope.available_importers = [];
$scope.active_vault = VaultService.getActiveVault();
@ -59,12 +59,12 @@
$scope.fileLoaded = function (file) {
file_data = file.data.split(',');
file_data = decodeURIComponent(escape(window.atob(file_data[1]))); //window.atob();
_log('File read successfully!');
_log($translate.instant('import.file.read'));
$scope.$digest();
};
$scope.fileLoadError = function (file) {
console.error('Error loading file', file);
console.error($translate.instant('error.loading.file'), file);
};
$scope.fileSelectProgress = function () {
@ -84,16 +84,16 @@
var _credential = parsed_data[parsed_data_index];
if (!_credential.label) {
if (parsed_data[parsed_data_index + 1]) {
_log('Credential has no label, skipping');
_log($translate.instant('import.no.label'));
addCredential(parsed_data_index + 1);
}
return;
}
_log('Adding ' + _credential.label);
_log($translate.instant('import.adding').replace('{{credential}}', _credential.label));
_credential.vault_id = $scope.active_vault.vault_id;
CredentialService.createCredential(_credential).then(function (result) {
if (result.credential_id) {
_log('Added ' + _credential.label);
_log($translate.instant('import.added').replace('{{credential}}', _credential.label));
if (parsed_data[parsed_data_index + 1]) {
$scope.import_progress = {
progress: parsed_data_index / parsed_data.length * 100,
@ -108,7 +108,7 @@
loaded: parsed_data.length,
total: parsed_data.length
};
_log('DONE!');
_log($translate.instant('done'));
}
}
});
@ -133,7 +133,8 @@
loaded: parsed_data.length,
total: parsed_data.length
};
_log('Parsed ' + parsed_data.length + ' credentials, starting to import');
var msg = $translate.instant('import.loaded').replace('{{num}}', parsed_data.length);
_log(msg);
if (parsed_data.length > 0) {
addCredential(0);
} else {

View file

@ -31,7 +31,7 @@
* Controller of the passmanApp
*/
angular.module('passmanApp')
.controller('PublicSharedCredential', ['$scope', 'ShareService', '$window', 'EncryptService', 'NotificationService', function ($scope, ShareService, $window, EncryptService, NotificationService) {
.controller('PublicSharedCredential', ['$scope', 'ShareService', '$window', 'EncryptService', 'NotificationService', '$translate', function ($scope, ShareService, $window, EncryptService, NotificationService, $translate) {
var _key;
$scope.loading = false;
$scope.loadSharedCredential = function () {
@ -54,7 +54,7 @@
$scope.downloadFile = function (credential, file) {
ShareService.downloadSharedFile(credential, file).then(function (result) {
if (!result.hasOwnProperty('file_data')) {
NotificationService.showNotification('Error downloading file, you probably don\'t have enough permissions', 5000);
NotificationService.showNotification($translate.instant('error.loading.file.perm'), 5000);
return;
}
var file_data = EncryptService.decryptString(result.file_data, _key);

View file

@ -32,8 +32,8 @@
* Controller of the passmanApp
*/
angular.module('passmanApp')
.controller('RevisionCtrl', ['$scope', 'SettingsService', 'VaultService', 'CredentialService', '$location', '$routeParams', '$rootScope', 'NotificationService', '$filter', 'ShareService', 'EncryptService',
function ($scope, SettingsService, VaultService, CredentialService, $location, $routeParams, $rootScope, NotificationService, $filter, ShareService, EncryptService) {
.controller('RevisionCtrl', ['$scope', 'SettingsService', 'VaultService', 'CredentialService', '$location', '$routeParams', '$rootScope', 'NotificationService', '$filter', 'ShareService', 'EncryptService', '$translate',
function ($scope, SettingsService, VaultService, CredentialService, $location, $routeParams, $rootScope, NotificationService, $filter, ShareService, EncryptService, $translate) {
$scope.active_vault = VaultService.getActiveVault();
if (!SettingsService.getSetting('defaultVault') || !SettingsService.getSetting('defaultVaultPass')) {
if (!$scope.active_vault) {
@ -106,7 +106,7 @@
for (var i = 0; i < $scope.revisions.length; i++) {
if ($scope.revisions[i].revision_id === revision.revision_id) {
$scope.revisions.splice(i, 1);
NotificationService.showNotification('Revision deleted', 5000);
NotificationService.showNotification($translate.instant('revision.deleted'), 5000);
break;
}
}
@ -137,7 +137,7 @@
SettingsService.setSetting('revision_credential', null);
$rootScope.$emit('app_menu', false);
$location.path('/vault/' + $routeParams.vault_id);
NotificationService.showNotification('Revision restored!', 5000);
NotificationService.showNotification($translate.instant('revision.restored'), 5000);
});
};

View file

@ -32,8 +32,8 @@
* Controller of the passmanApp
*/
angular.module('passmanApp')
.controller('SettingsCtrl', ['$scope', '$rootScope', 'SettingsService', 'VaultService', 'CredentialService', '$location', '$routeParams', '$http', 'EncryptService', 'NotificationService', '$sce',
function ($scope, $rootScope, SettingsService, VaultService, CredentialService, $location, $routeParams, $http, EncryptService, NotificationService, $sce) {
.controller('SettingsCtrl', ['$scope', '$rootScope', 'SettingsService', 'VaultService', 'CredentialService', '$location', '$routeParams', '$http', 'EncryptService', 'NotificationService', '$sce', '$translate',
function ($scope, $rootScope, SettingsService, VaultService, CredentialService, $location, $routeParams, $http, EncryptService, NotificationService, $sce, $translate) {
$scope.vault_settings = {};
$scope.new_vault_name = '';
$scope.active_vault = VaultService.getActiveVault();
@ -72,9 +72,9 @@
});
var btn_txt = $translate.instant('bookmarklet.text');
var http = location.protocol, slashes = http.concat("//"), host = slashes.concat(window.location.hostname), complete = host + location.pathname;
$scope.bookmarklet = $sce.trustAsHtml("<a class=\"button\" href=\"javascript:(function(){var a=window,b=document,c=encodeURIComponent,e=c(document.title),d=a.open('" + complete + "bookmarklet?url='+c(b.location)+'&title='+e,'bkmk_popup','left='+((a.screenX||a.screenLeft)+10)+',top='+((a.screenY||a.screenTop)+10)+',height=750px,width=475px,resizable=0,alwaysRaised=1');a.setTimeout(function(){d.focus()},300);})();\">Save in passman</a>");
$scope.bookmarklet = $sce.trustAsHtml("<a class=\"button\" href=\"javascript:(function(){var a=window,b=document,c=encodeURIComponent,e=c(document.title),d=a.open('" + complete + "bookmarklet?url='+c(b.location)+'&title='+e,'bkmk_popup','left='+((a.screenX||a.screenLeft)+10)+',top='+((a.screenY||a.screenTop)+10)+',height=750px,width=475px,resizable=0,alwaysRaised=1');a.setTimeout(function(){d.focus()},300);})();\">"+ btn_txt +"</a>");
$scope.saveVaultSettings = function () {
@ -84,38 +84,38 @@
VaultService.updateVault(_vault).then(function () {
//VaultService.setActiveVault(_vault);
$scope.active_vault.name = angular.copy(_vault.name);
NotificationService.showNotification('Settings saved', 5000);
NotificationService.showNotification($translate.instant('settings.saved'), 5000);
});
};
$scope.tabs = [
{
title: 'General settings',
title: $translate.instant('settings.general'),
url: 'views/partials/forms/settings/general_settings.html'
},
{
title: 'Password Audit',
title: $translate.instant('settings.audit'),
url: 'views/partials/forms/settings/tool.html'
},
{
title: 'Password settings',
title:$translate.instant('settings.password'),
url: 'views/partials/forms/settings/password_settings.html'
},
{
title: 'Import credentials',
title: $translate.instant('settings.import'),
url: 'views/partials/forms/settings/import.html'
},
{
title: 'Export credentials',
title: $translate.instant('settings.export'),
url: 'views/partials/forms/settings/export.html'
},
{
title: 'Sharing',
title: $translate.instant('settings.sharing'),
url: 'views/partials/forms/settings/sharing.html'
}
];
@ -186,7 +186,7 @@
$scope.$on("$locationChangeStart", function(event) {
if($scope.change_pw){
if($scope.change_pw.total > 0 && $scope.change_pw.done < $scope.change_pw.total){
if(!confirm("Are you sure you want to leave?\nThis will corrupt all your credentials")){
if(!confirm($translate.instant('changepw.navigate.away.warning'))){
event.preventDefault();
}
}
@ -196,11 +196,11 @@
$scope.changeVaultPassword = function (oldVaultPass, newVaultPass, newVaultPass2) {
if (oldVaultPass !== VaultService.getActiveVault().vaultKey) {
$scope.error = 'Your old password is incorrect!';
$scope.error = $translate.instant('incorrect.password');
return;
}
if (newVaultPass !== newVaultPass2) {
$scope.error = 'New passwords do not match!';
$scope.error = $translate.instant('password.no.match');
return;
}
VaultService.getVault($scope.active_vault).then(function (vault) {
@ -236,7 +236,7 @@
vault.private_sharing_key = EncryptService.encryptString(vault.private_sharing_key, newVaultPass);
VaultService.updateSharingKeys(vault).then(function () {
$rootScope.$broadcast('logout');
NotificationService.showNotification('Please login with your new vault password', 5000);
NotificationService.showNotification($translate.instant('login.new.pass'), 5000);
});
}
});

View file

@ -32,22 +32,19 @@
* This file is part of passman, licensed under AGPLv3
*/
angular.module('passmanApp')
.controller('ShareCtrl', ['$scope', 'VaultService', 'CredentialService', 'SettingsService', '$location', '$routeParams', 'ShareService', 'NotificationService', 'SharingACL', 'EncryptService',
function ($scope, VaultService, CredentialService, SettingsService, $location, $routeParams, ShareService, NotificationService, SharingACL, EncryptService) {
.controller('ShareCtrl', ['$scope', 'VaultService', 'CredentialService', 'SettingsService', '$location', '$routeParams', 'ShareService', 'NotificationService', 'SharingACL', 'EncryptService', '$translate',
function ($scope, VaultService, CredentialService, SettingsService, $location, $routeParams, ShareService, NotificationService, SharingACL, EncryptService, $translate) {
$scope.active_vault = VaultService.getActiveVault();
$scope.tabs = [{
title: 'Share with users and groups',
title: $translate.instant('share.u.g'),
url: 'views/partials/forms/share_credential/basics.html'
}, {
title: 'Share link',
title: $translate.instant('share.link'),
url: 'views/partials/forms/share_credential/link_sharing.html',
color: 'green'
}];
$scope.currentTab = {
title: 'General',
url: 'views/partials/forms/share_credential/basics.html'
};
$scope.currentTab = $scope.tabs[0];
$scope.onClickTab = function (tab) {
$scope.currentTab = tab;
@ -224,7 +221,7 @@
_credential = CredentialService.encryptCredential(_credential, old_key);
CredentialService.updateCredential(_credential, true).then(function () {
NotificationService.showNotification('Credential unshared', 4000);
NotificationService.showNotification($translate.instant('credential.unshared'), 4000);
CredentialService.reencryptCredential(_credential.guid, old_key, new_key).then(function () {
getAcl();
});
@ -266,7 +263,7 @@
$scope.$on("$locationChangeStart", function(event) {
if(!$scope.sharing_complete){
if(!confirm("Are you sure you want to leave?\nThis will corrupt this credential")){
if(!confirm($translate.instant('share.navigate.away.warning'))){
event.preventDefault();
}
}
@ -322,7 +319,7 @@
$scope.applyShareToUser(list[iterator], enc_key);
}
}
NotificationService.showNotification('Saved!', 4000);
NotificationService.showNotification($translate.instant('saved'), 4000);
$scope.sharing_complete = true;
} else {
@ -338,7 +335,7 @@
_credential.skip_revision = true;
_credential.shared_key = EncryptService.encryptString(key);
CredentialService.updateCredential(_credential, true).then(function () {
NotificationService.showNotification('Credential shared', 4000);
NotificationService.showNotification($translate.instant('credential.shared'), 4000);
$scope.sharing_complete = true;
});
});

View file

@ -31,7 +31,7 @@
* Controller of the passmanApp
*/
angular.module('passmanApp')
.controller('VaultCtrl', ['$scope', 'VaultService', 'SettingsService', 'CredentialService', '$location', 'ShareService', 'EncryptService', function ($scope, VaultService, SettingsService, CredentialService, $location, ShareService, EncryptService) {
.controller('VaultCtrl', ['$scope', 'VaultService', 'SettingsService', 'CredentialService', '$location', 'ShareService', 'EncryptService', '$translate', function ($scope, VaultService, SettingsService, CredentialService, $location, ShareService, EncryptService, $translate) {
VaultService.getVaults().then(function (vaults) {
$scope.vaults = vaults;
if (SettingsService.getSetting('defaultVault') != null) {
@ -96,7 +96,9 @@
var key_size = 1024;
ShareService.generateRSAKeys(key_size).progress(function (progress) {
var p = progress > 0 ? 2 : 1;
$scope.creating_keys = 'Generating sharing keys (' + p + ' / 2)';
var msg = $translate.instant('generating.sharing.keys');
msg = msg.replace('%step', p);
$scope.creating_keys = msg;
$scope.$digest();
}).then(function (kp) {
var pem = ShareService.rsaKeyPairToPEM(kp);
@ -131,7 +133,7 @@
_loginToVault(vault, vault_key);
} catch (e) {
$scope.error = 'Incorrect vault password!';
$scope.error = $translate.instant('invalid.vault.key')
}
};
@ -139,7 +141,7 @@
$scope.createVault = function (vault_name, vault_key, vault_key2) {
if (vault_key !== vault_key2) {
$scope.error = 'Passwords do not match';
$scope.error = $translate.instant('password.do.not.match');
return;
}
VaultService.createVault(vault_name).then(function (vault) {

View file

@ -30,7 +30,7 @@
*/
angular.module('passmanApp')
.directive('credentialField', ['$timeout', function ($timeout) {
.directive('credentialField', ['$timeout', '$translate', function ($timeout, $translate) {
return {
scope: {
value: '=value',
@ -45,13 +45,17 @@
'<span ng-if="valueVisible">{{value}}</span>' +
'</div>' +
'<div class="tools">' +
'<div class="cell" ng-if="toggle" tooltip="\'Toggle visibility\'" ng-click="toggleVisibility()"><i class="fa" ng-class="{\'fa-eye\': !valueVisible, \'fa-eye-slash\': valueVisible }"></i></div>' +
'<div class="cell" ng-if="toggle" tooltip="tggltxt" ng-click="toggleVisibility()"><i class="fa" ng-class="{\'fa-eye\': !valueVisible, \'fa-eye-slash\': valueVisible }"></i></div>' +
'<div class="cell" ng-if="isLink"><a ng-href="{{value}}" target="_blank"><i tooltip="\'Open in new window\'" class="link fa fa-external-link"></i></a></div>' +
'<div class="cell" ngclipboard-success="onSuccess(e);" ngclipboard-error="onError(e);" ngclipboard data-clipboard-text="{{value}}"><i tooltip="copy_msg" class="fa fa-clipboard"></i></div>' +
'</div></span>',
link: function (scope) {
var expression = /(https?:\/\/(?:www\.|(?!www))[^\s\.]+\.[^\s]{2,}|www\.[^\s]+\.[^\s]{2,})/gi;
var regex = new RegExp(expression);
$translate(['toggle.visibility', 'copy', 'copied']).then(function (translations) {
scope.tggltxt = translations['toggle.visibility'];
scope.copy_msg = translations['copy'];
});
scope.$watch("value", function () {
if (scope.value) {
@ -69,13 +73,13 @@
scope.toggle = true;
}
}
scope.copy_msg = 'Copy to clipboard';
var timer;
scope.onSuccess = function () {
scope.copy_msg = 'Copied to clipboard!';
scope.copy_msg = $translate.instant('copied') ;
$timeout.cancel(timer);
timer = $timeout(function () {
scope.copy_msg = 'Copy to clipboard';
scope.copy_msg = $translate.instant('copy');
}, 5000);
};
scope.valueVisible = true;

View file

@ -31,7 +31,7 @@
*/
angular.module('passmanApp')
.directive('passwordGen', function ($timeout) {
.directive('passwordGen', function ($timeout, $translate) {
/* jshint ignore:start */
function Arcfour () {
this.j = this.i = 0, this.S = []
@ -152,8 +152,8 @@
"<input ng-show=\"passwordVisible\" type=\"text\" ng-disabled=\"disabled\" class=\"form-control \" ng-model=\"password\" placeholder=\"{{placeholder}}\">" +
'<span class="generate_pw">' +
'<div class="cell" tooltip="\'Generate password\'" ng-click="generatePasswordStart()"><i class="fa fa-refresh"></i></div>' +
'<div class="cell" tooltip="\'Toggle password visibility\'" ng-click="toggleVisibility()"><i class="fa" ng-class="{\'fa-eye\': passwordVisible, \'fa-eye-slash\': !passwordVisible }"></i></div>' +
'<div class="cell" tooltip="gen_msg" ng-click="generatePasswordStart()"><i class="fa fa-refresh"></i></div>' +
'<div class="cell" tooltip="tggltxt" ng-click="toggleVisibility()"><i class="fa" ng-class="{\'fa-eye\': passwordVisible, \'fa-eye-slash\': !passwordVisible }"></i></div>' +
'<div class="cell" tooltip="\'Copy password to clipboard\'"><i class="fa fa-clipboard" ngclipboard-success="onSuccess(e);" ngclipboard-error="onError(e);" ngclipboard data-clipboard-text="{{password}}"></i></div>' +
"</button>" +
"</div>" +
@ -177,6 +177,11 @@
}
});
$translate(['password.gen', 'password.copy', 'copied', 'toggle.visibility']).then(function (translations) {
scope.tggltxt = translations['toggle.visibility'];
scope.copy_msg = translations['password.copy'];
scope.gen_msg = translations['password.gen'];
});
scope.$watch("password", function () {
scope.model = scope.password;
@ -185,7 +190,7 @@
//
scope.onSuccess = function (e) {
//@TODO move OC.Notification to a service
OC.Notification.showTemporary('Password copied to clipboard!');
OC.Notification.showTemporary($translate.instant('password.copied'));
e.clearSelection();
};

View file

@ -29,13 +29,13 @@
* # passwordGen
*/
angular.module('passmanApp')
.directive('progressBar', [function () {
.directive('progressBar', [function ($translate) {
return {
restrict: 'A',
template: '' +
'<div class="progress">' +
'<div class="progress-bar" role="progressbar" aria-valuenow="{{progress}}"aria-valuemin="0" aria-valuemax="100" style="width:{{progress}}%;" use-theme>' +
'<span class="sr-only">{{progress}}% Complete</span>' +
'<span class="sr-only">{{progress}}% {{completed_text}}</span>' +
'<span ng-if="index && total" class="progress-label" use-theme type="\'color\'" color="\'true\'">{{index}} / {{total}}</span>' +
'<span ng-if="!index && !total" class="progress-label" use-theme type="\'color\'" color="\'true\'">{{progress}}%</span>' +
'</div>' +
@ -47,7 +47,9 @@
},
link: function () {
$translate(['complete']).then(function (translations) {
$scope.completed_text = translations['complete'];
})
}
};
}]);

View file

@ -31,12 +31,11 @@ use PHPUnit_Framework_TestCase;
* Class PageControllerTest
*
* @package OCA\Passman\Controller
* @coversDefaultClass \OCA\Passman\Controller\PageController
* @coversDefaultClass \OCA\Passman\Controller\TranslationController
*/
class TranslationControllerTest extends PHPUnit_Framework_TestCase {
private $controller;
private $userId = 'john';
public function setUp() {
$request = $this->getMockBuilder('OCP\IRequest')->getMock();