| 408 | | 408 | |
| 409 | // split text by embedded images links | 409 | // split text by embedded images links |
| 410 | const chunks = text.split(/!\[.*?]\([^)]*\)/); | 410 | const chunks = text.split(/!\[.*?]\([^)]*\)/); |
| 411 | const links = [ ...text.matchAll(/!\[.*?]\([^)]*\)/g) ]; | 411 | const links = [...text.matchAll(/!\[.*?]\([^)]*\)/g)]; |
| 412 | | 412 | |
| 413 | let r = ""; | 413 | let result = ''; |
| 414 | for (let i = 0; i < chunks.length; i++) { | 414 | for (let i = 0; i < chunks.length; i++) { |
| 415 | r += await translateInner(chunks[i], lang); | 415 | result += await translateInner(chunks[i], lang); |
| 416 | if (i < links.length) r += links[i][0]; | 416 | if (i < links.length) result += links[i][0]; |
| 417 | } | 417 | } |
| 418 | | 418 | |
| 419 | return r; | 419 | return result; |
| 420 | } catch (error) { | 420 | } catch (error) { |
| 421 | console.log(error); | 421 | console.log(error); |
| 422 | toastr.error(String(error), 'Failed to translate message'); | 422 | toastr.error(String(error), 'Failed to translate message'); |