diff options
author | kaa <kaa@disroot.org> | 2025-07-27 20:27:38 -0700 |
---|---|---|
committer | kaa <kaa@disroot.org> | 2025-07-27 20:27:38 -0700 |
commit | 40eb84a9b77a383bfa0377bf4a8bb6bbaa4d3edd (patch) | |
tree | 6d25c3453ff5c23d196175a8f311e3b36cc38d18 /lib/translate/translate.go | |
parent | d1ea3403d3d31e44e9e73a077c640bc69e349357 (diff) |
fmt
Diffstat (limited to 'lib/translate/translate.go')
-rw-r--r-- | lib/translate/translate.go | 189 |
1 files changed, 91 insertions, 98 deletions
diff --git a/lib/translate/translate.go b/lib/translate/translate.go index 5414425..d02e8b4 100644 --- a/lib/translate/translate.go +++ b/lib/translate/translate.go @@ -1,9 +1,9 @@ package translate import ( - "pgset/lib/parse" "fmt" "io" + "pgset/lib/parse" ) func a(language string) string { @@ -23,72 +23,71 @@ func footer(language string) string { } // Among all languages, these are defined: -// * Prefix: What should come before a string of body text -// * Postfix: What should come after a string of body text -// * Header: Start of document -// * Footer: End of document +// - Prefix: What should come before a string of body text +// - Postfix: What should come after a string of body text +// - Header: Start of document +// - Footer: End of document +// // Maps for these tags, beginning and end if non-empty: -// * a: anchors to bookmarks and urls, switch on attribute -// * img: images -// * p: paragraphs -// * meta: metadata -// * h{1,2,3,4,5}: headings -// * strong, i: emphasis -// * table, tbody, tr, td: Table of Contents -// * div: chapter separations -// * br: line breaks +// - a: anchors to bookmarks and urls, switch on attribute +// - img: images +// - p: paragraphs +// - meta: metadata +// - h{1,2,3,4,5}: headings +// - strong, i: emphasis +// - table, tbody, tr, td: Table of Contents +// - div: chapter separations +// - br: line breaks +// // All other tags are ignored. -// * span: Unwanted metadata, contents to be consumed -var Definitions = map[string]map[string]any { +// - span: Unwanted metadata, contents to be consumed +var Definitions = map[string]map[string]any{ "ConTeXt": { // Must generate. - "a": a, - "/a": ``, - "meta": meta , + "a": a, + "/a": ``, + "meta": meta, "/meta": ``, - "div": div, - "/div": ``, + "div": div, + "/div": ``, // img tags are empty - "img": img, + "img": img, "Header": header, "Footer": footer, // Constants. - "p": ``, - "/p": ``, - "i": ``, - "/i": ``, - "strong": ``, + "p": ``, + "/p": ``, + "i": ``, + "/i": ``, + "strong": ``, "/strong": ``, - "table": ``, - "/table": ``, - "tr": ``, - "/tr": ``, - "tbody": ``, - "/tbody": ``, - "td": ``, - "/td": ``, - "h1": ``, - "/h1": ``, - "h2": ``, - "/h2": ``, - "h3": ``, - "/h3": ``, - "h4": ``, - "/h4": ``, - "h5": ``, - "/h5": ``, + "table": ``, + "/table": ``, + "tr": ``, + "/tr": ``, + "tbody": ``, + "/tbody": ``, + "td": ``, + "/td": ``, + "h1": ``, + "/h1": ``, + "h2": ``, + "/h2": ``, + "h3": ``, + "/h3": ``, + "h4": ``, + "/h4": ``, + "h5": ``, + "/h5": ``, // br tags are empty - "br": ``, + "br": ``, "Prefix": ``, "Postfix", ``, }, - "kerTeX": { - }, - "XeTeX": { - }, - "LaTeX memoir": { - }, + "kerTeX": {}, + "XeTeX": {}, + "LaTeX memoir": {}, "Neatroff": { "Header": `.ad pb .pmll 20 999999 @@ -175,45 +174,40 @@ var Definitions = map[string]map[string]any { ..`, "Footer": ``, }, - "Utmac": { - }, - "groff": { - }, - "Heirloom Troff": { - }, - "SILE": { - }, - "Typst": { - }, + "Utmac": {}, + "groff": {}, + "Heirloom Troff": {}, + "SILE": {}, + "Typst": {}, } // These keys defined: -// * "paper size" -// * "type family" -// * "columns" -// * "justification" -// * "margins" -// * "headers" -// * "page numbers" -var Styles = map[string]map[string]map[string]any { +// - "paper size" +// - "type family" +// - "columns" +// - "justification" +// - "margins" +// - "headers" +// - "page numbers" +var Styles = map[string]map[string]map[string]any{ "Margins": { "Neatroff": { "Wide": ``, "Thin": ``, }, - "ConTeXt": { - }, + "ConTeXt": {}, }, } // Across literature, there are fonts used for: -// * Display (h1) -// * Subheadings (h2, h3) -// * Text (h4, h5) -// * Small text (p) +// - Display (h1) +// - Subheadings (h2, h3) +// - Text (h4, h5) +// - Small text (p) +// // Following the nomenclature by Frank Grießhammer of Adobe. // https://community.adobe.com/t5/adobe-fonts-discussions/optical-size-range-for-source-serif-4/m-p/14397175#M9797 -var Families = map[string]map[string]map[string]string { +var Families = map[string]map[string]map[string]string{ "Adobe": { "Source Serif": { "Author": "Frank Grießhammer", @@ -230,65 +224,65 @@ The typeface is inspired by the forms of the American Type Founders' gothics by }, "Erewhon": { "Author": "Michael Sharpe", - "About": `Erewhon is a font package based largely on Andrey V. Panov’s Heuristica, but with so many changes that it is no longer strictly compatible with that package, and is offered instead as an enhanced alternative. (Heuristica extended the Utopia font family made available by the TEX Users’ Group, adding many accented glyphs, Cyrillic glyphs, liga- tures, superior and oldstyle fixed-width figures in all styles, and Small Caps in Regular style only. It is widely distributed as a free font collection in OpenType, TrueType and Type1 formats.) See https://mirrors.ibiblio.org/pub/mirrors/CTAN/fonts/erewhon/doc/erewhon-doc.pdf for more.`, + "About": `Erewhon is a font package based largely on Andrey V. Panov’s Heuristica, but with so many changes that it is no longer strictly compatible with that package, and is offered instead as an enhanced alternative. (Heuristica extended the Utopia font family made available by the TEX Users’ Group, adding many accented glyphs, Cyrillic glyphs, liga- tures, superior and oldstyle fixed-width figures in all styles, and Small Caps in Regular style only. It is widely distributed as a free font collection in OpenType, TrueType and Type1 formats.) See https://mirrors.ibiblio.org/pub/mirrors/CTAN/fonts/erewhon/doc/erewhon-doc.pdf for more.`, "Source": `https://ctan.org/tex-archive/fonts/erewhon`, }, }, "CTAN": { "Cochineal": { "Author": "Michael Sharpe", - "About": `Cochineal is a fork from the Crimson fonts (Roman, Italic, Bold, BoldItalic only) released under the OFL by Sebastian Kosch. These remarkable fonts are inspired by the famous oldstyle fonts in the garalde family (Garamond, Bembo) but, in the end, look more similar to Minion, though with smaller xheight and less plain in detail. See https://ctan.org/pkg/cochineal for more.`, + "About": `Cochineal is a fork from the Crimson fonts (Roman, Italic, Bold, BoldItalic only) released under the OFL by Sebastian Kosch. These remarkable fonts are inspired by the famous oldstyle fonts in the garalde family (Garamond, Bembo) but, in the end, look more similar to Minion, though with smaller xheight and less plain in detail. See https://ctan.org/pkg/cochineal for more.`, "Source": `https://ctan.org/pkg/cochineal`, }, "ETbb": { "Author": `Michael Sharpe`, - "About": `Based on Daniel Benjamin Miller’s XETBook, which expanded Tufte’s ETBook, the family name for the Bembo-like font family he commissioned for his books, ETbb expands its features to include a full set of figure styles, small caps in all styles, superior letters and figures, inferior figures, a new capital Sharp S with small caps. See https://ctan.org/pkg/etbb for more.`, + "About": `Based on Daniel Benjamin Miller’s XETBook, which expanded Tufte’s ETBook, the family name for the Bembo-like font family he commissioned for his books, ETbb expands its features to include a full set of figure styles, small caps in all styles, superior letters and figures, inferior figures, a new capital Sharp S with small caps. See https://ctan.org/pkg/etbb for more.`, "Source": `https://ctan.org/pkg/etbb`, }, }, "ANRT": { "Gotico-Antiqua Hamlet-Tertia18": { "Author": "Rafael Ribas & Alexis Faudot", - "About": `Hamlet (also named Kessler-Blackletter), designed by Edward Johnston, cut in three sizes (10, 12 and 18 pt) by Edward Prince for William Shakespeare’s Hamlet. Published by Harry Kessler’s Cranach Press in Weimar in 1929. The type is based on the Durandus for the lowercases, and Sweynheim & Pannartz’ Subiaco type for the capitals. The type was used for trials in other books, none of which were completed. Type design workshop at Bauhaus Universität Weimar and Anna Amalia Bibliothek Weimar, January 2018. See https://gotico-antiqua.anrt-nancy.fr/en for more.`, + "About": `Hamlet (also named Kessler-Blackletter), designed by Edward Johnston, cut in three sizes (10, 12 and 18 pt) by Edward Prince for William Shakespeare’s Hamlet. Published by Harry Kessler’s Cranach Press in Weimar in 1929. The type is based on the Durandus for the lowercases, and Sweynheim & Pannartz’ Subiaco type for the capitals. The type was used for trials in other books, none of which were completed. Type design workshop at Bauhaus Universität Weimar and Anna Amalia Bibliothek Weimar, January 2018. See https://gotico-antiqua.anrt-nancy.fr/en for more.`, "Source": "https://github.com/anrt-type/GoticoAntiqua", }, "Gotico-Antiqua Jessen-Mittel14": { "Author": "Rafael Ribas & Alexis Faudot", - "About": `Jessen, hybrid of gothic minuscules and roman capitals designed and cut without preliminary drawings in Offenbach am Main by Rudolf Koch for The Four Gospels. Printed at the Klingspor press in 1926 and published by Koch himself. Formerly named Bibel-Gotisch, the type was released as Jessen in several sizes by the Klingspor foundry in 1930. Type design workshop at ESAD•Valence, April 2016. See https://gotico-antiqua.anrt-nancy.fr/en for more.`, - "Source": "https://github.com/anrt-type/GoticoAntiqua", }, + "About": `Jessen, hybrid of gothic minuscules and roman capitals designed and cut without preliminary drawings in Offenbach am Main by Rudolf Koch for The Four Gospels. Printed at the Klingspor press in 1926 and published by Koch himself. Formerly named Bibel-Gotisch, the type was released as Jessen in several sizes by the Klingspor foundry in 1930. Type design workshop at ESAD•Valence, April 2016. See https://gotico-antiqua.anrt-nancy.fr/en for more.`, + "Source": "https://github.com/anrt-type/GoticoAntiqua"}, "Gotico-Antiqua Ptolemy-GreatPrimer18": { "Author": "Rafael Ribas & Alexis Faudot", - "About": "Ptolemy, designed in Chelsea by St John Hornby, Sidney Cockerell and Emery Walker, cut in 18 pt by Edward Prince for Cervantes’ Don Quixote. Published by the Ashendene Press in 1927. The type used until 1935 is a revival of Lienhart Holl’s cut for Ptolemaeus’ Cosmographia printed in 1482 in Ulm. Type design workshop at HEAR Mulhouse, March 2015. See https://gotico-antiqua.anrt-nancy.fr/en for more.", - "Source": "https://github.com/anrt-type/GoticoAntiqua", + "About": "Ptolemy, designed in Chelsea by St John Hornby, Sidney Cockerell and Emery Walker, cut in 18 pt by Edward Prince for Cervantes’ Don Quixote. Published by the Ashendene Press in 1927. The type used until 1935 is a revival of Lienhart Holl’s cut for Ptolemaeus’ Cosmographia printed in 1482 in Ulm. Type design workshop at HEAR Mulhouse, March 2015. See https://gotico-antiqua.anrt-nancy.fr/en for more.", + "Source": "https://github.com/anrt-type/GoticoAntiqua", }, "Gotico-Antiqua SouffletVert": { "Author": "Rafael Ribas & Alexis Faudot", - "About": "Soufflet Vert 106R, Hybrid first used in Paris by the Au Soufflet Vert workshop for Guido de Monte Rochen’s Manipulus curatorum, 1476 and used until 1480. Type design workshop at ISBA Besançon and Bibliothèque d’étude et de conservation de Besançon, May 2018. See https://gotico-antiqua.anrt-nancy.fr/en for more.", + "About": "Soufflet Vert 106R, Hybrid first used in Paris by the Au Soufflet Vert workshop for Guido de Monte Rochen’s Manipulus curatorum, 1476 and used until 1480. Type design workshop at ISBA Besançon and Bibliothèque d’étude et de conservation de Besançon, May 2018. See https://gotico-antiqua.anrt-nancy.fr/en for more.", "Source": "https://github.com/anrt-type/GoticoAntiqua", }, "Gotica-Antiqua Spira": { "Author": "Rafael Ribas & Alexis Faudot", - "About": "Spira 110R, Proto-Roman first used in Venice by Johannes and Vindelinus de Spira for Cicero’s Epistolae ad familiares in 1469 and used until 1473 by Vindelinus. Type design workshop at ENSBA Lyon and Bibliothèque municipale de Lyon, March 2017. See https://gotico-antiqua.anrt-nancy.fr/en for more.", + "About": "Spira 110R, Proto-Roman first used in Venice by Johannes and Vindelinus de Spira for Cicero’s Epistolae ad familiares in 1469 and used until 1473 by Vindelinus. Type design workshop at ENSBA Lyon and Bibliothèque municipale de Lyon, March 2017. See https://gotico-antiqua.anrt-nancy.fr/en for more.", "Source": "https://github.com/anrt-type/GoticoAntiqua", }, "Gotico-Antiqua Zainer": { "Author": "Rafael Ribas & Alexis Faudot", - "About": "Zainer 96G, Gotico-Antiqua first used in Ulm by Johann Zainer for Jacques de Voragine’s Legenda aurea not after 1477 and used until 1485. Type design workshop at Hochschule Aachen and Stadtbibliothek Aachen, October 2017. See https://gotico-antiqua.anrt-nancy.fr/en for more.", + "About": "Zainer 96G, Gotico-Antiqua first used in Ulm by Johann Zainer for Jacques de Voragine’s Legenda aurea not after 1477 and used until 1485. Type design workshop at Hochschule Aachen and Stadtbibliothek Aachen, October 2017. See https://gotico-antiqua.anrt-nancy.fr/en for more.", "Source": "https://github.com/anrt-type/GoticoAntiqua", }, "Gotico-Antiqua Hamlet-Cicero12": { "Author": "Rafael Ribas & Alexis Faudot", - "About": "Hamlet (also named Kessler-Blackletter), designed by Edward Johnston, cut in three sizes (10, 12 and 18 pt) by Edward Prince for William Shakespeare’s Hamlet. Published by Harry Kessler’s Cranach Press in Weimar in 1929. The type is based on the Durandus for the lowercases, and Sweynheim & Pannartz’ Subiaco type for the capitals. The type was used for trials in other books, none of which were completed. Type design workshop at Bauhaus Universität Weimar and Anna Amalia Bibliothek Weimar, January 2018. See https://gotico-antiqua.anrt-nancy.fr/en for more.", + "About": "Hamlet (also named Kessler-Blackletter), designed by Edward Johnston, cut in three sizes (10, 12 and 18 pt) by Edward Prince for William Shakespeare’s Hamlet. Published by Harry Kessler’s Cranach Press in Weimar in 1929. The type is based on the Durandus for the lowercases, and Sweynheim & Pannartz’ Subiaco type for the capitals. The type was used for trials in other books, none of which were completed. Type design workshop at Bauhaus Universität Weimar and Anna Amalia Bibliothek Weimar, January 2018. See https://gotico-antiqua.anrt-nancy.fr/en for more.", "Source": "https://github.com/anrt-type/GoticoAntiqua", }, "Gotico-Antiqua Rusch-R-Bizarre": { "Author": "Rafael Ribas & Alexis Faudot", - "About": `Rusch ‘R-Bizarre’ 103R, Proto-Roman first used in Strasbourg by Adolf Rusch for Raban Maur’s De universo between 1467-74 (exact date unknown) and used until 1475. Type design workshop at ESAL Metz and Bibliothèque municipale de Metz, April 2018. See https://gotico-antiqua.anrt-nancy.fr/en for more.`, + "About": `Rusch ‘R-Bizarre’ 103R, Proto-Roman first used in Strasbourg by Adolf Rusch for Raban Maur’s De universo between 1467-74 (exact date unknown) and used until 1475. Type design workshop at ESAL Metz and Bibliothèque municipale de Metz, April 2018. See https://gotico-antiqua.anrt-nancy.fr/en for more.`, "Source": "https://github.com/anrt-type/GoticoAntiqua", }, "Baskervvile": { "Author": "Rosalie Wagner", - "About": `Baskervville is a revival of Jacob's Baskerwille, itself revived from Baskerville's typeface. It was distributed by Berger-Levrault Foundry from 1815. The font Jacob produced was sold as a "Caractères dans le genre Baskerwille" i.e "Baskerwille fonts alike" — with a w instead of a v. + "About": `Baskervville is a revival of Jacob's Baskerwille, itself revived from Baskerville's typeface. It was distributed by Berger-Levrault Foundry from 1815. The font Jacob produced was sold as a "Caractères dans le genre Baskerwille" i.e "Baskerwille fonts alike" — with a w instead of a v. The particularity of Jacob's Baskerwille is that the roman is very closed to Baskerville's typefaces while the italic is closer to Didot's typefaces. The workshop aimed to digitalized Jacob's font in order to testify to his work which creates a transition between transitional and modern styles. The sources showed obvious inaccuracies due to the difficulty of producing and printing types in the 19th century. We didn't want to parody an historical typeface which would have reproduced irregularities from the paper, the ink nor the machine. So we tried to be true to what we thought were Jacob's purposess while using contemporary tools. However, we wanted to be able to use the font and for that matter we corrected some letter-shapes and proportions. We also had to guess the design of missing letters. We kept that unusual w, which is twice a v, and made it the identity of Jacob's font. Jacob's Baskerwille is a strange double of Baskerville's typefaces; a "clone" which looks alike but which is not as achieved as its predecessor. This elementary duplication of the letter v signals, in a way, the counterfeiting. @@ -316,7 +310,7 @@ In 1992 Bitstream donated a version of Charter, along with its version of Courie }, "XCharter": { "Author": `Michael Sharpe`, - "About": `The package presents an extension of Bitstream Charter, which provides small caps, oldstyle figures and superior figures in all four styles. See https://ctan.org/pkg/xcharter for more.`, + "About": `The package presents an extension of Bitstream Charter, which provides small caps, oldstyle figures and superior figures in all four styles. See https://ctan.org/pkg/xcharter for more.`, "Source": `https://ctan.org/pkg/xcharter`, }, }, @@ -367,7 +361,7 @@ See https://github.com/dbenjaminmiller/rwgaramond for more.`, }, "ScholaX": { "Author": "Michael Sharpe", - "About": `ScholaX has a text part and a math support part that is called with an option to newtxmath. The text component has many of the options and macros that are part of the newtxtext package, but with Times fonts replaced by TeXGyreScholaX fonts, the latter being an an extension of the TeXGyreSchola fonts which in turn extended the URW rendering of New Century Schoolbook that was donated as open source to the Ghostscript project. The font is based on early nineteenth century “Scotch” type, whose dominant features are low contrast as compared to, say, Times and Baskerville, and a relatively tall x-height. Its revivals gained popularity because of studies indicating its readability by children leading to its adoption in many texts for that market. See https://mirrors.rit.edu/CTAN/fonts/scholax/doc/scholax-doc.pdf for more.`, + "About": `ScholaX has a text part and a math support part that is called with an option to newtxmath. The text component has many of the options and macros that are part of the newtxtext package, but with Times fonts replaced by TeXGyreScholaX fonts, the latter being an an extension of the TeXGyreSchola fonts which in turn extended the URW rendering of New Century Schoolbook that was donated as open source to the Ghostscript project. The font is based on early nineteenth century “Scotch” type, whose dominant features are low contrast as compared to, say, Times and Baskerville, and a relatively tall x-height. Its revivals gained popularity because of studies indicating its readability by children leading to its adoption in many texts for that market. See https://mirrors.rit.edu/CTAN/fonts/scholax/doc/scholax-doc.pdf for more.`, "Source": `https://ctan.org/pkg/scholax`, }, }, @@ -412,7 +406,6 @@ It's a versatile family providing users with plenty of features and moods. It sp // Optically correct scaling. // Some people need larger body type. - func style(language, key, value string) (string, error) { return "", nil } @@ -425,10 +418,10 @@ func generate(mark, language string) (string, error) { func Generate(language string, tag Tag) string { switch t := Definitions[language][mark].(type) { - case string: - return t - case func(Tag): - t(tag) + case string: + return t + case func(Tag): + t(tag) } } |