Closed schmic41 closed 4 months ago
This would require changing the language of the whole language, right? Wouldn't that mess up other locales?
You are right, it would. I was imagining switching between locales working something like:
#set text(lang: "imp")
$ qty("3.141", "lb/in")$
#set lang(lang: "ru")
[...]
but, after looking deeper into how Typst handles locales, it looks like doing this would break too much -- hyphenations, decimal separators -- even in that small region of code.
That leaves two options: first, they could be added to the main units.csv
file, manually prefixed to avoid conflicts with metric units: imp-in
, imp-ft
, imp-mi
, and so on. Or, I can just bite the bullet and look into forking the code.
(For context, I submitted an "add imperial units" PR a few weeks ago, and the maintainer asked if it could be used with the new language feature.)
Having looked at the new code, imperial units can be added. It would consist of adding an imperial entry to the existing
lang-db
, and parsing a correspondingimperial.csv
file. Since there is currently no language referred to as imperial, there is no risk of a namespace clash when more languages are added.This does not exactly copy siunitx's behavior (there, the "preferred solution" is to use
\DeclareSIUnit
; here, that would require either downloading a local copy of the package or going through some complexstate.update
maneuvers). However, it does not create any conflicts with existing code, and it is unlikely to create namespace collisions with future code.If there is interest in adding imperial units, I can create a PR.
I am interested to read any thoughts on this. Please let me know if you need any additional information. Thanks!