stable-diffusion-webui
stable-diffusion-webui copied to clipboard
[New Feature] Realtime Prompt Translate & Reverse Translate
----2022-10-21----
Update! Added Reverse Translate, demo kinda like below:

Steps:
- click "en2jp" button to enable the feature.
- input text in prompt/neg_prompt, the translated prompt will display on top of the screen.
- (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):

In most cases jQuery can be substituted by pure javascript methods.
Element.insertAdjacentHTML() Document.querySelector() jQuery.getScript alternative in native JavaScript
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.
relevant ? an old never adressed issue : https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/517
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 🤔.
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.
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.
(823KB GIFs)

Added Reverse Translate.
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.
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.
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.
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.