apertium / apertium-html-tools

Web application providing a fully localised interface for text/website/document translation, analysis and generation powered by Apertium.
http://wiki.apertium.org/wiki/Apertium-html-tools
GNU General Public License v3.0
41 stars 89 forks source link

Switching languages doesn't copy already provided input and output #469

Open sheeerio opened 1 year ago

sheeerio commented 1 year ago

IMO, using the current output as the new query would greatly improve UX.

Instead of https://beta.apertium.org/#?dir=spa-eng&q=Buenos%20Muchacho to https://beta.apertium.org/#?dir=eng-spa&q=Buenos%20Muchacho,

https://beta.apertium.org/#?dir=spa-eng&q=Buenos%20Muchacho to https://beta.apertium.org/#?dir=eng-spa&q=Good%20Boy?

satti-hari-krishna-reddy commented 6 months ago

hey @sheeerio Implementing this feature using the current output as the new query would indeed enhance the user experience.

satti-hari-krishna-reddy commented 6 months ago

hey @sushain97 When we click on the 'swap-langs' button, it only swaps srcLang and tgtLang, not the texts inside the forms of TextTranslationForm (i.e., srcText and tgtText). If the 'swap-langs' button also has access to setSrcText() and setTgtText(), we can update the text inputs accordingly. Before I start working on this, I'd like to discuss a possible approach. What if we pass setSrcText and setTgtText as props to both the component where the 'swap-lang' button relies and the TextTranslationForm component? This way, they'll have access to the state. We can define these states in the parent component and pass them as props for better interaction between the components. What are your thoughts on this?

sushain97 commented 6 months ago

@satti-hari-krishna-reddy rather than exposing all of that state to the children components, passing a single onLangSwap handler from the parent components that encapsulates both those functions might be cleaner.