Skip to content

Conversation

@janiceferns02
Copy link
Contributor

@janiceferns02 janiceferns02 commented Oct 23, 2025

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

Dictionary chooser

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.

@ph4ni
Copy link
Collaborator

ph4ni commented Oct 25, 2025

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.

@janiceferns02
Copy link
Contributor Author

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.

@bodhisattwawiki bodhisattwawiki requested a review from ph4ni October 31, 2025 11:41
@janiceferns02
Copy link
Contributor Author

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.

@janiceferns02
Copy link
Contributor Author

Hello @ph4ni , This PR is now ready for review.

@ph4ni
Copy link
Collaborator

ph4ni commented Nov 5, 2025

If there are multiple languages in a book, will it prioritise the first one? example: https://wsindex.toolforge.org/books/Q135953686/

@janiceferns02
Copy link
Contributor Author

Yes, it will pick 'bn' in this example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants