@@ -159,9 +159,16 @@ pimcore.document.editables.areablock = Class.create(pimcore.document.editables.a
159159 var brickName = this . name + ":" + element . key + "." ;
160160 var documentId = pimcore_document_id ;
161161
162- var checkerSettings = createDeeplApiSettings ( "translate" , "DE" , "EN" ) ;
163-
164- $ . ajax ( checkerSettings ) . done ( function ( ) {
162+ var checkerSettings = createDeeplApiSettings ( "translate" , "DE" , "EN" ) ;
163+
164+ Ext . Ajax . request ( {
165+ url : '/asioso_quick_translate_text' ,
166+ method : 'POST' ,
167+ params : checkerSettings . data ,
168+ headers : {
169+ "Content-Type" : "application/json"
170+ } ,
171+ success : function ( response ) {
165172
166173 var elementsWindow = quickTranslatecreateWindow ( "Processing" , "Getting your content ready for translation..." ) ;
167174
@@ -233,16 +240,22 @@ pimcore.document.editables.areablock = Class.create(pimcore.document.editables.a
233240 for ( var i = 0 ; i < partsToTranslate . length ; i ++ ) {
234241 var settings = createDeeplApiSettings ( partsToTranslate [ i ] , null , langTo , true ) ;
235242
236- $ . ajax ( settings ) . done ( function ( response ) {
237-
238- translatedParts . push ( response . translations [ 0 ] . text ) ;
239- progressBar [ 0 ] . updateProgress ( translatedParts . length / partsToTranslate . length , "Translating: " + translatedParts . length + " of " + partsToTranslate . length ) ;
240-
241- } ) . fail ( function ( ) {
242-
243- translatedParts . push ( null ) ;
244- progressBar [ 0 ] . updateProgress ( translatedParts . length / partsToTranslate . length , "Translating: " + translatedParts . length + "/" + partsToTranslate . length ) ;
245-
243+ Ext . Ajax . request ( {
244+ url : '/asioso_quick_translate_text' ,
245+ method : 'POST' ,
246+ params : settings . data ,
247+ headers : {
248+ "Content-Type" : "application/json"
249+ } ,
250+ success : function ( response ) {
251+
252+ translatedParts . push ( response . translations [ 0 ] . text ) ;
253+ progressBar [ 0 ] . updateProgress ( translatedParts . length / partsToTranslate . length , "Translating: " + translatedParts . length + " of " + partsToTranslate . length ) ;
254+ } ,
255+ failure : function ( response ) {
256+ translatedParts . push ( null ) ;
257+ progressBar [ 0 ] . updateProgress ( translatedParts . length / partsToTranslate . length , "Translating: " + translatedParts . length + "/" + partsToTranslate . length ) ;
258+ }
246259 } ) ;
247260
248261 }
@@ -359,56 +372,66 @@ pimcore.document.editables.areablock = Class.create(pimcore.document.editables.a
359372
360373 var translatingWindow = quickTranslatecreateWindow ( "Translating" , "Translating your brick..." ) ;
361374
362- $ . ajax ( settings ) . done ( function ( response ) {
363- elems = xmlToJson ( response . translations [ 0 ] . text , srcSet , true ) ;
364-
365- translatingWindow . destroy ( ) ;
366-
367- var savingWindow = quickTranslatecreateWindow ( "Saving" , "Saving your translated brick..." ) ;
368-
369- Ext . Ajax . request ( {
370- url : "/asioso_quick_translate_brick" ,
371- method : 'POST' ,
372- params : {
373- id : documentId ,
374- elements : elems
375- } ,
376- success : function ( ) {
377-
378- savingWindow . destroy ( ) ;
379-
380- var window = new Ext . window . Window ( {
381- minHeight : 150 ,
382- minWidth : 350 ,
383- maxWidth : 700 ,
384- modal : true ,
385- layout : 'fit' ,
386- bodyStyle : "padding: 10px;" ,
387- title : "Success" ,
388- html : "Yor brick was successfully translated and saved. To see your changes click reload!" ,
389- buttons : [
390- {
391- text : 'Reload' ,
392- handler : function ( ) {
393- reloadDocument ( documentId , data . type ) ;
394- }
395- }
396- ]
397- } ) ;
375+ Ext . Ajax . request ( {
376+ url : '/asioso_quick_translate_text' ,
377+ method : 'POST' ,
378+ params : settings . data ,
379+ headers : {
380+ "Content-Type" : "application/json"
381+ } ,
382+ success : function ( response ) {
383+ var response = Ext . decode ( response . responseText ) ;
398384
399- window . show ( ) ;
385+ elems = xmlToJson ( response . translations [ 0 ] . text , srcSet , true ) ;
400386
401- } . bind ( this ) ,
387+ translatingWindow . destroy ( ) ;
402388
403- failure : function ( ) {
404- savingWindow . destroy ( ) ;
405- quickTranslatecreateWindow ( "Error" , "We encountered an error while saving your translated brick. Internal server error." ) ;
406- }
407- } ) ;
389+ var savingWindow = quickTranslatecreateWindow ( "Saving" , "Saving your translated brick..." ) ;
408390
409- } ) . fail ( function ( ) {
410- translatingWindow . destroy ( ) ;
411- quickTranslatecreateWindow ( "Error" , "We couldn't translate your brick. Either the brick is too large or you have a malformed structure!" ) ;
391+ Ext . Ajax . request ( {
392+ url : "/asioso_quick_translate_brick" ,
393+ method : 'POST' ,
394+ params : {
395+ id : documentId ,
396+ elements : elems
397+ } ,
398+ success : function ( ) {
399+
400+ savingWindow . destroy ( ) ;
401+
402+ var window = new Ext . window . Window ( {
403+ minHeight : 150 ,
404+ minWidth : 350 ,
405+ maxWidth : 700 ,
406+ modal : true ,
407+ layout : 'fit' ,
408+ bodyStyle : "padding: 10px;" ,
409+ title : "Success" ,
410+ html : "Yor brick was successfully translated and saved. To see your changes click reload!" ,
411+ buttons : [
412+ {
413+ text : 'Reload' ,
414+ handler : function ( ) {
415+ reloadDocument ( documentId , data . type ) ;
416+ }
417+ }
418+ ]
419+ } ) ;
420+
421+ window . show ( ) ;
422+
423+ } . bind ( this ) ,
424+
425+ failure : function ( ) {
426+ savingWindow . destroy ( ) ;
427+ quickTranslatecreateWindow ( "Error" , "We encountered an error while saving your translated brick. Internal server error." ) ;
428+ }
429+ } ) ;
430+ } ,
431+ failure : function ( response ) {
432+ translatingWindow . destroy ( ) ;
433+ quickTranslatecreateWindow ( "Error" , "We couldn't translate your brick. Either the brick is too large or you have a malformed structure!" ) ;
434+ }
412435 } ) ;
413436 } ;
414437
@@ -434,8 +457,9 @@ pimcore.document.editables.areablock = Class.create(pimcore.document.editables.a
434457 }
435458
436459 } ) ;
460+ } ,
437461
438- } ) . fail ( function ( ) {
462+ failure : function ( response ) {
439463
440464 var status = response . status ;
441465
@@ -454,9 +478,8 @@ pimcore.document.editables.areablock = Class.create(pimcore.document.editables.a
454478 quickTranslatecreateWindow ( "Connection error" , "There seems to be a problem connecting to the DeepL service. Try again later." ) ;
455479 break ;
456480 }
457-
458- } ) ;
459-
481+ }
482+ } ) ;
460483 } . bind ( this , element )
461484 } ) ;
462485
0 commit comments