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

firefox add-on translatelocally doesn´t seem to be initialized by default #61

Closed Rosika2 closed 1 year ago

Rosika2 commented 1 year ago

Hi all,

Info: my system: Linux/Lubuntu 20.04.5 LTS, 64 bit

I have a question regarding the initialization of translatelocally which I installed as a an add-on in my firefox browser.

It works well once it is initialized. But this doesn´t seem to happen automatically. When I load any page and click on the translatelocally icon in firefox´s status bar I get a popup window which says:

TypeError: NetworkError when attempting to fetch resource

and no translation is offered.

The only thing I can do is the following:

Now translatelocally works just fine.

But I have to follow the described procedure each time I power up firefox.

Any ideas why that is the case?

Thanks a lot for your help in advance.

Many greetings Rosika

jelmervdl commented 1 year ago

Hmm, I wonder whether this is caused by fetching the model list from translatelocally.com too early. There's also no retry on that request, which isn't great.

Rosika2 commented 1 year ago

@jelmervdl:

Hi and thanks for your reply, :-)

I´ve been keeping an eye on how things are behaving. E.g. right now:

My system has been running for 2 h 51 m at the moment of writing.

I haven´t had occasion to use translatelocally yet but I just clicked on the icon to see how it is behaving at the moment. Curiously enough this time I wasn´t presented with the error popup and translatelocally is available.

I wonder whether this has something to do with how long firefox has been running before attempting to use the add-on... Of course I may be totally wrong here.

Thanks again and many greetings from Rosika : -)

jelmervdl commented 1 year ago

Thanks for looking further into it!

Even when you don't interact with the add-on it will have fetched the model list and been checking the language of webpages you've visited against that list (this can be improved, #46)

What could have happened was that Firefox was started at a moment your computer wasn't connected to the internet, or not able to access any site (e.g. captive public wifi). It attempts to fetch the model list when the add-on is loaded.

I'm considering how to improve that situation. Firefox has an online event but that won't be good if the website hosting the model list is unreachable. Hammering that server on failure also isn't.

One easy improvement at least would be to store the model list in a persistent cache, and fall back to that cached entry if it can't be fetched. That would solve the add-on from being completely dysfunctional when offline.

Rosika2 commented 1 year ago

@jelmervdl:

Hi Jelmer, :-)

thanks again for writing and providing a wealth of background information. I also looked at the link you provided https://github.com/jelmervdl/translatelocally-web-ext/issues/46. That´s very interesting.

What could have happened was that Firefox was started at a moment your computer wasn't connected to the internet

Hmm, I cannot fully recollect the situation. But I intend to keep an eye on it when starting firefox next time.

Hold on: Now I´ve come to think of it: I think you are right indeed.

My situation is the following:

The internet connectivity is established via a 4G dongle for mobile networks. It´s a Huawei E3372h_LTE-USB-stick and upon connection it is recognized by my Lubuntu system as "cable connection".

In order to establish the internet connection I have to start firefox first and then load the tab http://192.168.8.1/html/content.html#home which gives me the stick´s web-interface and where I am presented with the "connect" button.

So you´re absolutely right: when starting firefox there is no internet connection yet...

One easy improvement at least would be to store the model list in a persistent cache, and fall back to that cached entry if it can't be fetched.

That sounds great.

Well, now I at least I got a reason why that error message occurred.

Thanks so much, Jelmer, for your kind help.

Many greetings. Rosika :-)