LuteOrg / lute-v3

LUTE = Learning Using Texts: learn languages through reading.
https://luteorg.github.io/lute-manual/
MIT License
493 stars 46 forks source link

Multi-line sentence translation #428

Closed bwkimmel closed 2 months ago

bwkimmel commented 6 months ago

Is your feature request related to a problem? Please describe.

Sentence translation only translates the current line of text, even if the sentence spans multiple lines.

Describe the solution you'd like

Some texts may consistently include punctuation (periods), while others may not. Perhaps there could be a per-book setting (with a configurable default -- perhaps in the language settings?) to indicate what characters are considered sentence delimiters (and, in particular, whether newlines are considered sentence delimiters).

Alternatively, or in addition, perhaps there could be a separate option to pass all of the highlighted text (which may span multiple lines) to the configured sentence translation page.

Describe alternatives you've considered

Alternatives include:

Additional context

In the screenshot below, I have a word within a 2-line sentence selected. When I hit 't', only the line containing the highlighted word is passed to the translation page. I would like for both lines to be passed. This particular text consistently has periods to delimit sentences.

image
bwkimmel commented 6 months ago

Actually, a better solution, rather than a per-book import option, might be just to have separate hotkeys for "translate line" and "translate sentence". The former would work the same way it works currently. The latter would scan forwards and backwards for the previous and next sentence delimiter and translate everything in between. Sentence delimiters could be configurable per-language.

jzohrab commented 6 months ago

Thanks @bwkimmel .

The challenge here is that Lute thinks that sentences that break across lines are separate things. Parsing gets pretty tough with various scenarios, song lyrics, etc. Lute thinks these are two sentences, even though that's obviously not the case:

I have
a fast car.

I usually remove all of the unwanted newlines from simple imports ... but that gets messy. Sometimes I just live with it.

Sentence delimiters are configurable per language already :-) in the settings > language > forms.

jzohrab commented 2 months ago

I don't think I can implement anything for this ... but Lute does have a "translate page" option in the sidebar that really gives you what you need, without me implementing another feature (which could get tricky!)

image

Given the above, I'll close this. Cheers and thank you, LMK if you have a different idea.