Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Language specifics
  • Loading branch information
Klaus Thoden committed Jan 23, 2018
1 parent fce223f commit 1e278a8
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 8 deletions.
2 changes: 1 addition & 1 deletion eoaconvert.py
Expand Up @@ -1061,7 +1061,7 @@ def cleanup():
# new version #
###############

formatted_references = libeoaconvert.format_citations(set_citations, bib_database + ".bib")[0]
formatted_references = libeoaconvert.format_citations(set_citations, bib_database + ".bib", strLanguage)[0]

# to check: is the order correct?
entries = formatted_references.findall(".//div")
Expand Down
19 changes: 16 additions & 3 deletions libeoaconvert.py
Expand Up @@ -34,7 +34,7 @@
Datei = open('tmp_files/xelatex-run-images.log', 'w')

# Setup of various dictionaries for localization of various elements
dictLangFootnotes = {"english" : "Footnotes", "italian" : "Note a piè pagina", "french" : "notes en bas de page", "german" : "Fußnoten", "de" : "Fußnoten", "en" : "Footnotes"}
dictLangFootnotes = {"it" : "Note a piè pagina", "fr" : "notes en bas de page", "de" : "Fußnoten", "en" : "Footnotes"}

# the new-style footnotes that use LaTeX bigfoot show up in the following order:
footnote_groups = ["decimal", "lower-latin"]
Expand Down Expand Up @@ -129,11 +129,24 @@ def deb_var(obj):
print("DEBUG: %s: %s" % (name, obj))
# def deb_var ends here

def two_letter_language(language_string):
"""Return a two letter code for a language"""

if language_string in ["english", "en"]:
return "en"
elif language_string in ["german", "deutsch", "de"]:
return "de"
elif language_string in ["french", "fr"]:
return "fr"
elif language_string in ["italian", "it"]:
return "it"
# two_letter_language ends here

# next function adapted from TEI2EOADjango
def format_citations(used_citekeys, bibdata):
def format_citations(used_citekeys, bibdata, language):
"""Return a formatted xmlstring of the used citations"""

md_file_header = "---\nlang: en\ntitle: Citations\n...\n\n"
md_file_header = "---\nlang: %s\ntitle: Citations\n...\n\n" % two_letter_language(language)

with open("tmp_files/used_citations.md", "w") as citation_formatter:
citation_formatter.write(md_file_header)
Expand Down
4 changes: 2 additions & 2 deletions tralics2django.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
# -*- coding: utf-8; mode: python -*-
# Time-stamp: <2018-01-17 14:54:34 (kthoden)>
# Time-stamp: <2018-01-23 10:38:24 (kthoden)>

import pickle
import os
Expand Down Expand Up @@ -1001,7 +1001,7 @@ def bring_footnote_down_django(footnote, fragment, footnote_number, object_numbe
xmlEOAsection.set("order", str(intObjectNumber))
intObjectNumber += 1
xmlHead = etree.Element("head")
xmlHead.text = libeoaconvert.dictLangFootnotes[xmlEOAchapter.get("language")]
xmlHead.text = libeoaconvert.dictLangFootnotes[libeoaconvert.two_letter_language(xmlEOAchapter.get("language"))]
xmlEOAsection.append(xmlHead)
xmlResult.append(xmlEOAsection)

Expand Down
4 changes: 2 additions & 2 deletions tralics2epub.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
# -*- coding: utf-8; mode: python -*-
# Time-stamp: <2017-12-05 16:14:54 (kthoden)>
# Time-stamp: <2018-01-23 10:38:00 (kthoden)>

import os
import sys
Expand Down Expand Up @@ -599,7 +599,7 @@ class FootnoteError(Exception):
continue
xmlNewFootnotes = etree.Element("div")
xmlNewFootnotesHeader = etree.Element("h3")
xmlNewFootnotesHeader.text = libeoaconvert.dictLangFootnotes[xmlChapter.get("language")]
xmlNewFootnotesHeader.text = libeoaconvert.dictLangFootnotes[libeoaconvert.two_letter_language(xmlChapter.get("language"))]
xmlNewFootnotes.append(xmlNewFootnotesHeader)

for grouping, notes in groupings:
Expand Down

0 comments on commit 1e278a8

Please sign in to comment.