Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
6efc473859 | ||
![]() |
e1ec86f298 | ||
![]() |
29ee5dda90 | ||
![]() |
b8cd2dff54 | ||
![]() |
fb3f32f050 | ||
![]() |
41f1f56fe5 | ||
![]() |
5be5def820 |
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
@ -78,7 +78,7 @@ jobs:
|
||||
|
||||
- name: Download release url
|
||||
if: contains(github.ref, '/tags/')
|
||||
uses: actions/download-artifact@v1
|
||||
uses: actions/download-artifact@v4.1.7
|
||||
with:
|
||||
name: release_upload_url
|
||||
path: ./
|
||||
|
@ -1,5 +1,7 @@
|
||||
# Screen Translator
|
||||
|
||||
**The project is almost abandoned. I don't have time for it and I can only fix minor issues**
|
||||
|
||||
## Introduction
|
||||
|
||||
This software allows you to translate any text on screen.
|
||||
@ -27,7 +29,7 @@ file and place it into the `translations` folder next to `screen-translator.exe`
|
||||
The app doesn't have a main window.
|
||||
After start it shows only the tray icon.
|
||||
|
||||
If the app detects invalid settings, it will show the error message via system tray.
|
||||
If the app detects invalid settings, it will show the error message via system tray.
|
||||
It will also highlight the section name in red on the left panel of the settings window.
|
||||
Clicking on that section name will show a more detailed error message in the right panel (also in red).
|
||||
|
||||
|
@ -4,8 +4,16 @@ var active = window.location.href !== "about:blank";
|
||||
function checkFinished() {
|
||||
if (!active) return;
|
||||
|
||||
let area = document.querySelector('textarea[dl-test=translator-target-input]');
|
||||
let text = area ? area.value : '';
|
||||
let area = document.querySelector('div#target-dummydiv');
|
||||
let text = area ? area.innerHTML.trim() : '';
|
||||
if (area == null) {
|
||||
area = document.querySelector('d-textarea.lmt__target_textarea p');
|
||||
text = area ? area.innerText.trim() : '';
|
||||
}
|
||||
if (area == null) {
|
||||
area = document.querySelector('d-textarea[data-testid=translator-target-input] p');
|
||||
text = area ? area.innerText.trim() : '';
|
||||
}
|
||||
|
||||
if (text === lastText || text === '')
|
||||
return;
|
||||
@ -20,16 +28,16 @@ function translate(text, from, to) {
|
||||
console.log('start translate', text, from, to)
|
||||
|
||||
if (text.trim().length == 0) {
|
||||
proxy.setTranslated('');
|
||||
return;
|
||||
proxy.setTranslated('');
|
||||
return;
|
||||
}
|
||||
|
||||
from = from == 'zh-CN' ? 'zh' : from;
|
||||
to = to == 'zh-CN' ? 'zh' : to;
|
||||
|
||||
let supported = ['ru', 'en', 'de', 'fr', 'es', 'pt', 'it', 'nl', 'pl', 'ja', 'zh',
|
||||
'uk', 'bg', 'hu', 'el', 'da', 'id', 'lt', 'pt', 'ro', 'sk', 'sk', 'tr', 'fi', 'cs',
|
||||
'sv', 'et']
|
||||
'uk', 'bg', 'hu', 'el', 'da', 'id', 'lt', 'pt', 'ro', 'sk', 'sk', 'tr', 'fi', 'cs',
|
||||
'sv', 'et']
|
||||
if (supported.indexOf(from) == -1) {
|
||||
proxy.setFailed('Source language not supported');
|
||||
return;
|
||||
@ -41,21 +49,32 @@ function translate(text, from, to) {
|
||||
|
||||
active = true;
|
||||
|
||||
var singleLineText = text.replace(/(?:\r\n|\r|\n)/g, ' ');
|
||||
|
||||
let langs = from + '/' + to + '/';
|
||||
if (window.location.href.indexOf('www.deepl.com/translator') !== -1
|
||||
&& window.location.href.indexOf(langs) !== -1) {
|
||||
var input = document.querySelector('textarea[dl-test=translator-source-input]');
|
||||
if (input.value == text) {
|
||||
console.log('using cached result');
|
||||
lastText = '';
|
||||
return;
|
||||
|
||||
var input = document.querySelector('d-textarea[dl-test=translator-source-input] p');
|
||||
if (input == null)
|
||||
input = document.querySelector('d-textarea.lmt__source_textarea p');
|
||||
if (input == null)
|
||||
input = document.querySelector('d-textarea[data-testid=translator-source-input] p');
|
||||
if (input.innerText == singleLineText) {
|
||||
console.log('using cached result');
|
||||
lastText = '';
|
||||
return;
|
||||
}
|
||||
input.value = text;
|
||||
input.dispatchEvent(new Event("input", { bubbles: true, cancelable: true }));
|
||||
input.innerText = singleLineText;
|
||||
if (areaCopy = document.querySelector('div#source-dummydiv'))
|
||||
areaCopy.innerHTML = singleLineText;
|
||||
setTimeout(function () {
|
||||
input.dispatchEvent(new Event("input", { bubbles: true, cancelable: true }));
|
||||
}, 300);
|
||||
return;
|
||||
}
|
||||
|
||||
let url = 'https://www.deepl.com/translator#' + langs + encodeURIComponent(text);
|
||||
let url = 'https://www.deepl.com/translator#' + langs + encodeURIComponent(singleLineText);
|
||||
console.log("setting url", url);
|
||||
window.location = url;
|
||||
}
|
||||
|
@ -594,7 +594,7 @@
|
||||
{"url":"https://raw.githubusercontent.com/OneMoreGres/ScreenTranslator/master/translators/bing.js", "path":"$translators$/bing.js", "md5":"a982e9aa6cac598f4c9bf4a56386d13e", "size":1481}
|
||||
]}
|
||||
,"deepl": {"files":[
|
||||
{"url":"https://raw.githubusercontent.com/OneMoreGres/ScreenTranslator/master/translators/deepl.js", "path":"$translators$/deepl.js", "md5":"6f1c5cd1ccd18cd663f65e6a9bf8462a", "size":1854}
|
||||
{"url":"https://raw.githubusercontent.com/OneMoreGres/ScreenTranslator/master/translators/deepl.js", "path":"$translators$/deepl.js", "md5":"76856af9b80c3d0e852ca73f8f1ebbdb", "size":2611}
|
||||
]}
|
||||
,"google": {"files":[
|
||||
{"url":"https://raw.githubusercontent.com/OneMoreGres/ScreenTranslator/master/translators/google.js", "path":"$translators$/google.js", "md5":"793d6628ac9e26a1f3cc00fa9c863495", "size":1508}
|
||||
|
Loading…
Reference in New Issue
Block a user