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 only: Downloaded language does not survive after Firefox restart #55

Open ghost opened 1 year ago

ghost commented 1 year ago

Hi,

TranslateLocally 0.7.2 / Firefox 106.0.4

Works nicely up to now. Desktop app is not installed.

One thing I don't understand:

On first new source language, TranslateLocally offers to Download language & Translate page. Later on same source language, the offer is to only Translate page -- OK, no problem.

When I restart Firefox, the offer is again to Download language & Translate page

My questions: 1- Where is the downloaded language downloaded to? In the user's profile? But where? 2- Why does the downloaded language need to be re-downloaded unless it is in RAM?

I don't get it. Thanks.

jelmervdl commented 1 year ago

Hi @Cade66, they are cached in the local browser cache and they should not be actively invalidated unless there is an error.

I'm not sure if they're visible in about:cache, but that's where I would expect them.

I've heard reports of people using Firefox in permanent private mode where caching may not work.

ghost commented 1 year ago

Hi @jelmervdl,

[Downloaded languages] are cached in the local browser cache and they should not be actively invalidated unless there is an error.

In the cache, of course. Users who've disabled disk cache have these downloaded language packs in memory hence wiped at Firefox exit. The ideal would be that these language packs be downloaded and remain available and I believe this is the advantage of combining the extension with the desktop application.

Someone wrote on a Ghacks article dedicated to TranslateLocally,

you can download language pair manually at https://translatelocally.com/models.json, extract file until you see folder and put at C:\Users*user*\AppData\Roaming\translateLocally

1- Just had a look at downloaded language packs here and I see that the language packs are not downloaded from translatelocally.com but from data.statmt.org/bergamot, i.e. https://data.statmt.org/bergamot/models/fren/fren.student.tiny11.tar.gz

2- Can we imagine a work-around which would allow the user to manually download these language packs to their dedicated localization in the user's C:\Users\*user*\AppData\Roaming\translateLocally (if this is correct) and then have the extension accept TranslateLocally in the Translation Provider option? The idea is to have the advantages of the TranslateLocally desktop application without actually installing it ...

3- Thanks to all, Bergamot, TranslateLocally, for your work. I'm more than interested by the concept and the development. So I'm digging into it to try to establish an equalization between the code and my own wishes. The main point is the translation quality of course and from what I've briefly tested the result is quite nice.

jelmervdl commented 1 year ago

1) Correct, data.statmt.org hosts our models at the moment, but in theory they can be hosted anywhere. They're also referred to from here: https://github.com/browsermt/students. The models.json file is the source of truth for the models and contains the checksums to validate them.

2) I don't think the web extension can access the filesystem. Temporary it can, through <input type="file">, but not across browser sessions. When you select TranslateLocally as the Translation provider, it will delegate all translations to that program (which does have access to the filesystem) so that's how it can work around that browser limitation.

Would storage like localStorage be maintained in these setups of Firefox?

One other way could be to have extra extensions per language, that ship the model and that can communicate with the main extension. But that would be quite the maintenance burden.