From fdd829da38d9b62e301538af968b727a7f19c330 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Tue, 14 Aug 2018 15:22:49 -0400 Subject: [PATCH] LP#1770981 Apply OpenSRF locale on webstaff page load Translate the locale from the locale cookie into the global OpenSRF.locale variable so network calls are stamped with the correct locale. Signed-off-by: Bill Erickson Signed-off-by: Ben Shum --- Open-ILS/web/js/ui/default/staff/services/startup.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Open-ILS/web/js/ui/default/staff/services/startup.js b/Open-ILS/web/js/ui/default/staff/services/startup.js index d947d751ce..41c69775d0 100644 --- a/Open-ILS/web/js/ui/default/staff/services/startup.js +++ b/Open-ILS/web/js/ui/default/staff/services/startup.js @@ -21,7 +21,9 @@ angular.module('egCoreMod') .factory('egStartup', ['$q','$rootScope','$location','$window','egIDL','egAuth','egEnv','egOrg', -function($q, $rootScope, $location, $window, egIDL, egAuth, egEnv , egOrg ) { + '$cookies', +function($q, $rootScope, $location, $window, egIDL, egAuth, egEnv , egOrg , + $cookies) { var service = { promise : null } @@ -89,6 +91,16 @@ function($q, $rootScope, $location, $window, egIDL, egAuth, egEnv , egOrg return service.promise; } + // Apply the locale from the cookie before any network + // calls are made. + var locale = $cookies.get('eg_locale'); + if (locale) { + // Cookie is stored aa_bb. OpenSRF wants aa-BB + var parts = locale.split(/_/); + OpenSRF.locale = parts[0] + '-' + parts[1].toUpperCase(); + console.debug('Applying locale ' + OpenSRF.locale); + } + // create a new promise and fire off startup var deferred = $q.defer(); service.promise = deferred.promise; -- 2.11.0