[ASTPPCOM-360] Use Async callback for i18n Created: 04/Apr/18 Updated: 09/Oct/19 Resolved: 05/Apr/18 |
|
| Status: | Done |
| Project: | ASTPP Community |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Task | ||
| Reporter: | Rob Thomas (Inactive) | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
At the moment, all i18n is done via a sync callback. This can be resolved in two ways: 1. Request all i18n requests in one call, which will still be sync, but will be significantly faster |
| Comments |
| Comment by Samir Doshi [ 04/Apr/18 ] |
|
Thanks for the suggestion and it seems that will improve the UI speed but here I am not pretty clear with Async callback and how it should work? Do you have any reference or doc which we can refer? |
| Comment by Rob Thomas (Inactive) [ 04/Apr/18 ] |
|
I probably should ask which would you prefer? I'm happy to do either, but I think the async call will be better. The other problem is that you're going to have to ugprade jQuery from 1.7.1 to something that was written when chrome existed 8) Is there any particular reason you're bundling it, rather than using one of the CDN hosted versions? |
| Comment by Samir Doshi [ 05/Apr/18 ] |
|
I do not know how async works. So before commenting on sync and async, I need to study about that. That is why I asked if you have any reference code or guide then please share with me. Regarding jquery 1.7.1, Nope when we started using that, we assumed that it will be faster and safe to use it from the local folder rather than using CDN hosted version. Moreover, at the moment, we are using flexigrid which requires same version. Now we are going to use latest version of jquery and replace flexigrid with datatables as that is more flexible & responsive. |
| Comment by Rob Thomas (Inactive) [ 05/Apr/18 ] |
|
Well, without looking too hard at the code, you're currently generating a string and then returning it. I would probably just do something like (and this is totally untested, and off the top of my head). Unable to find source-code formatter for language: `. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml var i18n = [ "These", "are", "the", "words", "to", "be", "translated" ]; var table = $("<table></table>"); var tr = $("<tr></tr>)"; $.each(i18n, function(v) { tr.append("<th id='translate-"+v+"'>"+getTranslation(v)+"</th>"); updateTranslation(v) }); function getTranslation(v) { // look up v in local browser store, return it if exists } function updateTranslation(v) { $.ajax({ url: blah, data: "?gettranslation="+v, success: function(data) { $("#translation-"+v).text(data); updateTranslation(v, data); } }); } function updateTranslation(v, data) { // update local browser data store } ` Hopefully that explains what I mean. You don't actually need to reference the ID, either - you could just pass the jquery th object and update that as part of the ajax callback. |