diff --git a/docs-web/src/main/webapp/src/app/docs/app.js b/docs-web/src/main/webapp/src/app/docs/app.js index 62df4bb1..2faed855 100644 --- a/docs-web/src/main/webapp/src/app/docs/app.js +++ b/docs-web/src/main/webapp/src/app/docs/app.js @@ -6,13 +6,13 @@ angular.module('docs', // Dependencies ['ui.router', 'ui.route', 'ui.bootstrap', 'ui.keypress', 'ui.validate', 'dialog', 'ngProgress', 'monospaced.qrcode', - 'ui.sortable', 'restangular', 'ngSanitize', 'ngTouch', 'colorpicker.module', 'angularFileUpload'] + 'ui.sortable', 'restangular', 'ngSanitize', 'ngTouch', 'colorpicker.module', 'angularFileUpload', 'pascalprecht.translate'] ) /** * Configuring modules. */ -.config(function($stateProvider, $httpProvider, RestangularProvider) { +.config(function($stateProvider, $httpProvider, RestangularProvider, $translateProvider) { // Configuring UI Router $stateProvider .state('main', { @@ -334,9 +334,25 @@ angular.module('docs', } } }); + // Configuring Restangular RestangularProvider.setBaseUrl('../api'); - + + // Configuring Angular Translate + $translateProvider + .useSanitizeValueStrategy(null) + .useStaticFilesLoader({ + prefix: 'locale/', + suffix: '.json' + }) + .registerAvailableLanguageKeys(['en', 'fr'], { + 'en_*': 'en', + 'fr_*': 'fr', + '*': 'en' + }) + .determinePreferredLanguage() + .fallbackLanguage('en'); + // Configuring $http to act like jQuery.ajax $httpProvider.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=utf-8'; $httpProvider.defaults.headers.put['Content-Type'] = 'application/x-www-form-urlencoded;charset=utf-8'; diff --git a/docs-web/src/main/webapp/src/app/docs/controller/Login.js b/docs-web/src/main/webapp/src/app/docs/controller/Login.js index 28faf4bf..743d1dcf 100644 --- a/docs-web/src/main/webapp/src/app/docs/controller/Login.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/Login.js @@ -3,7 +3,7 @@ /** * Login controller. */ -angular.module('docs').controller('Login', function(Restangular, $scope, $rootScope, $state, $dialog, User) { +angular.module('docs').controller('Login', function(Restangular, $scope, $rootScope, $state, $dialog, User, $translate) { $scope.codeRequired = false; // Get the app configuration @@ -33,9 +33,9 @@ angular.module('docs').controller('Login', function(Restangular, $scope, $rootSc $scope.codeRequired = true; } else { // Login truly failed - var title = 'Login failed'; - var msg = 'Username or password invalid'; - var btns = [{result: 'ok', label: 'OK', cssClass: 'btn-primary'}]; + var title = $translate.instant('login.login_failed_title'); + var msg = $translate.instant('login.login_failed_message'); + var btns = [{result: 'ok', label: $translate.instant('ok'), cssClass: 'btn-primary'}]; $dialog.messageBox(title, msg, btns); } }); diff --git a/docs-web/src/main/webapp/src/app/docs/controller/document/DocumentDefault.js b/docs-web/src/main/webapp/src/app/docs/controller/document/DocumentDefault.js index 6d9c7715..e093f02c 100644 --- a/docs-web/src/main/webapp/src/app/docs/controller/document/DocumentDefault.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/document/DocumentDefault.js @@ -3,7 +3,7 @@ /** * Document default controller. */ -angular.module('docs').controller('DocumentDefault', function($scope, $rootScope, $state, Restangular, $upload) { +angular.module('docs').controller('DocumentDefault', function($scope, $rootScope, $state, Restangular, $upload, $translate) { // Load app data Restangular.one('app').get().then(function(data) { $scope.app = data; @@ -39,7 +39,7 @@ angular.module('docs').controller('DocumentDefault', function($scope, $rootScope name: file.name, create_date: new Date().getTime(), mimetype: file.type, - status: 'Pending...' + status: $translate.instant('document.default.upload_pending') }; $scope.files.push(newfile); newfiles.push(newfile); @@ -63,7 +63,7 @@ angular.module('docs').controller('DocumentDefault', function($scope, $rootScope */ $scope.uploadFile = function(file, newfile) { // Upload the file - newfile.status = 'Uploading...'; + newfile.status = $translate.instant('document.default.upload_progress'); return $upload.upload({ method: 'PUT', url: '../api/file', @@ -81,9 +81,9 @@ angular.module('docs').controller('DocumentDefault', function($scope, $rootScope $rootScope.userInfo.storage_current += data.size; }) .error(function (data) { - newfile.status = 'Upload error'; + newfile.status = $translate.instant('document.default.upload_error'); if (data.type == 'QuotaReached') { - newfile.status += ' - Quota reached'; + newfile.status += ' - ' + $translate.instant('document.default.upload_error_quota'); } }); }; diff --git a/docs-web/src/main/webapp/src/app/docs/controller/document/DocumentEdit.js b/docs-web/src/main/webapp/src/app/docs/controller/document/DocumentEdit.js index fa007e67..e00eabf5 100644 --- a/docs-web/src/main/webapp/src/app/docs/controller/document/DocumentEdit.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/document/DocumentEdit.js @@ -94,7 +94,6 @@ angular.module('docs').controller('DocumentEdit', function($rootScope, $scope, $ // Upload files after edition promise.then(function(data) { - console.log('document created, adding file', $scope.newFiles); $scope.fileProgress = 0; // When all files upload are over, attach orphan files and move on @@ -122,7 +121,7 @@ angular.module('docs').controller('DocumentEdit', function($rootScope, $scope, $ navigateNext(); } else { $scope.fileIsUploading = true; - $rootScope.pageTitle = '0% - Sismics Docs'; + $rootScope.pageTitle = '0% - ' + $rootScope.appName; // Send a file from the input file array and return a promise var sendFile = function(key) { @@ -134,7 +133,6 @@ angular.module('docs').controller('DocumentEdit', function($rootScope, $scope, $ }; // Build the payload - console.log('sending file', key, $scope.newFiles[key], data); var file = $scope.newFiles[key]; var formData = new FormData(); formData.append('id', data.id); @@ -149,7 +147,6 @@ angular.module('docs').controller('DocumentEdit', function($rootScope, $scope, $ contentType: false, processData: false, success: function(response) { - console.log('file uploaded successfully', formData); deferred.resolve(response); }, error: function(jqXHR) { @@ -172,19 +169,19 @@ angular.module('docs').controller('DocumentEdit', function($rootScope, $scope, $ // Error uploading a file, we stop here $scope.alerts.unshift({ type: 'danger', - msg: 'Document successfully ' + ($scope.isEdit() ? 'edited' : 'added') + ' but some files cannot be uploaded' - + (data.responseJSON.type == 'QuotaReached' ? ' - Quota reached' : '') + msg: $translate.instant('document.edit.document_' + ($scope.isEdit() ? 'edited' : 'added') + '_with_errors') + + (data.responseJSON.type == 'QuotaReached' ? (' - ' + $translate.instant('document.edit.quota_reached')) : '') }); // Reset view and title $scope.fileIsUploading = false; $scope.fileProgress = 0; - $rootScope.pageTitle = 'Sismics Docs'; + $rootScope.pageTitle = $rootScope.appName; }, function(e) { var done = 1 - (e.total - e.loaded) / e.total; var chunk = 100 / _.size($scope.newFiles); $scope.fileProgress = startProgress + done * chunk; - $rootScope.pageTitle = Math.round($scope.fileProgress) + '% - Sismics Docs'; + $rootScope.pageTitle = Math.round($scope.fileProgress) + '% - ' + $rootScope.appName; }); return deferred.promise; @@ -195,13 +192,11 @@ angular.module('docs').controller('DocumentEdit', function($rootScope, $scope, $ var then = function() { key++; if ($scope.newFiles[key]) { - console.log('sending new file'); sendFile(key).then(then); } else { $scope.fileIsUploading = false; $scope.fileProgress = 0; - $rootScope.pageTitle = 'Sismics Docs'; - console.log('finished sending files, bye'); + $rootScope.pageTitle = $rootScope.appName; navigateNext(); } }; diff --git a/docs-web/src/main/webapp/src/app/docs/controller/document/DocumentView.js b/docs-web/src/main/webapp/src/app/docs/controller/document/DocumentView.js index 41281950..67a22779 100644 --- a/docs-web/src/main/webapp/src/app/docs/controller/document/DocumentView.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/document/DocumentView.js @@ -3,7 +3,7 @@ /** * Document view controller. */ -angular.module('docs').controller('DocumentView', function ($scope, $state, $stateParams, $location, $dialog, $modal, Restangular, $timeout) { +angular.module('docs').controller('DocumentView', function ($scope, $state, $stateParams, $location, $dialog, $modal, Restangular, $translate) { // Load document data from server Restangular.one('document', $stateParams.id).get().then(function(data) { $scope.document = data; @@ -40,11 +40,11 @@ angular.module('docs').controller('DocumentView', function ($scope, $state, $sta * Delete a comment. */ $scope.deleteComment = function(comment) { - var title = 'Delete comment'; - var msg = 'Do you really want to delete this comment?'; + var title = $translate.instant('document.view.delete_comment_title'); + var msg = $translate.instant('document.view.delete_comment_message'); var btns = [ - {result: 'cancel', label: 'Cancel'}, - {result: 'ok', label: 'OK', cssClass: 'btn-primary'} + {result: 'cancel', label: $translate.instant('cancel')}, + {result: 'ok', label: $translate.instant('ok'), cssClass: 'btn-primary'} ]; $dialog.messageBox(title, msg, btns, function (result) { @@ -60,11 +60,11 @@ angular.module('docs').controller('DocumentView', function ($scope, $state, $sta * Delete a document. */ $scope.deleteDocument = function (document) { - var title = 'Delete document'; - var msg = 'Do you really want to delete this document?'; + var title = $translate.instant('document.view.delete_document_title'); + var msg = $translate.instant('document.view.delete_document_message'); var btns = [ - {result: 'cancel', label: 'Cancel'}, - {result: 'ok', label: 'OK', cssClass: 'btn-primary'} + {result: 'cancel', label: $translate.instant('cancel')}, + {result: 'ok', label: $translate.instant('ok'), cssClass: 'btn-primary'} ]; $dialog.messageBox(title, msg, btns, function (result) { @@ -108,14 +108,11 @@ angular.module('docs').controller('DocumentView', function ($scope, $state, $sta $scope.showShare = function(share) { // Show the link var link = $location.absUrl().replace($location.path(), '').replace('#', '') + 'share.html#/share/' + $stateParams.id + '/' + share.id; - var title = 'Shared document'; - var msg = 'You can share this document by giving this link. ' + - 'Note that everyone having this link can see the document.
' + - ''; + var title = $translate.instant('document.view.shared_document_title'); + var msg = $translate.instant('document.view.shared_document_message', { link: link }); var btns = [ - {result: 'unshare', label: 'Unshare', cssClass: 'btn-danger'}, - {result: 'close', label: 'Close'} + {result: 'unshare', label: $translate.instant('unshare'), cssClass: 'btn-danger'}, + {result: 'close', label: $translate.instant('close')} ]; $dialog.messageBox(title, msg, btns, function (result) { diff --git a/docs-web/src/main/webapp/src/app/docs/controller/document/DocumentViewContent.js b/docs-web/src/main/webapp/src/app/docs/controller/document/DocumentViewContent.js index 6bddae9b..d6e456d9 100644 --- a/docs-web/src/main/webapp/src/app/docs/controller/document/DocumentViewContent.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/document/DocumentViewContent.js @@ -3,7 +3,7 @@ /** * Document view content controller. */ -angular.module('docs').controller('DocumentViewContent', function ($scope, $rootScope, $stateParams, Restangular, $dialog, $state, $upload) { +angular.module('docs').controller('DocumentViewContent', function ($scope, $rootScope, $stateParams, Restangular, $dialog, $state, $upload, $translate) { /** * Configuration for file sorting. */ @@ -45,11 +45,11 @@ angular.module('docs').controller('DocumentViewContent', function ($scope, $root * Delete a file. */ $scope.deleteFile = function (file) { - var title = 'Delete file'; - var msg = 'Do you really want to delete this file?'; + var title = $translate.instant('document.view.content.delete_file_title'); + var msg = $translate.instant('document.view.content.delete_file_message'); var btns = [ - {result: 'cancel', label: 'Cancel'}, - {result: 'ok', label: 'OK', cssClass: 'btn-primary'} + {result: 'cancel', label: $translate.instant('cancel')}, + {result: 'ok', label: $translate.instant('ok'), cssClass: 'btn-primary'} ]; $dialog.messageBox(title, msg, btns, function (result) { @@ -82,7 +82,7 @@ angular.module('docs').controller('DocumentViewContent', function ($scope, $root name: file.name, create_date: new Date().getTime(), mimetype: file.type, - status: 'Pending...' + status: $translate.instant('document.view.content.upload_pending') }; $scope.files.push(newfile); newfiles.push(newfile); @@ -104,7 +104,7 @@ angular.module('docs').controller('DocumentViewContent', function ($scope, $root */ $scope.uploadFile = function(file, newfile) { // Upload the file - newfile.status = 'Uploading...'; + newfile.status = $translate.instant('document.view.content.upload_progress'); return $upload.upload({ method: 'PUT', url: '../api/file', @@ -125,9 +125,9 @@ angular.module('docs').controller('DocumentViewContent', function ($scope, $root $rootScope.userInfo.storage_current += data.size; }) .error(function (data) { - newfile.status = 'Upload error'; + newfile.status = $translate.instant('document.view.content.upload_error'); if (data.type == 'QuotaReached') { - newfile.status += ' - Quota reached'; + newfile.status += ' - ' + $translate.instant('document.view.content.upload_error_quota'); } }); }; diff --git a/docs-web/src/main/webapp/src/app/docs/controller/settings/SettingsAccount.js b/docs-web/src/main/webapp/src/app/docs/controller/settings/SettingsAccount.js index d318c0e1..58d88bf4 100644 --- a/docs-web/src/main/webapp/src/app/docs/controller/settings/SettingsAccount.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/settings/SettingsAccount.js @@ -3,7 +3,7 @@ /** * Settings account controller. */ -angular.module('docs').controller('SettingsAccount', function($scope, Restangular) { +angular.module('docs').controller('SettingsAccount', function($scope, Restangular, $translate) { $scope.editUserAlert = false; // Alerts @@ -22,7 +22,7 @@ angular.module('docs').controller('SettingsAccount', function($scope, Restangula $scope.editUser = function() { Restangular.one('user').post('', $scope.user).then(function() { $scope.user = {}; - $scope.alerts.push({ type: 'success', msg: 'Account successfully updated' }); + $scope.alerts.push({ type: 'success', msg: $translate.instant('settings.account.updated') }); }); }; }); \ No newline at end of file diff --git a/docs-web/src/main/webapp/src/app/docs/controller/settings/SettingsGroupEdit.js b/docs-web/src/main/webapp/src/app/docs/controller/settings/SettingsGroupEdit.js index 0275288a..21db3000 100644 --- a/docs-web/src/main/webapp/src/app/docs/controller/settings/SettingsGroupEdit.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/settings/SettingsGroupEdit.js @@ -3,7 +3,7 @@ /** * Settings group edition page controller. */ -angular.module('docs').controller('SettingsGroupEdit', function($scope, $dialog, $state, $stateParams, Restangular, $q) { +angular.module('docs').controller('SettingsGroupEdit', function($scope, $dialog, $state, $stateParams, Restangular, $q, $translate) { /** * Returns true if in edit mode (false in add mode). */ @@ -52,9 +52,12 @@ angular.module('docs').controller('SettingsGroupEdit', function($scope, $dialog, * Delete the current group. */ $scope.remove = function() { - var title = 'Delete group'; - var msg = 'Do you really want to delete this group?'; - var btns = [{result:'cancel', label: 'Cancel'}, {result:'ok', label: 'OK', cssClass: 'btn-primary'}]; + var title = $translate.instant('settings.group.edit.delete_group_title'); + var msg = $translate.instant('settings.group.edit.delete_group_message'); + var btns = [ + { result:'cancel', label: $translate.instant('cancel') }, + { result:'ok', label: $translate.instant('ok'), cssClass: 'btn-primary' } + ]; $dialog.messageBox(title, msg, btns, function(result) { if (result == 'ok') { diff --git a/docs-web/src/main/webapp/src/app/docs/controller/settings/SettingsSecurity.js b/docs-web/src/main/webapp/src/app/docs/controller/settings/SettingsSecurity.js index 76037eb5..91d007c9 100644 --- a/docs-web/src/main/webapp/src/app/docs/controller/settings/SettingsSecurity.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/settings/SettingsSecurity.js @@ -3,7 +3,7 @@ /** * Settings security controller. */ -angular.module('docs').controller('SettingsSecurity', function($scope, User, $dialog, $modal, Restangular) { +angular.module('docs').controller('SettingsSecurity', function($scope, User, $dialog, $modal, Restangular, $translate) { User.userInfo().then(function(data) { $scope.user = data; }); @@ -12,9 +12,12 @@ angular.module('docs').controller('SettingsSecurity', function($scope, User, $di * Enable TOTP. */ $scope.enableTotp = function() { - var title = 'Enable two-factor authentication'; - var msg = 'Make sure you have a TOTP-compatible application on your phone ready to add a new account'; - var btns = [{result:'cancel', label: 'Cancel'}, {result:'ok', label: 'OK', cssClass: 'btn-primary'}]; + var title = $translate.instant('settings.security.enable_totp_title'); + var msg = $translate.instant('settings.security.enable_totp_message'); + var btns = [ + { result:'cancel', label: $translate.instant('cancel') }, + { result:'ok', label: $translate.instant('ok'), cssClass: 'btn-primary' } + ]; $dialog.messageBox(title, msg, btns, function(result) { if (result == 'ok') { diff --git a/docs-web/src/main/webapp/src/app/docs/controller/settings/SettingsUserEdit.js b/docs-web/src/main/webapp/src/app/docs/controller/settings/SettingsUserEdit.js index 599001ee..4655e99f 100644 --- a/docs-web/src/main/webapp/src/app/docs/controller/settings/SettingsUserEdit.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/settings/SettingsUserEdit.js @@ -3,7 +3,7 @@ /** * Settings user edition page controller. */ -angular.module('docs').controller('SettingsUserEdit', function($scope, $dialog, $state, $stateParams, Restangular) { +angular.module('docs').controller('SettingsUserEdit', function($scope, $dialog, $state, $stateParams, Restangular, $translate) { /** * Returns true if in edit mode (false in add mode). */ @@ -49,9 +49,12 @@ angular.module('docs').controller('SettingsUserEdit', function($scope, $dialog, * Delete the current user. */ $scope.remove = function() { - var title = 'Delete user'; - var msg = 'Do you really want to delete this user? All associated documents, files and tags will be deleted'; - var btns = [{result:'cancel', label: 'Cancel'}, {result:'ok', label: 'OK', cssClass: 'btn-primary'}]; + var title = $translate.instant('settings.user.edit.delete_user_title'); + var msg = $translate.instant('settings.user.edit.delete_user_message'); + var btns = [ + { result:'cancel', label: $translate.instant('cancel') }, + { result:'ok', label: $translate.instant('ok'), cssClass: 'btn-primary' } + ]; $dialog.messageBox(title, msg, btns, function(result) { if (result == 'ok') { diff --git a/docs-web/src/main/webapp/src/app/docs/controller/tag/TagEdit.js b/docs-web/src/main/webapp/src/app/docs/controller/tag/TagEdit.js index e77599da..5905fbba 100644 --- a/docs-web/src/main/webapp/src/app/docs/controller/tag/TagEdit.js +++ b/docs-web/src/main/webapp/src/app/docs/controller/tag/TagEdit.js @@ -3,7 +3,7 @@ /** * Tag edit controller. */ -angular.module('docs').controller('TagEdit', function($scope, $stateParams, Restangular, $dialog, $state) { +angular.module('docs').controller('TagEdit', function($scope, $stateParams, Restangular, $dialog, $state, $translate) { // Retrieve the tag Restangular.one('tag', $stateParams.id).get().then(function(data) { $scope.tag = data; @@ -28,11 +28,11 @@ angular.module('docs').controller('TagEdit', function($scope, $stateParams, Rest * Delete a tag. */ $scope.deleteTag = function(tag) { - var title = 'Delete tag'; - var msg = 'Do you really want to delete this tag?'; + var title = $translate.instant('tag.edit.delete_tag_title'); + var msg = $translate.instant('tag.edit.delete_tag_message'); var btns = [ - {result: 'cancel', label: 'Cancel'}, - {result: 'ok', label: 'OK', cssClass: 'btn-primary'} + {result: 'cancel', label: $translate.instant('cancel')}, + {result: 'ok', label: $translate.instant('ok'), cssClass: 'btn-primary'} ]; $dialog.messageBox(title, msg, btns, function(result) { diff --git a/docs-web/src/main/webapp/src/index.html b/docs-web/src/main/webapp/src/index.html index c9f40a41..85dc910a 100644 --- a/docs-web/src/main/webapp/src/index.html +++ b/docs-web/src/main/webapp/src/index.html @@ -1,7 +1,7 @@ - Sismics Docs + Sismics Docs @@ -29,6 +29,7 @@ + @@ -92,7 +93,7 @@