I would like to ask a question related to an ongoing issue in the GitHub repository of jgm/citeproc here, since my question may come to be out of scope of the original issue.
I'm trying to apply an approach proposed in a comment on the thread on GitHub to a csl
file so that I can display English references and non-English ones (Chinese lang-zh
, here) in different layouts according to their language. That is, when citeproc finds that a bib entry of a .bib
file contains a csl's variable
(say lang-zh
), that bib entry is displayed in a layout that is specified in the csl's if-statement as shown below:
<citation>
...
<layout>
<choose>
<if variable="lang-zh">
<!--
Multibyte comma as a deliminater for non-English references
-->
<group delimiter=",">
<text macro="author-short-zh" />
<text macro="issued-year-zh" />
<text macro="citation-locator-zh" />
</group>
</if>
<else>
<!--
Normal comma as a deliminater for references in the default language (English)
-->
<group delimiter=", ">
<text macro="author-short" />
<text macro="issued-year" />
<text macro="citation-locator" />
</group>
</else>
</choose>
</layout>
</citation>
However, the variable/tag lang-zh
in the .bib
file seems to be ignored even when I add such filed as lang-zh = {yes}
, variable = {lang-zh}
, or language = {lang-zh}
to the .bib
file, as shown below.
@article{chen2012,
title = {基于电无级变速器的内燃机最优控制策略及整车能量管理},
author = {陈骁 and 黄声华 and 万山明 and 庞珽},
journal = {电工技术学报},
volume = {27},
number = {2},
pages = {133--138},
year = {2012},
lang-zh = {yes},
variable = {lang-zh},
language = {lang-zh}
}
Then how should I add a filed or variable to the .bib
file that can be recognised by the csl?
(M)WE
Full .csl
file (say mod_apa_zh_pulipuli.csl
)
You can find the .csl
file from https://github.com/jgm/citeproc/issues/120#issuecomment-1296207148
(Its original csl called apa_zh_pulipuli.csl
is from https://raw.githubusercontent.com/pulipulichen/blogger/master/project/zotero/apa_zh_pulipuli.csl)
tests.bib
@book{xie2015,
title = {Dynamic Documents with {R} and knitr},
author = {Yihui Xie},
publisher = {Chapman and Hall/CRC},
address = {Boca Raton, Florida},
year = {2015},
edition = {2nd},
note = {ISBN 978-1498716963},
url = {http://yihui.name/knitr/},
language = {English}
}
@article{chen2012,
title = {基于电无级变速器的内燃机最优控制策略及整车能量管理},
author = {陈骁 and 黄声华 and 万山明 and 庞珽},
journal = {电工技术学报},
volume = {27},
number = {2},
pages = {133--138},
year = {2012},
lang-zh = {yes},
variable = {lang-zh},
language = {lang-zh}
}
test.md
---
bibliography: [test.bib]
csl: mod_apa_zh_pulipuli.csl
---
@xie2015
@chen2012