EPUB writer: Allow lang variable to set language in metadata.

Defaults to locale language if `lang` is not set.
This commit is contained in:
John MacFarlane 2012-01-01 14:32:27 -08:00
parent da8425598a
commit 4e30f24974
2 changed files with 9 additions and 5 deletions

7
README
View file

@ -418,9 +418,10 @@ Options
By default, pandoc will include the following metadata elements:
`<dc:title>` (from the document title), `<dc:creator>` (from the
document authors), `<dc:language>` (from the locale), and
`<dc:identifier id="BookId">` (a randomly generated UUID). Any of
these may be overridden by elements in the metadata file.
document authors), `<dc:language>` (from the `lang` variable, or,
if is not set, the locale), and `<dc:identifier id="BookId">` (a
randomly generated UUID). Any of these may be overridden by elements
in the metadata file.
`-D` *FORMAT*, `--print-default-template=`*FORMAT*
: Print the default template for an output *FORMAT*. (See `-t`

View file

@ -120,8 +120,11 @@ writeEPUB mbStylesheet opts doc@(Pandoc meta _) = do
let chapterEntries = zipWith chapterToEntry [1..] chapters
-- contents.opf
lang <- catch (liftM (takeWhile (/='.')) $ getEnv "LANG")
(\_ -> return "en-US")
localeLang <- catch (liftM (takeWhile (/='.')) $ getEnv "LANG")
(\_ -> return "en-US")
let lang = case lookup "lang" (writerVariables opts') of
Just x -> x
Nothing -> localeLang
uuid <- getRandomUUID
let chapterNode ent = unode "item" !
[("id", takeBaseName $ eRelativePath ent),