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

Improve swap lang button for language and text swapping #482

Open satti-hari-krishna-reddy opened 6 months ago

satti-hari-krishna-reddy commented 6 months ago

fixes #469

Description :

This pull request addresses the issue where switching languages doesn't copy already provided input and output. With the modified changes now when the languages are swapped the new input is our already provided output.

before : https://beta.apertium.org/index.eng.html#?dir=eng-spa&q=Dog to https://beta.apertium.org/index.eng.html#?dir=spa-eng&q=Dog

After : https://beta.apertium.org/index.eng.html#?dir=eng-spa&q=Dog to https://beta.apertium.org/index.eng.html#?dir=spa-eng&q=Perro

Changes Made : -Lifted state from the child component TextTranslationForm to the parent component Translator, passing the state and its corresponding setter functions as props and wrapped setSrcText and setTgtText in the function swapLangText to swap the text and passed it to LanguageSelector as a prop. Included that function in swapLangs function to call it whenever it is executed.

-Modified TextTranslationForm.test to accommodate the new changes made to TextTranslationForm. In LanguageSelector.test, checked whether swapLangText is actually getting called or not.

coveralls commented 6 months ago

Pull Request Test Coverage Report for Build 7537945566


Totals Coverage Status
Change from base Build 7484346259: -0.2%
Covered Lines: 1380
Relevant Lines: 1398

💛 - Coveralls
satti-hari-krishna-reddy commented 6 months ago

@sushain97 , could you please review my pull request?

sushain97 commented 6 months ago

This looks reasonable at first glance but I'll take a closer look tomorrow. I may have been wrong about the cleanest way to do this since I haven't looked at the code in a while. I appreciate the detailed PR description.

satti-hari-krishna-reddy commented 5 months ago

@sushain97 i moved swapLangs from src/components/translator/LanguageSelector.tsx to the src/components/translator/Translator.tsx and The swapping of languages and text is functioning as expected. However, this change has caused some issues in LanguageSelector.test.tsx. I made some adjustments to the test file to make it pass, but I think it might not be the optimal solution. Could you please take a look and help me on how to update the test accordingly?