diff --git a/docs-web/src/main/webapp/src/app/share/app.js b/docs-web/src/main/webapp/src/app/share/app.js index c162fb96..8c712093 100644 --- a/docs-web/src/main/webapp/src/app/share/app.js +++ b/docs-web/src/main/webapp/src/app/share/app.js @@ -5,13 +5,13 @@ */ angular.module('share', // Dependencies - ['ui.router', 'ui.bootstrap', 'restangular', 'ngSanitize', 'ngTouch'] + ['ui.router', 'ui.bootstrap', 'restangular', 'ngSanitize', 'ngTouch', 'pascalprecht.translate', 'tmh.dynamicLocale'] ) /** * Configuring modules. */ -.config(function($locationProvider, $stateProvider, $httpProvider, RestangularProvider) { +.config(function($locationProvider, $stateProvider, $httpProvider, RestangularProvider, $translateProvider, tmhDynamicLocaleProvider) { $locationProvider.hashPrefix(''); // Configuring UI Router @@ -53,6 +53,31 @@ angular.module('share', // Configuring Restangular RestangularProvider.setBaseUrl('../api'); + + // Configuring Angular Translate + $translateProvider + .useSanitizeValueStrategy(null) + .useStaticFilesLoader({ + prefix: 'locale/', + suffix: '.json' + }) + .registerAvailableLanguageKeys(['en', 'fr', 'zh_CN', 'zh_HK', 'zh_TW'], { + 'zh_*': 'zh_CN', + 'en_*': 'en', + 'fr_*': 'fr', + '*': 'en' + }); + + if (!_.isUndefined(localStorage.overrideLang)) { + // Set the current language if an override is saved in local storage + $translateProvider.use(localStorage.overrideLang); + } else { + // Or else determine the language based on the user's browser + $translateProvider.determinePreferredLanguage(); + } + + // Configuring tmhDynamicLocale + tmhDynamicLocaleProvider.localeLocationPattern('locale/angular-locale_{{locale}}.js'); // Configuring $http to act like jQuery.ajax $httpProvider.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=utf-8'; diff --git a/docs-web/src/main/webapp/src/app/share/controller/Footer.js b/docs-web/src/main/webapp/src/app/share/controller/Footer.js new file mode 100644 index 00000000..f1535a3c --- /dev/null +++ b/docs-web/src/main/webapp/src/app/share/controller/Footer.js @@ -0,0 +1,26 @@ +'use strict'; + +/** + * Footer controller. + */ +angular.module('share').controller('Footer', function($scope, $rootScope, Restangular, $translate, tmhDynamicLocale, $locale) { + // Load app data + Restangular.one('app').get().then(function(data) { + $scope.app = data; + }); + + // Save the current language to local storage + $rootScope.$on('$translateChangeSuccess', function() { + $scope.currentLang = $translate.use(); + localStorage.overrideLang = $scope.currentLang; + tmhDynamicLocale.set($scope.currentLang).then(function () { + $rootScope.dateFormat = $locale.DATETIME_FORMATS.shortDate; + $rootScope.dateTimeFormat = $locale.DATETIME_FORMATS.short; + }); + }); + + // Change the current language + $scope.changeLanguage = function(lang) { + $translate.use(lang); + }; +}); \ No newline at end of file diff --git a/docs-web/src/main/webapp/src/locale/en.json b/docs-web/src/main/webapp/src/locale/en.json index 0935ad54..7aba03cb 100644 --- a/docs-web/src/main/webapp/src/locale/en.json +++ b/docs-web/src/main/webapp/src/locale/en.json @@ -313,6 +313,13 @@ "new_entry": "New entry" } }, + "app_share": { + "main": "Ask a shared document link to access it", + "403": { + "title": "Not authorized", + "message": "The document you are trying to view is not shared anymore" + } + }, "directive": { "acledit": { "acl_target": "For", diff --git a/docs-web/src/main/webapp/src/locale/fr.json b/docs-web/src/main/webapp/src/locale/fr.json index b9fdbdb0..e040c75a 100644 --- a/docs-web/src/main/webapp/src/locale/fr.json +++ b/docs-web/src/main/webapp/src/locale/fr.json @@ -313,6 +313,13 @@ "new_entry": "Nouvelle entrée" } }, + "app_share": { + "main": "Demandez un lien de partage d'un document pour y accéder", + "403": { + "title": "Non autorisé", + "message": "Le document que vous tentez de consulter n'est plus disponible" + } + }, "directive": { "acledit": { "acl_target": "Pour", diff --git a/docs-web/src/main/webapp/src/partial/docs/document.view.html b/docs-web/src/main/webapp/src/partial/docs/document.view.html index 5c31f240..0fe0e794 100644 --- a/docs-web/src/main/webapp/src/partial/docs/document.view.html +++ b/docs-web/src/main/webapp/src/partial/docs/document.view.html @@ -21,13 +21,13 @@