Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Formats > ePub

Notices

Reply
 
Thread Tools Search this Thread
Old 06-23-2021, 10:58 AM   #1
abraum
Enthusiast
abraum began at the beginning.
 
Posts: 32
Karma: 10
Join Date: Aug 2020
Device: Tablet
Add xml:lang to ePub

Hi,

since a few days i use reasily instead of moon+reader. Reasily support "custom css" where i can add my own css code. here is an example for breaking words: https://reasily.blogspot.com/2018/10...h-hyphens.html

But this doesn't work for my perhaps because of wrong or missing "xml:lang"? where can i add this to the epub? The first line in all xhtml files is

Code:
<?xml version='1.0' encoding='utf-8'?>
can i add it in this line?
abraum is offline   Reply With Quote
Old 06-23-2021, 11:06 AM   #2
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 7,871
Karma: 5449552
Join Date: Nov 2009
Device: many
Typically you add it to the html tag
KevinH is online now   Reply With Quote
Advert
Old 06-23-2021, 11:20 AM   #3
abraum
Enthusiast
abraum began at the beginning.
 
Posts: 32
Karma: 10
Join Date: Aug 2020
Device: Tablet
In each HTML file?

Can you give an example?
abraum is offline   Reply With Quote
Old 06-23-2021, 01:21 PM   #4
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 7,871
Karma: 5449552
Join Date: Nov 2009
Device: many
Yes on each html file. Add it as an attribute to the html tag.

Code:
xml:lang="en"

See
https://en.wikipedia.org/wiki/EPUB

for a specific example.

It also pays to set your dc:language metadata to the primary language of your epub.

Last edited by KevinH; 06-23-2021 at 01:27 PM.
KevinH is online now   Reply With Quote
Old 06-23-2021, 02:58 PM   #5
hobnail
Running with scissors
hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.
 
Posts: 1,552
Karma: 14325282
Join Date: Nov 2019
Device: none
My suggestion would be to use sigil to edit your epubs. There's a forum here for it that also has instructions for downloading it. Sigil has a plugin called access-aide; one click with it and adds the xml:lang line to all of your book's files that need it.
hobnail is offline   Reply With Quote
Advert
Old 06-23-2021, 03:12 PM   #6
Tex2002ans
Wizard
Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.
 
Posts: 2,297
Karma: 12126329
Join Date: Jul 2012
Device: Kobo Forma, Nook
Quote:
Originally Posted by abraum View Post
But this doesn't work for my perhaps because of wrong or missing "xml:lang"? where can i add this to the epub?
1. Which language is your book?

You use this information to figure out which codes to use. For example:

en = English
de = German
fr = French
es = Spanish

2. You go into your chapters and add a:

Code:
lang="en" xml:lang="en"
to your <html>. So, if this is the original:

Code:
<html xmlns="http://www.w3.org/1999/xhtml">
you change it to:

Code:
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
This now says: "Hey, all the HTML inside of here is English."

3. Go into your EPUB's metadata and make sure the language is correct too.

In Sigil, you get there by Tools > Metadata Editor.

You should see a Language or dc:language column:

Code:
Language   |   en
This is saying: "Hey, this entire book is English"!

4. To double-check the languages are all applied correctly, you can also use Sigil's/Calibre's Spellcheck Lists.

In Sigil, press Tools > Spellcheck > Spellcheck.

In Calibre, press Tools > Check Spelling.

This will pop up a list of all Words + # of Times Used + Language.
Tex2002ans is offline   Reply With Quote
Old 06-23-2021, 04:14 PM   #7
abraum
Enthusiast
abraum began at the beginning.
 
Posts: 32
Karma: 10
Join Date: Aug 2020
Device: Tablet
OK, this works when i use 'de' but not with 'de-DE'. This is what a user wrote in the reasily faq.

Thanks.
abraum is offline   Reply With Quote
Old 06-23-2021, 04:14 PM   #8
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 7,871
Karma: 5449552
Join Date: Nov 2009
Device: many
Aside:
Technically for epub2, according to the official spec only xml:lang is a legal attribute of the html tag as lang was not enabled until epub3/html5. If both are present xml:lang takes precedence.
KevinH is online now   Reply With Quote
Old 06-24-2021, 05:13 AM   #9
abraum
Enthusiast
abraum began at the beginning.
 
Posts: 32
Karma: 10
Join Date: Aug 2020
Device: Tablet
is it possible to add more then one language so that breaking words works for english and german?
abraum is offline   Reply With Quote
Old 06-24-2021, 01:34 PM   #10
DNSB
Bibliophagist
DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.
 
DNSB's Avatar
 
Posts: 37,786
Karma: 150333332
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
Quote:
Originally Posted by abraum View Post
is it possible to add more then one language so that breaking words works for english and german?
You can't set two languages at the html level ( <html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xml:lang="de" xml:lang="en" lang="de" lang="en"> ) since this will trigger an already specified error. What you can do is to wrap the minority language segments in <span>s with the language tags though if that will help with hyphenation is outside my knowledge.

Last edited by DNSB; 06-26-2021 at 02:07 PM.
DNSB is offline   Reply With Quote
Old 06-24-2021, 02:44 PM   #11
Tex2002ans
Wizard
Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.
 
Posts: 2,297
Karma: 12126329
Join Date: Jul 2012
Device: Kobo Forma, Nook
Quote:
Originally Posted by abraum View Post
is it possible to add more then one language so that breaking words works for english and german?
Yes. You just have to mark the languages properly:

Code:
<p>An English phrase is: Thank you for the tacos.</p>

<p>A German phrase is: <span lang="de" xml:lang="de">Danke für die tacos</span>.</p>

<p>A Spanish phrase is: <span lang="es" xml:lang="es">Gracias por los tacos</span>.</p>
For more information/tips, I recently wrote a detailed tutorial here:

"Japanese characters not showing up on some devices"

If you mark your code properly, Multi-Language Hyphenation should work in a properly designed reader.

But actual ereader support? Unsure.

I know that Kobo allows multiple hyphenation dictionaries... but I don't know if it does hyphenation at the book- or word-level.

Note: I know Multi-Language Hyphenation definitely works in LaTeX + Word/LibreOffice.

Other Advantages of Language Markup

Text-to-Speech (TTS)

TTS will know how to speak certain words. For example:

"tacos" in English =/= the way "tacos" is spoken in Spanish.

Again, unsure of actual ereaders that support multi-language TTS... but on the computer, there's actual screen readers where it works: JAWS + NVDA.

Multi-Language Spellchecking

The little red squigglies will be correct.

Here's a little trick I use to help mass mark "foreign words":

"Is there a way to use the selection in a Saved Search?" (Post #29)

Sigil recently added Multi-Language Spellchecking, so the same methods can now apply.

Auto-Translation

Think Google Translate. If it knows "Danke für die tacos" is German, it may be able to auto-translate that on the fly.

I know that PocketBook Reader (Android) has support for this. (Although I haven't tested it out in-depth yet.)

Dictionary

You know how you can press+hold a word to get a definition?

"die" in English =/= "die" (the) in German.

so this sentence:

"Danke für die tacos"

would need a German->English dictionary!

Last edited by Tex2002ans; 06-24-2021 at 02:49 PM.
Tex2002ans is offline   Reply With Quote
Old 06-25-2021, 06:06 PM   #12
Tex2002ans
Wizard
Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.
 
Posts: 2,297
Karma: 12126329
Join Date: Jul 2012
Device: Kobo Forma, Nook
Notjohn brought up Welsh hyphenation in another thread. I answered that there.

Last edited by Tex2002ans; 06-25-2021 at 06:06 PM. Reason: Whoops. Wrong thread.
Tex2002ans is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
xml:lang tage fredheim Conversion 5 04-25-2019 06:45 AM
xml:lang oddities jcsalomon ePub 1 06-06-2016 05:28 PM
xml:lang empty (pdf to epub) fxp33 Conversion 3 05-07-2015 11:40 PM
xml epub yuxi_kelly ePub 4 05-13-2011 10:52 AM
Add xml in META-INF Sylver Sigil 5 04-26-2011 03:17 AM


All times are GMT -4. The time now is 08:14 AM.


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