-
-
Notifications
You must be signed in to change notification settings - Fork 44
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
[REQ] only translate "foreign" text #29
Comments
To implement this we can retrieve the detected language from Google API and check with our |
To get the language of the page we have the following:
If testing those disables and the user still wants to translate they can use the context menu. To detect user language:
There's also |
Yes. We need to do something for this. However, language detection is inefficient because ...
Instead of those, how about we'd offer a toolbar button (and key shortcut) for switching instant translation feature? |
That doesn't solve the problem IMHO. Maybe an option to switch off language detection for Instant Translation? |
Using the API to define the language brings a lot of extra network requests. I think that some kind of shortcut would be a good idea to switch instant translation feature. |
I'm working on this one :) |
Just putting some thoughts down... If we try to simplify the goal: what do we really want to do? Check if the language of the text/page is the same as the target language. function getPageLanguage() {
var langHTML = document.documentElement.lang
var langCharSet = document.characterSet
var x = document.getElementsByTagName("META")
for (var i = 0; i < x.length; i++) {
if (x[i].getAttribute('property') == 'og:locale')
var langOgLocale = x[i].getAttribute('content')
}
if (langHTML != null) console.log(langHTML)
if (langCharSet != null) console.log(langCharSet)
if (langOgLocale != null) console.log(langOgLocale)
if (langClosest != null) console.log(langClosest)
return
}
Maybe it's enough to just check lang? Benefit is that it is the same format as the languages are stored in Settings.plist There's also a possibility that elements within the page are given a lang attribute, so it's better to start at the click and go up the DOM to the closest lang attribute.
What if our logic gets it wrong? The user still sees the translation! No worries. |
Thank you for the detailed survey! I think this feature could be shipped if the following issues were solved.
Consider filing PR for this feature! so we can test it in the real world whether it works well 👍 |
Agreed. This is a difficult problem to solve satisfactorily. I will give it more thought. |
I was thinking it is possible to guess encoding of text using JavaScript or Obj-C (now that the extension is native) with quick initial check to see if it only contains ASCII bytes. Background JavaScript Obj-C (Foundation) |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Let's still do this. |
I still run into this problem. I think perhaps my issues would mostly be solved switching off Polyglot for contents of input/textarea? |
I will look into how that works. |
Hi there. |
@AntonUspehov did you set your preferences in the Polyglot app? See readme > setup > step 3 |
This issue still annoys me every day. How about disabling Polyglot for certain domains? For me that would be English Wikipedia for example. |
This does not work reliably for me? eg. in my eBay.co.uk messages I select part of a message and that triggers Polyglot? |
It would be great if the extension only translated "foreign" text
ideas:
The text was updated successfully, but these errors were encountered: