@@ -231,35 +231,31 @@ export function getCurrentLanguage() {
231231}
232232
233233function getLangsJson ( ) {
234- const deferred = Promise . defer ( ) ;
235-
236- request (
237- { method : "GET" , url : i18nFolder + 'languages.json' } ,
238- ( err , response , body ) => {
239- if ( err || response . status < 200 || response . status >= 300 ) {
240- deferred . reject ( { err : err , response : response } ) ;
241- return ;
234+ return new Promise ( ( resolve , reject ) => {
235+ request (
236+ { method : "GET" , url : i18nFolder + 'languages.json' } ,
237+ ( err , response , body ) => {
238+ if ( err || response . status < 200 || response . status >= 300 ) {
239+ reject ( { err : err , response : response } ) ;
240+ return ;
241+ }
242+ resolve ( JSON . parse ( body ) ) ;
242243 }
243- deferred . resolve ( JSON . parse ( body ) ) ;
244- }
245- ) ;
246- return deferred . promise ;
244+ ) ;
245+ } ) ;
247246}
248247
249248function getLanguage ( langPath ) {
250- const deferred = Promise . defer ( ) ;
251-
252- let response_return = { } ;
253- request (
254- { method : "GET" , url : langPath } ,
255- ( err , response , body ) => {
256- if ( err || response . status < 200 || response . status >= 300 ) {
257- deferred . reject ( { err : err , response : response } ) ;
258- return ;
249+ return new Promise ( ( resolve , reject ) => {
250+ request (
251+ { method : "GET" , url : langPath } ,
252+ ( err , response , body ) => {
253+ if ( err || response . status < 200 || response . status >= 300 ) {
254+ reject ( { err : err , response : response } ) ;
255+ return ;
256+ }
257+ resolve ( JSON . parse ( body ) ) ;
259258 }
260-
261- deferred . resolve ( JSON . parse ( body ) ) ;
262- }
263- ) ;
264- return deferred . promise ;
259+ ) ;
260+ } ) ;
265261}
0 commit comments