I'm running the fantastic pandoc from within an R package, relying on the LaTeX babel package for some typesetting niceties.
Pandoc expects a lang
argument as a BCP 47 code (e.g. en-US
), but babel
expects its own language codes (e.g. american
).
Pandoc, being as awesome as it is, maps between the two in this haskell script.
In the spirit of defensive programming, I'd like to warn my users when they're using a wrong language code, and give them a definitive list of such acceptable BCP 47 codes.
Does such a list (or vector, or whatever) exist somewhere in R or a package for convenient use?
I'm trying to avoid manually typing up the pandoc haskell script.
I needed to provide a convenient selectize input, so I had to have the available options ready in R and ended up hand-copying them (yikes).
In case anyone finds this useful, here are: - language codes in short (
lang_short
), - variant or locale (var_short
), - a longer version of the language (helpful for input)lang_long
(possibly non-standard!), - a longer version of the variant or locale (helpful for input)var_long
(probably non-standard!), - logical values forpolyglossia
andbabel
, indicating whether pandoc maps to one or both of these (might come in handy if you need to rely on only one of these LaTeX packages.Remember that pandoc expects languages of the form
en_US
etc., so you need to paste column 1 and 2.Remember that these are not all languages and variants under the BCP 47 standard; it's just the (small) subset mapped by pandoc.
(If anyone comes across a more definitive list of language codes in R, that would be great).