@@ -73,7 +73,12 @@ angular.module('gettext').provider('gettextCatalog', ["gettextPlurals", function
7373 angular . extend ( this , provider ) ;
7474
7575 var self = this ;
76- this . $get = /* @ngInject */ [ "$http" , "$interpolate" , "$cacheFactory" , "$rootScope" , function ( $http , $interpolate , $cacheFactory , $rootScope ) {
76+ this . $get = /* @ngInject */ [ "$injector" , function ( $injector ) {
77+ // lazily inject these to prevent circular dependecies
78+ var $http ;
79+ var $interpolate ;
80+ var $rootScope ;
81+
7782 function Catalog ( options ) {
7883 angular . extend ( this , options ) ;
7984 var self = this ;
@@ -95,6 +100,7 @@ angular.module('gettext').provider('gettextCatalog', ["gettextPlurals", function
95100 } ;
96101
97102 function broadcastUpdated ( ) {
103+ $rootScope = $rootScope || $injector . get ( '$rootScope' ) ;
98104 $rootScope . $broadcast ( 'gettextLanguageChanged' ) ;
99105 }
100106
@@ -109,12 +115,16 @@ angular.module('gettext').provider('gettextCatalog', ["gettextPlurals", function
109115 } ;
110116
111117 this . getString = function ( string , scope , context ) {
118+ $interpolate = $interpolate || $injector . get ( '$interpolate' ) ;
119+
112120 string = this . getStringForm ( string , 0 , context ) || prefixDebug ( string ) ;
113121 string = scope ? $interpolate ( string ) ( scope ) : string ;
114122 return addTranslatedMarkers ( string ) ;
115123 } ;
116124
117125 this . getPlural = function ( n , string , stringPlural , scope , context ) {
126+ $interpolate = $interpolate || $injector . get ( '$interpolate' ) ;
127+
118128 var form = gettextPlurals ( this . currentLanguage , n ) ;
119129 string = this . getStringForm ( string , form , context ) || prefixDebug ( n === 1 ? string : stringPlural ) ;
120130 if ( scope ) {
@@ -125,6 +135,7 @@ angular.module('gettext').provider('gettextCatalog', ["gettextPlurals", function
125135 } ;
126136
127137 this . loadRemote = function ( url ) {
138+ $http = $http || $injector . get ( '$http' ) ;
128139 return $http ( {
129140 method : 'GET' ,
130141 url : url ,
@@ -137,7 +148,7 @@ angular.module('gettext').provider('gettextCatalog', ["gettextPlurals", function
137148 } ;
138149 }
139150
140- self . cache = self . cache || $cacheFactory ( 'strings' ) ;
151+ self . cache = self . cache || $injector . get ( '$ cacheFactory' ) ( 'strings' ) ;
141152 return new Catalog ( self ) ;
142153 } ] ;
143154} ] ) ;
0 commit comments