Skip to content
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

side-by-side original and translation #219

Merged
merged 1 commit into from
Mar 8, 2024

Conversation

tiropictor
Copy link

Added side-by-side original/translation option.

(Seen this request on forum, and actually personally for me it's more convenient to see text in two columns, much easier to refer to original, if translation isn't clear enough)

Screenshot 2024-03-07 at 21 07 19
Screenshot 2024-03-07 at 21 08 11

@bookfere
Copy link
Owner

bookfere commented Mar 8, 2024

Thank you for your great idea and effort! I truly appreciate your contribution.

After testing the code, however, I found that there are some areas for improvement and additional unittest cases that need to be applied. But no worries, I will address this after merging the PR.

@bookfere bookfere merged commit 66f67cf into bookfere:master Mar 8, 2024
1 check passed
@tiropictor tiropictor deleted the new_branch branch March 8, 2024 07:01
@tiropictor
Copy link
Author

Thank you for your great idea and effort! I truly appreciate your contribution.

After testing the code, however, I found that there are some areas for improvement and additional unittest cases that need to be applied. But no worries, I will address this after merging the PR.

Hey! I've checked the code and update looks much better than my initial offer %)

Anyway, I came here to inform that following part of code may cause some issues:
etree.SubElement(tr, 'td', attrib={'width': '10%'})
I've tried similar approach, and if in e-reader switch to own style (turn off built-in epub styling) then middle "empty" column collapses to zero width and then left and right columns sticks to each other, and it's kinda impossible to sort out where original ends and translation starts. And in my personal case, switching off epub styling is every day practice, because I usually prefer a bit larger font size than it is built into book.

That was the reason why string of special symbols were inserted into that middle column. Because then it holds its width no matter if any styling applied or not.
@bookfere

@bookfere
Copy link
Owner

bookfere commented Mar 12, 2024

Thank you for your reminder.

I noticed that you used xml_escape('&#xA0;&#xA0;&#xA0;&#xA0;') to create a gap between two <td> elements. However, it's important to note that this method doesn't scale the gap as a percentage width would do on screens of various sizes.

The issue of the middle "empty" column collapsing, as you observed, is attributed to the <table> element lacking a width attribute, as outlined by the width calculation rules specified on the HTML specification. Without this attribute, the width of <td> elements will exhibit unexpected behavior, as you experienced.

A percentage specification (e.g., width="20%") is based on the percentage of the horizontal space available to the table (between the current left and right margins, including floats).

Since only the intrinsic attributes of the table and its children elements are used here, compatibility issues should be minimal, even on older devices that may not fully support modern stylesheets.

However, it's worth noting that this is an ideal scenario and may not cover all possible conditions. If your device encounters unexpected results, please provide more details for resolving this issue.

@tiropictor
Copy link
Author

So, I decided to test your current version, and I see that middle column width is quite minor problem regarding to complete translations mismatch within one table.. Screenshot attached
image
image

@bookfere
Copy link
Owner

Have you enabled the "Merge to Translation" option and also used the cached translation?

If so, I have encountered the same issue. The problem originated from the feature I introduced in commit c89e735, which disrupted the translation order. This was primarily due to an unreasonable implementation. I have fixed the issue, and I will @ you once the fix is committed. Please feel free to test it at your convenience.

If this situation does not align with the one I mentioned, kindly inform me. Thank you.

@bookfere
Copy link
Owner

The dislocation issue has been addressed in commit 7cc8191. @tiropictor

@tiropictor
Copy link
Author

I've downloaded latest version from Github, deleted all caches, and re-translated the book. As result, I can confirm that translations are now on correct places along with originals. Going to post another separate comment with details on middle column / gap between original and translation.

@tiropictor
Copy link
Author

I use one of latest OnyxBoox (with color e-ink), and KOReader app as my main reading app. None of them seem to be outdated %)

KOReader is nearly perfect because it's open source and as flexible as I can imagine. And it has built-in Calibre support. But I also tried to open resulting ebooks on default built-in unerasable BOOX reader, and results were much worse.

So. Here are some images. Latest plugin version, ebook styles ON:
image
(notice the gap)

image
(notice the gap AND difference in width of columns)

image
(not even close to 50/50 or 45/10/45)

Now all the same EXCEPT now ebook style is OFF (you can see the typeface and font size changed):
image
(the gap, the widths)

image
(the gap, the widths..)

Now a couple of photos of ebook which I converted using my ugly code (the reader and the app are the same).
WITH ebook style ON:
image
the gap now definitely exists. But widths of columns are definitely not 50/50 or 45/45..

image
all the same here.

Now with ebook style OFF:
image
the gap persists, the widths are different again.

image
just to be sure that same here.

So, you can definitely see that table column widths does not stay exactly as it is written in ebook code. Even with styles applied, reading app renderer is feeling fine to minimize empty column width, ignoring cell attributes, and change widths according to its own taste.

Believe me, I've spent HOURS trying to figure out best way to keep the gap, and those empty spaces codes were really the only way I found persistent.

@tiropictor
Copy link
Author

Maybe it would be even better to allow user to set this gap width in settings, like "narrow / medium / wide" and according to that setting put there appropriate number of those spaces into middle column? Let's say 3 for narrow, 5 for medium and 8 for wide..

@bookfere
Copy link
Owner

Thanks for the detailed information. After reviewing your screenshots, your advice seems reasonable. I will implement an option that allows users to control the number of non-breaking space for the layout.

@bookfere
Copy link
Owner

Please check out the commit cd10ef3 and test latest version. @tiropictor

@tiropictor
Copy link
Author

Maan!! This! Is! PURE! AWESOMNESS!!!!
giphy

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