mbutterick / pollen-users

please use https://forums.matthewbutterick.com/c/typesetting/ instead
https://forums.matthewbutterick.com/c/typesetting/
53 stars 0 forks source link

Approach to Multi-lingual texts #89

Open zachmandeville opened 3 years ago

zachmandeville commented 3 years ago

Hello!

I have a small pollen zine that just got a translation. I wanted to include the translated text into the zine, but wasn't sure the best way to approach it and curious on if any of you have done this, and the approach you took!

I would want to have two different outputted zines: one in English and one in Spanish. I was thinking I could add some logic so that an arg passed to raco pollen render would render it with the translation. One way would be to maybe have two different .ptree files, one for the english files and one for the spanish, and I just tell render which ptree file to look at? Ideally, though, I think I'd want to have each file be multi-lingual, as it'd make navigating the source a bit easier. So I would have two different sections per language, and then have the render be able to set which one gets picked up?

Hopefully that makes sense, thank you!

sorawee commented 3 years ago

I have a defunct personal website that attempts at this problem. I use an environment variable LANG to control which language I am in, then I simply call raco pollen render several times on different values of LANG. In a source file, I can use tags named lang/<lang-code> (e.g., lang/en, lang/th) where the content in the tag will only appear when LANG is set to <lang-code>. The output HTML for each LANG are in completely separated directories, but that works well for me.

mbutterick commented 3 years ago

You can inspect any environment variable from within a tag function using getenv (that’s a Racket thing, not a Pollen thing)