.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 }
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;