Yak-Shaving, Printing Emails Edition
„Martin, could you provide me that email as a signed PDF?” was the request by a good friend of mine. „That should be easy,” I thought. Famous last words.
The first try, printing directly from (neo)mutt to the CUPS PDF printer failed from the start, as I did not have the PDF printer installed yet. A quick „sudo apt install cups-pdf” later, I failed by being unable to specify the correct printer. After reading up on lpr and lpstat I finally got a print result. And after a few more minutes fiddling around with the border settings of the print driver, I was finally able to create a decently looking PDF of an email.
But it did not look „good” so I kept searching and found „muttprint”. A quick „sudo apt install muttprint” later, I was again unable to print at all. After some tweaking, I was able to remedy that situation. And it looked „LaTeXy” in a good way :D After some more tweaking, even the Umlauts and the date were printed with the correct encoding and formatting (ISO 8601).
Except the date in the footer of the page which kept using the funky date format used in the USA. So I started experimenting with multiple locale settings to change the date format in the footer. Which of course just wasted time but did not render useful results.
So, grasping at straws, I started to do, what nobody wants to do. I started reading the documentation. As the manpage did not yield any solutions, I did some more „research” (aka. frantic googeling) and finally found the muttprint manual SGML source code (I could not find the HTML or PDF version, stupid me), which clearly states:
The date in the footer is generated by LaTeX and so it’s in the language specified byLC_MESSAGES .
Even though I was quite sure that I did set LC_MESSAGE before, I tried again. And it failed again. So I had to dig deeper. The locale was set correctly, so what is failing here? It had to be LaTeX.
So, after some research, I learned that this has to do something with „babel”. And the muttprint sourcecode also contained the relevant statements:
\\usepackage[$babellanguage]{babel} ... \\lfoot{\\today}
But it should pick up the language from the locale and not stick with the stupid USA-format. Even using „--print-locale” showed the correct settings:
$ LC_MESSAGES=de /usr/bin/muttprint -f example.eml --date local --date-format '%Y-%m-%d %H:%M:%S' -p PDF --print-locale ... Encoding ......: ANSI_X3.4-1968 Language ......: de Country .......: US Babel option ..: ngerman TeX inputenc ..: latin1 TeX fontenc ...: T1
Look, LaTex, THERE! It says „ngerman”, why do you not use it ????
Well, after some additional time poking around, I FINALLY looked into the muttprint logfile (/tmp/muttprint.log) and lo and behold:
Package babel Error: Unknown option 'ngerman'. Either you misspelled it (babel) or the language definition file ngerman.ldf (babel) was not found.
But why? Muttprint says everything is fine. dpkg shows that language support for European languages is installed:
$ dpkg -l | grep -i texlive-lang ii texlive-lang-european ... TeX Live: Other European languages
Well, after some more online-digging I found out that the organization of the babel language files has „recently changed” [insert „burn everything down meme here”]. Apparently, you need to manually install „texlive-lang-[LANGUAGE]” to get proper language support.
A quick „sudo apt-get install texlive-lang-german” and half an hour later (due to „Building latex-based formats –byhyphen language.dat”), I was finally able to print an email from mutt using muttprint with a German „long date” in the footer.
That was easy, wasn’t it? Took almost no time …
Tagged as: email, latex, linux, mutt, pdf, print, printing, yakshaving | Author: Martin Leyrer
[Sonntag, 20241103, 15:21 | permanent link | 0 Kommentar(e)