translate.js icon indicating copy to clipboard operation
translate.js copied to clipboard

Allow translate.text to accept a string for callback in browser context

Open erikvold opened this issue 15 years ago • 4 comments

In the browser context, it is slightly more efficient (depending on the use case) for a user of translate.js to pass a string as the callback, which is the name of the global function that will be used when the jsonp request is complete. Besides that it is a nice additional feature I think.

erikvold avatar Jul 04 '10 00:07 erikvold

efficient or succinct?

you'd have to show me the code, i dont really understand. if you are talking about event binding sugar syntax, i think thats the job for an event library, not translate

Marak avatar Jul 04 '10 01:07 Marak

efficient or succinct?

efficient

you'd have to show me the code

patch

It didn't turn out as well as I hoped, because the returned variable is the full reponse in this case, and not just the translated text..

erikvold avatar Jul 04 '10 01:07 erikvold

yeah i see what you are talking about now.

this is a problem i think. if you fire two concurrent translate requests the callbacks are going to get borked?

this is why i wanted to use a standard JSONP / AJAX library for this. i might revert back to jQuery, since I know jQuery will automatically create the dynamic callback names for you.

Marak avatar Jul 04 '10 17:07 Marak

this is a problem i think. if you fire two concurrent translate requests the callbacks are going to get borked?

I thought about that situation, and I can't see how this gets borked. A library would be overkill imo.

erikvold avatar Jul 04 '10 18:07 erikvold