I created a simple package aimed at helping you build up language tags. The main use case I built it for was adding the
<html lang="en-US"> type tags for an
elm-pages app. It’s focused solely on generating the BCP 47 code (doesn’t include any metadata like language name, country name, etc.). I also built it with dead-code elimination in mind, so while it includes a lot of definitions, with Elm’s dead-code elimination it will only include the codes you explicitly reference in the code you ship.
You can see some other places that BCP 47 language tags are used in the readme. Hope some people find some use from it!