diff options
author | John MacFarlane <jgm@berkeley.edu> | 2017-08-11 11:56:54 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2017-08-11 22:22:31 -0700 |
commit | 74212eb1b0e1757fc0ac3e5d45b0ee18bac491e5 (patch) | |
tree | 522b79da10f8838b0bd2665ddfa741eed0ecbeff /src/Text/Pandoc/Logging.hs | |
parent | 7892dcd353ff0efd24ed753061b9be8e556b0177 (diff) |
Added support for translations (localization) (see #3559).
* readDataFile, readDefaultDataFile, getReferenceDocx,
getReferenceODT have been removed from Shared and
moved into Class. They are now defined in terms of
PandocMonad primitives, rather than being primitve
methods of the class.
* toLang has been moved from BCP47 to Class.
* NoTranslation and CouldNotLoudTranslations have
been added to LogMessage.
* New module, Text.Pandoc.Translations, exporting
Term, Translations, readTranslations.
* New functions in Class: translateTerm, setTranslations.
Note that nothing is loaded from data files until
translateTerm is used; setTranslation just sets the
language to be used.
* Added two translation data files in data/translations.
* LaTeX reader: Support `\setmainlanguage` or `\setdefaultlanguage`
(polyglossia) and `\figurename`.
Diffstat (limited to 'src/Text/Pandoc/Logging.hs')
-rw-r--r-- | src/Text/Pandoc/Logging.hs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/Text/Pandoc/Logging.hs b/src/Text/Pandoc/Logging.hs index ac45b0a66..832a1f4df 100644 --- a/src/Text/Pandoc/Logging.hs +++ b/src/Text/Pandoc/Logging.hs @@ -95,6 +95,8 @@ data LogMessage = | CouldNotHighlight String | MissingCharacter String | Deprecated String String + | NoTranslation String + | CouldNotLoadTranslations String String deriving (Show, Eq, Data, Ord, Typeable, Generic) instance ToJSON LogMessage where @@ -195,6 +197,11 @@ instance ToJSON LogMessage where Deprecated thing msg -> ["thing" .= Text.pack thing, "message" .= Text.pack msg] + NoTranslation term -> + ["term" .= Text.pack term] + CouldNotLoadTranslations lang msg -> + ["lang" .= Text.pack lang, + "message" .= Text.pack msg] showPos :: SourcePos -> String @@ -282,6 +289,11 @@ showLogMessage msg = if null m then "" else ". " ++ m + NoTranslation t -> + "The term " ++ t ++ " has no translation defined." + CouldNotLoadTranslations lang m -> + "Could not load translations for " ++ lang ++ + if null m then "" else ('\n':m) messageVerbosity:: LogMessage -> Verbosity messageVerbosity msg = @@ -314,3 +326,5 @@ messageVerbosity msg = CouldNotHighlight{} -> WARNING MissingCharacter{} -> WARNING Deprecated{} -> WARNING + NoTranslation{} -> WARNING + CouldNotLoadTranslations{} -> WARNING |