06-23-2021, 10:58 AM | #1 |
Enthusiast
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'?> |
06-23-2021, 11:06 AM | #2 |
Sigil Developer
Posts: 8,102
Karma: 5450184
Join Date: Nov 2009
Device: many
|
Typically you add it to the html tag
|
Advert | |
|
06-23-2021, 11:20 AM | #3 |
Enthusiast
Posts: 32
Karma: 10
Join Date: Aug 2020
Device: Tablet
|
In each HTML file?
Can you give an example? |
06-23-2021, 01:21 PM | #4 |
Sigil Developer
Posts: 8,102
Karma: 5450184
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. |
06-23-2021, 02:58 PM | #5 |
Running with scissors
Posts: 1,556
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.
|
Advert | |
|
06-23-2021, 03:12 PM | #6 | |
Wizard
Posts: 2,297
Karma: 12126329
Join Date: Jul 2012
Device: Kobo Forma, Nook
|
Quote:
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" Code:
<html xmlns="http://www.w3.org/1999/xhtml"> Code:
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> 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 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. |
|
06-23-2021, 04:14 PM | #7 |
Enthusiast
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. |
06-23-2021, 04:14 PM | #8 |
Sigil Developer
Posts: 8,102
Karma: 5450184
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. |
06-24-2021, 05:13 AM | #9 |
Enthusiast
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?
|
06-24-2021, 01:34 PM | #10 |
Bibliophagist
Posts: 39,634
Karma: 154147704
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
|
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. |
06-24-2021, 02:44 PM | #11 | |
Wizard
Posts: 2,297
Karma: 12126329
Join Date: Jul 2012
Device: Kobo Forma, Nook
|
Quote:
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> "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. |
|
06-25-2021, 06:06 PM | #12 |
Wizard
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. |
|
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 |