sile-typesetter / sile

The SILE Typesetter — Simon’s Improved Layout Engine
https://sile-typesetter.org
MIT License
1.61k stars 97 forks source link

Export locale for system commands run from Lua #2038

Open alerque opened 1 month ago

alerque commented 1 month ago

One more for after we better work out how we're handling the locale code internally...

When I run os.execute() from Lua inside a SILE document, I would expect the document locale setting to have been exported as an env var ahead of time.

\begin{document}
\language[main=tr]
\fluent[name=Docker]{hello}
\eject
\begin{lua}
local date = os.execute("date")
local date = os.execute("env LC_ALL=tr_TR.UTF-8 date")
\end{lua}
\end{document}
$ sile foo.sil -o - -b text
SILE v0.14.17.r414-g6382ac4 (LuaJIT 2.1.1700206165) [Rust]
<d/foo.sil> as sil
<./core/languages.lua:78> as xml
Merhaba Docker![1]  1
                     <./core/sile.lua:566> as lua
Fri May 31 01:47:20 AM +03 2024
Cum 31 May 2024 01:47:20 +03
[2]
2

Note the output of the first date command does not track the document context.

alerque commented 3 weeks ago

I basically have this working now, but the system locale setting needs something more than our two letter language codes. This is hung up on needing BCP47 language codes.