aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Class.hs
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2017-08-12 12:17:38 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2017-08-12 12:17:38 -0700
commit622c3f2fa6c29ecc33502f63ae6f33e59c11c96c (patch)
treecd593e216eb9810e582e4dab9a5d1b09f3248c50 /src/Text/Pandoc/Class.hs
parentb6e0add76aa2479fde9696f1ab25c1101de4de31 (diff)
downloadpandoc-622c3f2fa6c29ecc33502f63ae6f33e59c11c96c.tar.gz
Change to yaml for translation files.
Diffstat (limited to 'src/Text/Pandoc/Class.hs')
-rw-r--r--src/Text/Pandoc/Class.hs13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/Text/Pandoc/Class.hs b/src/Text/Pandoc/Class.hs
index 80ebd58b4..074181c92 100644
--- a/src/Text/Pandoc/Class.hs
+++ b/src/Text/Pandoc/Class.hs
@@ -79,7 +79,7 @@ module Text.Pandoc.Class ( PandocMonad(..)
, toLang
, setTranslations
, translateTerm
- , Translations(..)
+ , Translations
, Term(..)
) where
@@ -135,7 +135,8 @@ import System.IO (stderr)
import qualified Data.Map as M
import Text.Pandoc.Error
import Text.Pandoc.BCP47 (Lang(..), parseBCP47, renderLang)
-import Text.Pandoc.Translations (Term(..), Translations(..), readTranslations)
+import Text.Pandoc.Translations (Term(..), Translations, lookupTerm,
+ readTranslations)
import qualified Debug.Trace
#ifdef EMBED_DATA_FILES
import Text.Pandoc.Data (dataFiles)
@@ -343,8 +344,8 @@ getTranslations = do
Nothing -> return mempty -- no language defined
Just (_, Just t) -> return t
Just (lang, Nothing) -> do -- read from file
- let translationFile = "translations/" ++ renderLang lang ++ ".trans"
- let fallbackFile = "translations/" ++ langLanguage lang ++ ".trans"
+ let translationFile = "translations/" ++ renderLang lang ++ ".yaml"
+ let fallbackFile = "translations/" ++ langLanguage lang ++ ".yaml"
let getTrans bs =
case readTranslations (UTF8.toString bs) of
Left e -> do
@@ -374,8 +375,8 @@ getTranslations = do
-- Issue a warning if the term is not defined.
translateTerm :: PandocMonad m => Term -> m String
translateTerm term = do
- Translations termMap <- getTranslations
- case M.lookup term termMap of
+ translations <- getTranslations
+ case lookupTerm term translations of
Just s -> return s
Nothing -> do
report $ NoTranslation (show term)