stable-diffusion-webui icon indicating copy to clipboard operation
stable-diffusion-webui copied to clipboard

[New Feature] Realtime Prompt Translate & Reverse Translate

Open donlinglok1 opened this issue 3 years ago • 11 comments
trafficstars

----2022-10-21---- Update! Added Reverse Translate, demo kinda like below: ezgif-5-2ffddd21eb

Steps:

  1. click "en2jp" button to enable the feature.
  2. input text in prompt/neg_prompt, the translated prompt will display on top of the screen.
  3. (optional) If you want to use reverse translate, click "jp2en", then input text in the new textarea on top of the screen.

Tested in chrome and edge for txt2img prompt.

----2022-10-19 ---- Hi, I am immensely enjoying your masterpiece project.

However, I am facing that there is too many prompt/negative prompt during the input, and it is hard to read.

Usually, I use chrome + google translate to convert and format it to another language for a better understanding. But that means I will need to switch tabs/ click translate frequently. The good news is, I find a way that can detect my input and real-time translate my prompt. (And this change ONLY effect to users who enabled google translate)

The demo is below (651KB GIFs): ezgif-1-fe2a5dd0f1

donlinglok1 avatar Oct 19 '22 09:10 donlinglok1

In most cases jQuery can be substituted by pure javascript methods.

Element.insertAdjacentHTML() Document.querySelector() jQuery.getScript alternative in native JavaScript

fa0311 avatar Oct 19 '22 10:10 fa0311

In most cases jQuery can be substituted by pure javascript methods.

Element.insertAdjacentHTML Document.querySelector() jQuery.getScript alternative in native JavaScript

thank you for the reply, I will check on it.

donlinglok1 avatar Oct 19 '22 10:10 donlinglok1

relevant ? an old never adressed issue : https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/517

Ehplodor avatar Oct 19 '22 10:10 Ehplodor

relevant ? an old never adressed issue : #517

This feature just provides convenience for knowing what is typing, for converting the input to English maybe is another feature.

However, it is possible in the logic, I think you can fork my code and add an input box on top, then update the prompt with the translated text 🤔.

donlinglok1 avatar Oct 19 '22 10:10 donlinglok1

In most cases jQuery can be substituted by pure javascript methods.

Element.insertAdjacentHTML() Document.querySelector() jQuery.getScript alternative in native JavaScript

Thanks for the suggestion, now the code won't include jQuery.

donlinglok1 avatar Oct 20 '22 04:10 donlinglok1

relevant ? an old never adressed issue : #517

This feature just provides convenience for knowing what is typing, for converting the input to English maybe is another feature.

However, it is possible in the logic, I think you can fork my code and add an input box on top, then update the prompt with the translated text 🤔.

@Ehplodor

actually it is easy to implement. image (823KB GIFs) ezgif-5-2ffddd21eb

donlinglok1 avatar Oct 20 '22 05:10 donlinglok1

Added Reverse Translate.

donlinglok1 avatar Oct 21 '22 08:10 donlinglok1

This can be done as a single .js file, and it can be distributed as a custom script on wiki's https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Custom-Scripts page. As his feature is basically for non-English users, I do not want to add it to the main repository.

AUTOMATIC1111 avatar Oct 21 '22 13:10 AUTOMATIC1111

This can be done as a single .js file, and it can be distributed as a custom script on wiki's https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Custom-Scripts page. As his feature is basically for non-English users, I do not want to add it to the main repository.

Thanks for the reply, I will soon try to split the code from the main repository into a single .js file, and then distribute it to the custom script wiki.

donlinglok1 avatar Oct 21 '22 14:10 donlinglok1

This can be done as a single .js file, and it can be distributed as a custom script on wiki's https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Custom-Scripts page. As his feature is basically for non-English users, I do not want to add it to the main repository.

@AUTOMATIC1111 @ClashSAN Hi, I have moved the code to a custom script repo.

https://github.com/donlinglok/realtime-prompt-translate-for-sd-webui

Realtime Prompt Translate

These tools can translate your prompt to your native language for review or let you input your native language and translate it to English for input.

donlinglok1 avatar Oct 25 '22 05:10 donlinglok1

This can be done as a single .js file, and it can be distributed as a custom script on wiki's https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Custom-Scripts page. As his feature is basically for non-English users, I do not want to add it to the main repository.

@AUTOMATIC1111 @ClashSAN Hi, I have moved the code to a custom script repo.

https://github.com/donlinglok/realtime-prompt-translate-for-sd-webui

Realtime Prompt Translate

These tools can translate your prompt to your native language for review or let you input your native language and translate it to English for input.

just patched a bug fix, tested on Windows.

donlinglok1 avatar Oct 25 '22 13:10 donlinglok1