jelmervdl / translatelocally-web-ext

TranslateLocally for the Browser is a web-extension that enables client side in-page translations for web browsers.
https://addons.mozilla.org/en-GB/firefox/addon/translatelocally-for-firefox/
Mozilla Public License 2.0
65 stars 3 forks source link

[Question]: Help including the translation engine outside a browser #72

Open saona-raimundo opened 1 year ago

saona-raimundo commented 1 year ago

Hi! Thank you for all the work!

I wanted to ask for pointers about how to make the translation engine work outside the browser, maybe with only a wasm runtime(?). The bergamot project website is not very informative on that. I would assume that you only need a javascript or wasm runtime, right?

jelmervdl commented 1 year ago

I think your best starting point would be https://github.com/browsermt/bergamot-translator/tree/main/wasm. There's a node-test.js that is supposed to run on nodejs in a terminal.

The wasm bindings we use generate Javascript for an interface. I don't know how you would be able to call any of the compiled wasm code without those bits of javascript.

saona-raimundo commented 1 year ago

I was planning on using the wasm module directly through a WASM runtime like wasmtime

I inspected the wasm folder and the wasm release of bergamont, I hope you do not mind some follow-up questions.

I am not familiar with Node.js (yet) so I am not sure how everything fits together, but it would be cool if I could use the wasm directly. If I understand correctly, only the wasm and the models are necessary to perform a translation, right?

Just as an exercise (because it may not be an efficient use), one can compile wasm apps that read some input file, here is a markdown2html example Do you think something like this is possible with bergamot? (basically, a command line interface compiled to wasm)