@ -2,15 +2,19 @@
"use strict" ;
"use strict" ;
/* globals RELATIVE_PATH, config, define */
/* globals RELATIVE_PATH, config, define */
var S ;
var S = null ;
var stringDefer = null ;
// export the class if we are in a Node-like system.
// export the class if we are in a Node-like system.
if ( typeof module === 'object' && module . exports === translator ) {
if ( typeof module === 'object' && module . exports === translator ) {
exports = module . exports = translator ;
exports = module . exports = translator ;
S = require ( 'string' ) ;
S = require ( 'string' ) ;
stringDefer . resolve ( S ) ;
} else {
} else {
stringDefer = $ . Deferred ( ) ;
require ( [ 'string' ] , function ( stringLib ) {
require ( [ 'string' ] , function ( stringLib ) {
S = stringLib ;
S = stringLib ;
stringDefer . resolve ( S ) ;
} ) ;
} ) ;
}
}
@ -162,6 +166,12 @@
return callback ( text ) ;
return callback ( text ) ;
}
}
if ( S === null ) { // browser environment and S not yet initialized
// we need to wait for async require call
stringDefer . then ( function ( ) { translateKeys ( keys , text , language , callback ) ; } ) ;
return ;
}
var data = { text : text } ;
var data = { text : text } ;
keys . forEach ( function ( key ) {
keys . forEach ( function ( key ) {
translateKey ( key , data , language , function ( translated ) {
translateKey ( key , data , language , function ( translated ) {