-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Offline Web Page Translation? #21
Comments
Offline from a mobile browser extension? That's not exactly trivial. Hardest part is running all the code in JS. https://emscripten.org/ can help with that, but it's a lot of work. https://github.com/ftyers/attjs also started on a part of it. It's something that we have the expertise to do, but definitely not the time for. An online browser extension would be much easier to make, and we have some code laying around for many parts of it - again, time is the main blocker. For now, if you're online you can just use https://apertium.org/ in any browser. |
The problem with using Google Translate or Apertium in browser is many of the websites I need to translate are because I'm buying a product or checking out at a restaurant. It seems like a bad idea to enter credit card information into a website that is sending potentially all of the text somewhere else to be translated... But perhaps I'm wrong. The other feature I need to completely replace Google Translate is doing OCR on an image and then translating that text. Have you heard of anyone doing that? |
As a stopgap for geeks on Linux, https://gist.github.com/unhammer/6900610 will let you select any text, hit a keyboard shortcut and show the translation, using locally installed apertium. (Not a solution for most people of course.) |
Sweet, I'll think about how this could be done on Android, if at all. |
https://news.ycombinator.com/item?id=33792447 - some useful discussion for those researching how to implement offline translation... I'm closing this for now as I don't see apertium being a potential path for this goal. |
(Reopening since we do want this, it's just that no one is currently working on it.) |
Emscripten looked easy enough to get running, so I tried it and managed to get CG-3 to build and run. Since CG-3 required that I figure out ICU (and Boost), all of our other tools should be buildable under Emscripten. Javascript code, tested in both Chrome and Firefox: {
let cglb = Module.cwrap('cg3_grammar_load_buffer', 'number', ['string', 'number']);
let cac = Module.cwrap('cg3_applicator_create', 'number', ['number']);
let crgotf = Module.cwrap('cg3_run_grammar_on_text_fns', null, ['number', 'string', 'string']);
let g = cglb('DELIMITERS = "<.>"; SELECT (tag) ;', 'DELIMITERS = "<.>"; SELECT (tag) ;'.length);
let a = cac(g);
FS.writeFile('/tmp/input.txt', '"<woærd>"\n\t"woørd" tag\n\t"woård" nottag\n');
crgotf(a, '/tmp/input.txt', '/tmp/output.txt');
console.log(FS.readFile('/tmp/output.txt', {'encoding': 'utf8'}));
} Yields output:
So it is absolutely doable. Just need to take the time for it. |
https://github.com/apertium/wasm - I don't intend to do more with it atm. I've proven it can work, but there is no concrete application need yet. |
How hard would it be to use Apertium's offline functionality for web page translation in Firefox & Chrome (especially on Android)? Currently, there seems no way to translate web pages on the fly unless your Android phone includes Google Services, unfortunately. I'm trying to find the easiest way to auto translate web pages - especially offline & on Linux desktop & on Android.
Thanks!
The text was updated successfully, but these errors were encountered: