Forum How do I...?

Specifying default hyphenation language

Jellby
Is it possible to specify a default per-document hyphenation language? I see that in hyph.css the default is set to english, and other languages are chosen when the "lang" attribute is set. What I'd like is a way to choose a language for elements that don't have this attribute. A way to set the language with CSS would be great, but all I see is using "lang" as a selector, not as a settable property...

While modifying hyph.css could be a workaround for a particular case, one should not be changing system files (if prince is installed in a system-wide localition) so often. And setting the hyphenate-patterns for the :root element in another file could be tricky if the exact location of the hyphenation patterns is not known.
mikeday
At the moment the default hyph.css file must be modified, or you can add a lang or xml:lang attribute to the root element. It could be possible to extend Prince to check for a user-specific style sheet at startup, but most installations are single-user these days anyway, and this behaviour is easy to achieve with an alias like this on Linux systems:
alias prince="/usr/bin/prince -s $HOME/.prince/default.css"
Jellby
Could maybe a command-line option be added in the future, just "--lang xx"? The thing is one may want to set the default language for every document, and changing a stylesheet every time is not very friendly. Of course, one could have a script that accepts the "--lang xx" option and then uses a xx.css stylesheet... but there's still the problem with paths for the hyphenation pattern files.

Indeed, the "correct" way is to set the xml:lang attribute for the root element, but there are cases where one does not control the source document, and where the language, if specified, is not set in the xml source. I'm thinking, for instance, of ePUB files, where the language is not necessarily given in xml:lang attributes, but in a separate metadata file
mikeday
The solution for that might be to handle the ePUB wrapper file format specifically, if there is sufficient demand for it. But the script wrapper would also be relatively easy to write, and the path issue is easy to get right if the /usr/bin/prince script itself is modified.
Jellby
Actually, I'm already creating a script for converting ePUB to PDF: http://www.mobileread.com/forums/showpost.php?p=591684&postcount=11
mikeday
Great, that could be really useful! Let us know how it goes.
kozayur
Is it possible to process ePub's table of content into the PDF file?
mikeday
Prince does not process the ePub manifest and table of contents yet, but it is possible that some of this could be done with JavaScript in Prince 8.0.