R中是否有BCP 47语言代码列表?

问题描述 投票:0回答:2

我正在运行R包中的梦幻般的pandoc,依靠LaTeX babel package进行一些排版细节。

Pandoc expects a lang argument作为BCP 47代码(例如en-US),但babel期望其自己的语言代码(例如american)。

Pandoc,就像它一样令人敬畏,在this haskell script中映射两者。

本着防御性编程的精神,我想在用户使用错误的语言代码时警告我的用户,并为他们提供这些可接受的BCP 47代码的明确清单。

这样的列表(或矢量,或其他)是否存在于R或包中的某处以方便使用?

我试图避免手动输入pandoc haskell脚本。

r latex multilingual pandoc ietf-bcp-47
2个回答
2
投票

我需要提供一个方便的选择输入,所以我必须在R中准备好可用的选项并最终手动复制它们(yikes)。

如果有人发现这个有用,这里有: - 简短的语言代码(lang_short), - 变体或语言环境(var_short), - 更长的语言版本(有助于输入)lang_long(可能是非标准的!), - a更长版本的变体或区域设置(有助于输入)var_long(可能非标准!), - polyglossiababel的逻辑值,指示pandoc是否映射到其中一个或两个(如果您需要依赖它可能会派上用场这些LaTeX包中只有一个。

请记住,pandoc需要en_US等形式的语言,因此您需要粘贴第1列和第2列。

请记住,这些并非BCP 47标准下的所有语言和变体;它只是pandoc映射的(小)子集。

(如果有人在R中遇到更明确的语言代码列表,那就太好了)。


lang_short;var_short;lang_long;var_long;polyglossia;babel
ar;DZ;arabic;Algeria;TRUE;FALSE
ar;IQ;arabic;Iraq;TRUE;FALSE
ar;JO;arabic;Jordan;TRUE;FALSE
ar;LB;arabic;Lebanon;TRUE;FALSE
ar;LY;arabic;Libya;TRUE;FALSE
ar;MA;arabic;Morocco;TRUE;FALSE
ar;MR;arabic;Mauritania;TRUE;FALSE
ar;PS;arabic;Palestinian Territory;TRUE;FALSE
ar;SY;arabic;Syria;TRUE;FALSE
ar;TN;arabic;Tunisia;TRUE;FALSE
de;DE;german;;TRUE;TRUE
de;AT;german;Austria;TRUE;TRUE
de;CH;german;Switzerland;TRUE;TRUE
dsb;;lower sorbian;;TRUE;FALSE
hsb;;upper sorbian;;FALSE;TRUE
el;polyton;greek;polytonic;TRUE;TRUE
en;AU;english;Australia;TRUE;TRUE
en;CA;english;Canada;TRUE;TRUE
en;GB;english;Great Britain;TRUE;TRUE
en;NZ;english;New Zealand;TRUE;TRUE
en;UK;english;United Kingdom;TRUE;TRUE
en;US;english;United States;TRUE;TRUE
grc;ancient;greek;ancient;TRUE;TRUE
la;;latin;;TRUE;TRUE
sl;;slovenian;;TRUE;TRUE
fr;CA;french;Canada;FALSE;TRUE
pt;BR;portoguese;Brazil;TRUE;TRUE
sr;;serbian;;TRUE;TRUE
af;;afrikaans;;TRUE;TRUE
am;;amharic;;TRUE;TRUE
ar;;arabic;;TRUE;TRUE
as;;assamese;;TRUE;TRUE
ast;;asturian;;TRUE;TRUE
bg;;bulgarian;;TRUE;TRUE
bn;;bengali;;TRUE;TRUE
bo;;tibetan;;TRUE;TRUE
br;;breton;;TRUE;TRUE
ca;;catalan;;TRUE;TRUE
cy;;welsh;;TRUE;TRUE
cs;;czech;;TRUE;TRUE
cop;;coptic;;TRUE;TRUE
da;;danish;;TRUE;TRUE
dv;;divehi;;TRUE;TRUE
el;;greek;;TRUE;TRUE
en;;english;;TRUE;TRUE
eo;;esperanto;;TRUE;TRUE
es;;spanish;;TRUE;TRUE
et;;estonian;;TRUE;TRUE
eu;;basque;;TRUE;TRUE
fa;;farsi;;TRUE;TRUE
fr;;french;;TRUE;TRUE
fur;;friulan;;TRUE;TRUE
ga;;irish;;TRUE;TRUE
gd;;scottish;;TRUE;TRUE
gez;;ethiopic;;TRUE;TRUE
gl;;galician;;TRUE;TRUE
he;;hebrew;;TRUE;TRUE
hi;;hindi;;TRUE;TRUE
hr;;croatian;;TRUE;TRUE
hu;;magyar;;TRUE;TRUE
hy;;armenian;;TRUE;TRUE
ia;;interlingua;;TRUE;TRUE
id;;indonesian;;TRUE;TRUE
is;;icelandic;;TRUE;TRUE
it;;italian;;TRUE;TRUE
km;;khmer;;TRUE;TRUE
kmr;;kurmanji;;TRUE;TRUE
kn;;kannada;;TRUE;TRUE
ko;;korean;;TRUE;TRUE
lo;;lao;;TRUE;TRUE
lt;;lithuanian;;TRUE;TRUE
lv;;latvian;;TRUE;TRUE
ml;;malayalam;;TRUE;TRUE
mn;;mongolian;;TRUE;TRUE
mr;;marathi;;TRUE;TRUE
nb;;norsk;;TRUE;TRUE
nl;;dutch;;TRUE;TRUE
nn;;nynorsk;;TRUE;TRUE
no;;norsk;;TRUE;TRUE
nqo;;nko;;TRUE;TRUE
oc;;occitan;;TRUE;TRUE
pa;;panjabi;;TRUE;TRUE
pms;;piedmontese;;TRUE;TRUE
pt;;portoguese;;TRUE;TRUE
rm;;romanian;;TRUE;TRUE
ro;;russian;;TRUE;TRUE
sa;;sanskrit;;TRUE;TRUE
se;;samin;;TRUE;TRUE
sk;;slovak;;TRUE;TRUE
sq;;albanian;;TRUE;TRUE
sr;;serbian;;TRUE;TRUE
syr;;syriac;;TRUE;TRUE
ta;;tamil;;TRUE;TRUE
te;;telugu;;TRUE;TRUE
th;;thai;;TRUE;TRUE
ti;;ethiopic;;TRUE;TRUE
tk;;turkmen;;TRUE;TRUE
tr;;turkish;;TRUE;TRUE
uk;;ukrainian;;TRUE;TRUE
ur;;urdu;;TRUE;TRUE
vi;;vietnamese;;TRUE;TRUE

1
投票

由于R脚本无法访问Haskell代码(在自己的进程中运行),因此无法实现。但是,pandoc> 2.0会向STDERR发出警告,在这种情况下:

$ echo "foo" | pandoc -M lang=asdf -t latex
[WARNING] Invalid 'lang' value 'asdf'.
  Use an IETF language tag like 'en-US'.

应该有办法从R中捕获这个。

© www.soinside.com 2019 - 2024. All rights reserved.