Skip to content

Commit

Permalink
[ding2tei] Place @xml:lang (more) correctly
Browse files Browse the repository at this point in the history
Now:
 - at top-level text element: source language
 - at each cit@type="trans": target language

Previously:
 - at the top-level text element: target language
 - at each quote element: the respective language
  • Loading branch information
respiranto authored and humenda committed Apr 20, 2022
1 parent 15cbc90 commit 3596640
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 17 deletions.
12 changes: 10 additions & 2 deletions importers/ding2tei/src/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ contributors =
-- | Date of last output-affecting change of this program.
-- Must be given as YYYY-MM-DD.
publicationDate :: String
publicationDate = "2022-04-15"
publicationDate = "2022-04-18"

status :: String
status = "stable"
Expand Down Expand Up @@ -174,12 +174,20 @@ changes =
, Change "1.8.1" "0.2.1" [person_eleichtfuss] "2020-10-28"
[ "Mark units with annotated inflected forms as verbs."
]
, Change "1.9" "1" [person_eleichtfuss] "2022-04-15"
, Change "1.9" "1" [person_eleichtfuss] "2022-04-18"
[ "Update to Ding version 1.9."
, unwords
[ "Unify xr elements by @type."
, "(Previously, each xr element contained exactly one ref element.)"
]
, unwords
[ "Place @xml:lang (more) correctly:"
, "at top-level text element (source language)"
, "and at cit@type=\"trans\" (target language)."
, "(Previously,"
, "the target language was given at the top-level text element, and"
, "the respective language at each quote element.)"
]
]
]

Expand Down
31 changes: 16 additions & 15 deletions importers/ding2tei/src/Language/TEI/ToXML/Body.hs
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,15 @@ import Language.TEI.ToXML.Ident
-- ([Attr], String), (Attr, Element), ([Attr], [Element]), Attr.
-- * If a pair is provided, the left element is always the attribute (list)
-- and the right element the content.
-- * The placement of the @xml:lang is suggested in the example lg1-lg2.tei
-- file. (<teiHeader>, <text xml:lang="TGT">, top level <form>, any
-- <quote>)
-- * The @xml:lang attribute is placed
-- - on the top-level <text> element (source language), and
-- - on cit@type="trans" elements (target language).
-- - This includes translations of examples.
-- * Reasoning: All but translations are in the source language, this is
-- the minimal approach.
-- * Note that there are some fixed abbreviations (e.g., for grammatical
-- gender, or register), which violate this (usually English; TODO?).
-- * lg1-lg2.tei suggests otherwise.
-- * TEI Lex-0 suggests instead to add the attribute to <entry> and <cit>
-- elements.

Expand All @@ -78,7 +84,7 @@ convBody body srcLang tgtLang = convBody' body

convBody' :: Body Entry -> Element
convBody' (Body entries)
= unode "text" $ (,) xmlLangTgt
= unode "text" $ (,) xmlLangSrc
$ unode "body"
$ map convEntry $ entries

Expand Down Expand Up @@ -122,7 +128,6 @@ convBody body srcLang tgtLang = convBody' body
-- 2020-05-03)
-- * Nest inside the main form.
-- b) TEI Lex-0 (3.3): suggests value as content, e.g. <tns>pres</tns>.
-- * Not followed.
-- c) TEI P5
-- * 9.3.1: grammar tags
-- * <tns> doc: tns, mood example: <tns value="..."/>
Expand Down Expand Up @@ -160,13 +165,9 @@ convBody body srcLang tgtLang = convBody' body
-- Note: inflected forms are dropped for now - unsure how to encode. (TODO)
convTranslation :: Translation -> Element
convTranslation trans = unode "cit"
( [uattr "type" "trans"]
, unode "quote"
( xmlLangTgt
, translationOrth trans
)
:
(maybe id (:)
( [uattr "type" "trans", xmlLangTgt]
, unode "quote" (translationOrth trans)
: (maybe id (:)
(convGrammar $ translationGrammar trans)
$ (map convUsage $ translationUsages trans)
++ (map (convAbbrev "cit") $ translationAbbrevs trans)
Expand All @@ -185,12 +186,12 @@ convBody body srcLang tgtLang = convBody' body
convExample :: Example -> Element
convExample (Example srcEx tgtExs) = unode "cit"
( [uattr "type" "example"]
, unode "quote" (xmlLangSrc, srcEx) : map convExTrans tgtExs
, unode "quote" srcEx : map convExTrans tgtExs
)
where
convExTrans :: String -> Element
convExTrans = unode "cit" . (,) (uattr "type" "trans")
. unode "quote" . (,) xmlLangTgt
convExTrans = unode "cit" . (,) [uattr "type" "trans", xmlLangTgt]
. unode "quote"


convRefGroup :: ReferenceGroup -> Element
Expand Down

0 comments on commit 3596640

Please sign in to comment.