Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > KOReader

Notices

Reply
 
Thread Tools Search this Thread
Old 07-02-2020, 12:39 AM   #1
aldazo
Enthusiast
aldazo began at the beginning.
 
Posts: 27
Karma: 10
Join Date: Dec 2011
Device: Sony PRS-T1
offline translator

Hello,
I was using koreader on my android and the first time I was looking to translate a sentence, this message pop-up:

"Do you want to turn on Wi-Fi?"

So my initial response was to press "turn on" and I was pleasantly surprised to see how quick and well integrated was the online translator with the koreader and how nice it looked on the eink screen.

Then, when I was not able to connect to the internet, I tried to use the offline google translator app I have installed, so this time I pressed "cancel" instead of "turn on" and... nothing happened. I realized that there is not a direct option for bringing up an offline translator, so after some exploration I managed to bring it up by choosing the "share" option instead of the "translate" one...but it wasn't the same, it did not pop up but opened a whole new window, load relatively slowly and didn't look sharp on the eink screen.

The offline translator worked fine but I miss the overall speed, look and integration from the koreader's default (online only) translator. I know I can just keep the wifi on but more than less I find myself unable to connect to the internet.

So my question is:
what can I do/modify in order to get the default translator working offline? and/or what can I do/modify in order to get my offline google translator integrated/working similarly to the default one?

Any help is much appreciated.
aldazo is offline   Reply With Quote
Old 07-02-2020, 01:31 PM   #2
pazos
cosiñeiro
pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.
 
Posts: 1,271
Karma: 2200049
Join Date: Apr 2014
Device: BQ Cervantes 4
Quote:
Originally Posted by aldazo View Post
Hello,
what can I do/modify in order to get the default translator working offline?
Nothing. The default translator uses google translate service/API. There's no way to make it offline.

Quote:
Originally Posted by aldazo View Post
Hello,
what can I do/modify in order to get my offline google translator integrated/working similarly to the default one?
Nothing. Offline translators are android activities and have their own UI. You cannot integrate them with KOReader UI. Just open them.

KOReader supports offline dictionaries with stardict format. You can get a bilingual dict from the program itself but the offered dictionaries are not as good as google translate.

KOReader in android can also do queries in 3rd party apps. There're a few supported by default (Colordict and goldendict support overlays, so they won't switch you to a different activity but display an overlay on top of KOReader activity) but if you like the look&feel of KOReader UI is better to use the built-in dictionary.

If you manage to find a good offline translator apk you can add support yourself following https://github.com/koreader/koreader...ictionary-list but that won't replace the "translate option" but the "dictionary option".
pazos is offline   Reply With Quote
Old 07-02-2020, 07:58 PM   #3
aldazo
Enthusiast
aldazo began at the beginning.
 
Posts: 27
Karma: 10
Join Date: Dec 2011
Device: Sony PRS-T1
Thanks for the reply.
Quote:
Originally Posted by pazos View Post
Nothing. The default translator uses google translate service/API. There's no way to make it offline...
Nothing. Offline translators are android activities and have their own UI
I mean, the default translator do queries in the online google translator but displays it using the koreader UI; I think it should be possible to make it use the offline google translator and display it using the Koreader UI, or I am missing something? Maybe I am confusing things?

Quote:
Originally Posted by pazos View Post
...KOReader in android can also do queries in 3rd party apps. There're a few supported by default (Colordict and goldendict support overlays, so they won't switch you to a different activity but display an overlay on top of KOReader activity) but if you like the look&feel of KOReader UI is better to use the built-in dictionary.
The default 3rd party apps are for dictionaries, but I prefer translators because they can translate phrases or sentences. However, I use the build in dictionary for synonyms and definitions.

Quote:
Originally Posted by pazos View Post
If you manage to find a good offline translator apk you can add support yourself following https://github.com/koreader/koreader...ictionary-list but that won't replace the "translate option" but the "dictionary option".
For my offline translator I use the "share" link when highlighting. But maybe I should look for an offline translator that support overlay like the apps you mentioned before. Will the overlay use the koreader UI or the 3rd party app UI?

As a side note, I used the "Customize dictionary list" tutorial to modify the Fora dict query. I have Fora dict installed but when I wanted to use the external dictionary the "Fora" box was disable (grey out), so after an inquiry I found that the dictionaries.lua reads "com.ngc.fora", but in my android the folder's name is "com.ngc.fora.android".

So I created a notepad with only this inside:
Code:
return {
     { "Fora", "Fora Dict", false, "com.ngc.fora.android", "search" }, 
}
and rename it dictionaries.lua and put it inside the koreader folder. Thankfully it solved the problem.
aldazo is offline   Reply With Quote
Old 07-03-2020, 06:20 AM   #4
pazos
cosiñeiro
pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.
 
Posts: 1,271
Karma: 2200049
Join Date: Apr 2014
Device: BQ Cervantes 4
Yup, you're confusing a few things.

When you use the "share text" button or the dictionary lookup you're opening other activities. These activities did enable certain filters to let other activities notice they can do things with them (like share, process text or open a document).

That's why when you click "share text" you'll be prompted with activities that can handle text sharing (from Whatsapp to Twitter, note taking apps, dictionaries... whatever)

All activities have their own UI, because that's what they are (see https://developer.android.com/guide/...tro-activities)

What you want needs an application that provides a service, not an activity. That service needs to be available for other activities. If you find an offline translator that provides an service that can be bounded by 3rd party apps (using AIDL, for instance) then we can use its API like we use the API of google translate.
pazos is offline   Reply With Quote
Old 07-03-2020, 08:57 AM   #5
pazos
cosiñeiro
pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.
 
Posts: 1,271
Karma: 2200049
Join Date: Apr 2014
Device: BQ Cervantes 4
Microsoft Translation Android app has an Api: see https://github.com/MicrosoftTranslat...ster/Readme.md

(Description inin https://github.com/MicrosoftTranslat...or/service/app)

With that kind of services is possible to retrieve content and show it inside KOReader.

Last edited by pazos; 07-03-2020 at 09:01 AM.
pazos is offline   Reply With Quote
Old 07-03-2020, 05:46 PM   #6
aldazo
Enthusiast
aldazo began at the beginning.
 
Posts: 27
Karma: 10
Join Date: Dec 2011
Device: Sony PRS-T1
Quote:
Originally Posted by pazos View Post
Yup, you're confusing a few things.
When you use the "share text" button or the dictionary lookup you're opening other activities...
All activities have their own UI...
What you want needs an application that provides a service, not an activity. That service needs to be available for other activities...
Quote:
Originally Posted by pazos View Post
Microsoft Translation Android app has an Api...
With that kind of services is possible to retrieve content and show it inside KOReader.
I see now. I'm not a programmer but I have a very basic knowledge of coding (that's how I change the fora's folder thing mentioned in my previous post )
Well, it was nice while it lasted. Nevertheless, I found that the offline google translator has the feature "tap to translate" where you highlight text in your app (koreader) then press copy and a bubble will appear on the right side of the screen to bring the offline translator as an overlay, so at least it will not need to switch to a different activity.

Another thing I found was that there is this app: Translate On Screen/Screen Translate that brings an overlay to any app and can use the offline google translator (no needed so far thanks to google translator "tap to translate" feature). There is also this other app that works as a dictionary and as a translator: U-Dictionary Oxford that also has the overlay display and can do offline translations.

That's all from me now, thanks for your help, really appreciated .
aldazo is offline   Reply With Quote
Old 07-03-2020, 06:47 PM   #7
pazos
cosiñeiro
pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.
 
Posts: 1,271
Karma: 2200049
Join Date: Apr 2014
Device: BQ Cervantes 4
Hey aldazo, nice tips with the google translate app!. I didn't know about the "tap to translate" feature. It works well.

I see you have your workflow solved but maybe it is interesting for others: it turns out that you can open Google Translate on top of KOReader activity. That doesn't happen using the SHARE intent but works fine with PROCESS_TEXT intent.

Happily KOReader supports these kind of intents too (because it is what Kiwix use and being both opensource we shall not forget Kiwix!). So it is relatively easy to extend the "translate button" behaviour like we extended the "dictionary button" behaviour (ie: providing integration with 3rd party apps).

In fact if I create a dictionaries.lua with:
Code:
return {
    { "GTranslate", "Google Translate", true, "com.google.android.apps.translate", "text" },
}
and select that dict on the menu the overlay just pops over the activity exactly like when you use "tap to translate" feature.

I don't plan to implement it myself but I will be happy to help
pazos is offline   Reply With Quote
Old 07-05-2020, 01:40 AM   #8
aldazo
Enthusiast
aldazo began at the beginning.
 
Posts: 27
Karma: 10
Join Date: Dec 2011
Device: Sony PRS-T1
Hello again.
Quote:
Originally Posted by pazos View Post
...Offline translators are android activities and have their own UI. You cannot integrate them with KOReader UI. Just open them...
Quote:
Originally Posted by pazos View Post
...it turns out that you can open Google Translate on top of KOReader activity...So it is relatively easy to extend the "translate button" behaviour like we extended the "dictionary button" behaviour (ie: providing integration with 3rd party apps).
Just to be clear, does this mean it could be possible to bring the offline translator as an overlay using the koreader UI? or I am confusing things again?

Quote:
Originally Posted by pazos View Post
...it turns out that you can open Google Translate on top of KOReader activity. That doesn't happen using the SHARE intent but works fine with PROCESS_TEXT intent.
When you say "open ... on top of" using the PROCESS_TEXT intent, you mean opening it as an activity not necessarily as an overlay, correct?

Quote:
Originally Posted by pazos View Post
...So it is relatively easy to extend the "translate button" behaviour like we extended the "dictionary button" behaviour (ie: providing integration with 3rd party apps).
In fact if I create a dictionaries.lua with:
Code:
return {
    { "GTranslate", "Google Translate", true, "com.google.android.apps.translate", "text" },
}
and select that dict on the menu the overlay just pops over the activity exactly like when you use "tap to translate" feature.

I don't plan to implement it myself but I will be happy to help
You mean the "translate button" would manage a list of 3rd party translators to choose from the same way the "dictionary button" can bring on colordict, goldendict, fora, etc. Right?
In that case one should not use the dictionaries.lua to bring up translators because a dictionary pops up when you select one word, and the main function of a translator is to translate phrases or sentences.
It would be better to create a translators.lua that acts as a dictionary.lua but only when you select more than one word and hold the last word for about a second. I cannot imagine how much work would be needed but would be interesting.

Last edited by aldazo; 07-05-2020 at 01:47 AM.
aldazo is offline   Reply With Quote
Old 07-05-2020, 09:03 AM   #9
pazos
cosiñeiro
pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.pazos ought to be getting tired of karma fortunes by now.
 
Posts: 1,271
Karma: 2200049
Join Date: Apr 2014
Device: BQ Cervantes 4
Quote:
Originally Posted by aldazo View Post
Hello again.


1. Just to be clear, does this mean it could be possible to bring the offline translator as an overlay using the koreader UI? or I am confusing things again?


2. When you say "open ... on top of" using the PROCESS_TEXT intent, you mean opening it as an activity not necessarily as an overlay, correct?


3. You mean the "translate button" would manage a list of 3rd party translators to choose from the same way the "dictionary button" can bring on colordict, goldendict, fora, etc. Right?
In that case one should not use the dictionaries.lua to bring up translators because a dictionary pops up when you select one word, and the main function of a translator is to translate phrases or sentences.
It would be better to create a translators.lua that acts as a dictionary.lua but only when you select more than one word and hold the last word for about a second. I cannot imagine how much work would be needed but would be interesting.
1. Nope

2. Nope

3. Yes. That's exactly what needs to be implemented. Basically a copy of https://github.com/koreader/koreader/pull/5108/files. The example I gave on the previous post is to show that the platform code is there and works without modifications, but the frontend code to manage third party translators needs to be implemented.
pazos is offline   Reply With Quote
Old 07-05-2020, 07:00 PM   #10
aldazo
Enthusiast
aldazo began at the beginning.
 
Posts: 27
Karma: 10
Join Date: Dec 2011
Device: Sony PRS-T1
Quote:
Originally Posted by pazos View Post
1. Nope

2. Nope
Well, there go my hopes.

Quote:
Originally Posted by pazos View Post
3. Yes. That's exactly what needs to be implemented. Basically a copy of https://github.com/koreader/koreader/pull/5108/files. The example I gave on the previous post is to show that the platform code is there and works without modifications, but the frontend code to manage third party translators needs to be implemented.
Just one last question, all that coding, what programming language is it?
aldazo is offline   Reply With Quote
Old 07-06-2020, 09:44 AM   #11
Frenzie
Wizard
Frenzie ought to be getting tired of karma fortunes by now.Frenzie ought to be getting tired of karma fortunes by now.Frenzie ought to be getting tired of karma fortunes by now.Frenzie ought to be getting tired of karma fortunes by now.Frenzie ought to be getting tired of karma fortunes by now.Frenzie ought to be getting tired of karma fortunes by now.Frenzie ought to be getting tired of karma fortunes by now.Frenzie ought to be getting tired of karma fortunes by now.Frenzie ought to be getting tired of karma fortunes by now.Frenzie ought to be getting tired of karma fortunes by now.Frenzie ought to be getting tired of karma fortunes by now.
 
Posts: 1,619
Karma: 724945
Join Date: Oct 2014
Location: Antwerp
Device: Kobo Aura H2O
@aldazo That's Lua.
Frenzie is offline   Reply With Quote
Old 07-06-2020, 08:03 PM   #12
aldazo
Enthusiast
aldazo began at the beginning.
 
Posts: 27
Karma: 10
Join Date: Dec 2011
Device: Sony PRS-T1
Quote:
Originally Posted by Frenzie View Post
@aldazo That's Lua.
Thank you, much appreciated.
aldazo is offline   Reply With Quote
Reply

Tags
translator


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
DeepL.com translator. (ACX) dtp Kindle Developer's Corner 6 05-08-2018 02:00 PM
Ebook reader with translator Saido Apple Devices 0 01-23-2015 04:30 AM
Glo Automatic translator acex Kobo Reader 0 08-23-2013 03:43 PM
PW Bilingual Dictionary / Translator apeiron75 Amazon Kindle 1 05-14-2013 05:35 PM


All times are GMT -4. The time now is 03:48 PM.


MobileRead.com is a privately owned, operated and funded community.