diff --git a/eoaconvert.py b/eoaconvert.py index fc7c493..3bd2e11 100755 --- a/eoaconvert.py +++ b/eoaconvert.py @@ -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") diff --git a/libeoaconvert.py b/libeoaconvert.py index 7341718..090795f 100644 --- a/libeoaconvert.py +++ b/libeoaconvert.py @@ -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"] @@ -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) diff --git a/tralics2django.py b/tralics2django.py index 1e3d284..527cfd5 100755 --- a/tralics2django.py +++ b/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 @@ -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) diff --git a/tralics2epub.py b/tralics2epub.py index 844b3c9..8abf3eb 100755 --- a/tralics2epub.py +++ b/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 @@ -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: