-
Notifications
You must be signed in to change notification settings - Fork 9
Add Translate and Dictionary options to text selection in ReaderFragment #52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add Translate and Dictionary options to text selection in ReaderFragment #52
Conversation
…ctions Translate and Dictionary.
|
Is the dictionary supporting languages other than English? I tried with Telugu and it threw an error. Searching for Telugu words directly in OneLook website is also not working. |
|
It currently supports only English. It completely slipped my mind to check for other languages. I’ll update it soon to detect the language of the selected word and redirect to a suitable dictionary or translator. I’ll test it with a few different languages and share an update soon. Thanks for the review. |
…tching language code of book and adding to room db.
|
DESCRIPTION Add Translate and Dictionary options to text selection in VisualReaderFragment To support translation and dictionary lookup in different languages, book language from the API response is saved in new column language_code in books entity. Database migrations were added to ensure older app versions don’t crash when upgrading. For books already downloaded default "auto" will be added to language_code column. And once that book is open in reader, the API request is made to fetch its language, the language is then saved in room db. If a dictionary is not available for a particular language, redirection is done for web search TESTING |
|
Hello @ph4ni , This PR is now ready for review. |
|
If there are multiple languages in a book, will it prioritise the first one? example: https://wsindex.toolforge.org/books/Q135953686/ |
|
Yes, it will pick 'bn' in this example. |
DESCRIPTION
Add Translate and Dictionary options to text selection in VisualReaderFragment
Translate: Opens the selected text in Google Translate in a browser.
Dictionary: Opens the selected word in a suitable dictionary in a browser.
To support translation and dictionary lookup in different languages, book language from the API response is saved in new column language_code in books entity. Database migrations were added to ensure older app versions don’t crash when upgrading.
For books already downloaded default "auto" will be added to language_code column. And once that book is open in reader, the API request is made to fetch its language, the language is then saved in room db.
If a dictionary is not available for a particular language, redirection is done for web search
TESTING
Verified that selecting text triggers the Translate and Dictionary actions correctly.
Verified that each of the book languages mentioned in the 'all books' filter are giving proper results when clicking on dictionary or translate.
Verified that if there is no suitable dictionary, app is redirecting to web search.
Verified that db migration is working fine.
Verified that column language_code is updating properly in case newly downloaded books and old books too.