Juris-M / citeproc-js

A JavaScript implementation of the Citation Style Language (CSL) https://citeproc-js.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Localized date formats with CSL-M layout extension

zepinglee opened this issue · comments

Branch: master 98a4368

>>===== MODE =====>>
citation
<<===== MODE =====<<

>>===== RESULT =====>>
2001 in English, 2001 in English, 2001 in English
<<===== RESULT =====<<

>>===== CSL =====>>
<style
      xmlns="http://purl.org/net/xbiblio/csl"
      class="note"
      version="1.0">
  <info>
    <id />
    <title />
    <updated>2022-04-24T00:00:00+08:00</updated>
  </info>
  <locale xml:lang="zh">
    <date form="text">
      <date-part name="year" suffix=" in Chinese"/>
    </date>
  </locale>
  <locale>
    <date form="text">
      <date-part name="year" suffix=" in English"/>
    </date>
  </locale>
  <macro name="issued-date">
    <date variable="issued" form="text"/>
  </macro>
  <macro name="citation-layout">
    <text macro="issued-date"/>
  </macro>
  <citation>
    <layout delimiter="; " locale="zh">
      <text macro="citation-layout"/>
    </layout>
    <layout delimiter="; ">
      <group delimiter=", ">
        <date variable="issued" form="text"/>
        <text macro="issued-date"/>
        <text macro="citation-layout"/>
      </group>
    </layout>
  </citation>
</style>
<<===== CSL =====<<

>>===== INPUT =====>>
[
    {
        "id": "ITEM-1",
        "type": "book",
        "issued": {
            "date-parts": [
              [
                2001
              ]
            ]
        },
        "language": "en"
    }
]
<<===== INPUT =====<<

Test output:

  0 passing (38ms)
  1 failing

  1) Integration tests
       should pass locale_date:

      AssertionError: /Users/zepinglee/Developer/csl/citeproc-js/fixtures/local/locale_date.txt
      + expected - actual

      -2001 in English, 2001 in English, 2001 in Chinese
      +2001 in English, 2001 in English, 2001 in English
      
      at Context.<anonymous> (.cslTestFixtures/fixtures.js:72:24)
      at process.processImmediate (node:internal/timers:471:21)

The <text macro="citation-layout"/> is supposed to load English date format but the output is the one from locale zh.