@@ -15,7 +15,15 @@ angular.module('gettext').factory('gettextCatalog', ["gettextPlurals", "$http",
1515
1616 var prefixDebug = function ( string ) {
1717 if ( catalog . debug && catalog . currentLanguage !== catalog . baseLanguage ) {
18- return '[MISSING]: ' + string ;
18+ return catalog . debugPrefix + string ;
19+ } else {
20+ return string ;
21+ }
22+ } ;
23+
24+ var addTranslatedMarkers = function ( string ) {
25+ if ( catalog . showTranslatedMarkers ) {
26+ return catalog . translatedMarkerPrefix + string + catalog . translatedMarkerSuffix ;
1927 } else {
2028 return string ;
2129 }
@@ -27,6 +35,10 @@ angular.module('gettext').factory('gettextCatalog', ["gettextPlurals", "$http",
2735
2836 catalog = {
2937 debug : false ,
38+ debugPrefix : '[MISSING]: ' ,
39+ showTranslatedMarkers : false ,
40+ translatedMarkerPrefix : '[' ,
41+ translatedMarkerSuffix : ']' ,
3042 strings : { } ,
3143 baseLanguage : 'en' ,
3244 currentLanguage : 'en' ,
@@ -54,14 +66,14 @@ angular.module('gettext').factory('gettextCatalog', ["gettextPlurals", "$http",
5466 broadcastUpdated ( ) ;
5567 } ,
5668
57- getStringForm : function ( string , n , gettextContext ) {
69+ getStringForm : function ( string , n , context ) {
5870 var stringTable = this . strings [ this . currentLanguage ] || { } ;
5971 var plurals = stringTable [ string ] || [ ] ;
6072 var translation ;
6173
6274 // Translation is an object with context bound translations for the string
6375 if ( angular . isObject ( plurals [ 0 ] ) ) {
64- plurals = ( plurals [ 0 ] [ gettextContext ] || [ ] ) ;
76+ plurals = ( plurals [ 0 ] [ context ] || [ ] ) ;
6577 if ( ! angular . isArray ( plurals ) ) {
6678 throw new Error ( 'Context bound translations must be wrapped in a array' ) ;
6779 }
@@ -70,15 +82,17 @@ angular.module('gettext').factory('gettextCatalog', ["gettextPlurals", "$http",
7082 return translation ;
7183 } ,
7284
73- getString : function ( string , context , gettextContext ) {
74- string = this . getStringForm ( string , 0 , gettextContext ) || prefixDebug ( string ) ;
75- return context ? $interpolate ( string ) ( context ) : string ;
85+ getString : function ( string , scope , context ) {
86+ string = this . getStringForm ( string , 0 , context ) || prefixDebug ( string ) ;
87+ string = scope ? $interpolate ( string ) ( scope ) : string ;
88+ return addTranslatedMarkers ( string ) ;
7689 } ,
7790
78- getPlural : function ( n , string , stringPlural , context , gettextContext ) {
91+ getPlural : function ( n , string , stringPlural , scope , context ) {
7992 var form = gettextPlurals ( this . currentLanguage , n ) ;
80- string = this . getStringForm ( string , form , gettextContext ) || prefixDebug ( n === 1 ? string : stringPlural ) ;
81- return context ? $interpolate ( string ) ( context ) : string ;
93+ string = this . getStringForm ( string , form , context ) || prefixDebug ( n === 1 ? string : stringPlural ) ;
94+ string = scope ? $interpolate ( string ) ( scope ) : string ;
95+ return addTranslatedMarkers ( string ) ;
8296 } ,
8397
8498 loadRemote : function ( url ) {
0 commit comments