andras-simonyi / citeproc-el

A CSL 1.0.2 Citation Processor for Emacs.
GNU General Public License v3.0
85 stars 9 forks source link

Non-English langid entries title-cased #84

Closed Quintus closed 2 years ago

Quintus commented 2 years ago

Dear Andras,

looks as if I finally also suffer from a titlecase problem. The CSL style I use currently does not use the text-case attribute anywhere, but even though I write in German, I ocassionally do cite English works. Their titles were sentence-cased, which bugged me a little (there is no standard for citing English works in a German work, I just find title case nicer) so I decided to modify the CSL style and add the text-case attribute. The resulting modified juristische-schulung.csl is provided below. It however turns out that in doing so citeproc now title-cases all titles, even those for which the langid field is not set to an English variant. That should not be; the relevant section from the CSL 1.0.1 spec reads (emphasis mine):

As many languages do not use title case, title case conversion (with text-case set to “title”) only affects English-language items.

If the default-locale attribute on cs:style isn’t set, or set to a locale code with a primary language tag of “en” (English), items are assumed to be English. An item is only considered to be non-English if its metadata contains a language field with a non-nil value that doesn’t start with the “en” primary language tag.

If default-locale is set to a locale code with a primary language tag other than “en”, items are assumed to be non-English. An item is only considered to be English if the value of its language field starts with the “en” primary language tag.

Here's an MWE.org file:

#+TITLE: Test
#+AUTHOR: Testauthor
#+LANGUAGE: de
#+bibliography: /tmp/mwe/mwe.bib
#+cite_export: csl /tmp/mwe/juristische-schulung.csl

Das ist ein Test. [cite:@schuhmacher2004alg p. 20]

Corresponding mwe.bib (notice the presence of langid):

@Book{schuhmacher2004alg,
    author = {Dirk Schuhmacher},
    title = {Schutz von Algorithmen für Computerprogramme},
    year = {2004},
    publisher = {Lit Verlag},
    location = {Münster},
    langid = {ngerman}
}

Exporting with the modified juristische-schulung.csl provided below results in:

Schuhmacher, Schutz von Algorithmen Für Computerprogramme, 2004, 20

Whereas it should have been (notice the word “für” has to be lowercase):

Schuhmacher, Schutz von Algorithmen für Computerprogramme, 2004, 20

citeproc at 2e7df666bfeed92178d20c5851a2945ed5760664. Org mode version 9.5 (release_9.5-225-g494c20 @ /home/quintus/.emacs.d/org-mode/lisp/).

-quintus


Modified juristische-schulung.csl with text-case set on book entries:

<?xml version="1.0" encoding="utf-8"?>
<style xmlns="http://purl.org/net/xbiblio/csl" version="1.0" class="note" default-locale="de-DE">
  <info>
    <title>Juristische Schulung (Deutsch)</title>
    <title-short>JuS</title-short>
    <id>http://www.zotero.org/styles/juristische-schulung</id>
    <link href="http://www.zotero.org/styles/juristische-schulung" rel="self"/>
    <link href="http://www.zotero.org/styles/neue-juristische-wochenschrift" rel="template"/>
    <link href="http://rsw.beck.de/rsw/upload/JuS/jusautorenhinweise.pdf" rel="documentation"/>
    <author>
      <name>Reto Mantz</name>
    </author>
    <category citation-format="note"/>
    <category field="law"/>
    <issn>0022-6939</issn>
    <summary>JuS
    Style for articles in German law journal JuS
    - based on style Neue Juristische Wochenschrift (NJW) http://www.zotero.org/styles/neue-juristische-wochenschrift
    - Commentaries and handbooks should use publication type "entry-encyclopedia". See details for different citations below.
    - If a book or entry-encyclopedia is cited for the 2nd time (or more), "title and edition" are substituted by (o. Fn. ...)
      (see footnote ...)
    - see more details below in the comments</summary>
    <updated>2014-12-09T13:38:27+00:00</updated>
    <rights license="http://creativecommons.org/licenses/by-sa/3.0/">This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License</rights>
  </info>
  <!-- set date to format 8. 8. 2014 -->
  <locale xmlns="http://purl.org/net/xbiblio/csl" xml:lang="de-DE">
    <date form="numeric">
      <date-part name="day" form="numeric" suffix=". "/>
      <date-part name="month" form="numeric" suffix=". "/>
      <date-part name="year"/>
    </date>
  </locale>
  <macro name="author">
    <names variable="author" font-style="italic">
      <name delimiter="/ " name-as-sort-order="all" sort-separator=", " form="long"/>
      <label form="short" prefix=" (" suffix=")"/>
      <substitute>
        <names variable="editor"/>
      </substitute>
    </names>
  </macro>
  <macro name="author-note">
    <names variable="author" font-style="italic">
      <name form="short" delimiter="/" name-as-sort-order="all"/>
    </names>
  </macro>
  <macro name="author-commentary">
    <choose>
      <if variable="collection-editor">
        <names variable="collection-editor">
          <name form="short" delimiter="/" name-as-sort-order="all"/>
        </names>
      </if>
      <else>
        <names variable="author editor">
          <name form="short" delimiter="/" name-as-sort-order="all"/>
        </names>
      </else>
    </choose>
  </macro>
  <macro name="locator-with-label">
    <group delimiter=" ">
      <label variable="locator" form="symbol"/>
      <text variable="locator"/>
    </group>
  </macro>
  <macro name="autor-editor-note">
    <names variable="author" font-style="italic">
      <name form="short" delimiter="/" sort-separator=""/>
      <substitute>
        <names variable="editor"/>
      </substitute>
    </names>
  </macro>
  <macro name="author-chapter">
    <names variable="container-author">
      <name delimiter="/ " name-as-sort-order="all" sort-separator=", " form="short"/>
      <label form="short" prefix=" (" suffix=")"/>
    </names>
  </macro>
  <macro name="journalname-year">
    <group delimiter=" ">
      <text variable="container-title-short"/>
      <date date-parts="year" form="text" variable="issued"/>
    </group>
  </macro>
  <macro name="firstpage-locator">
    <text variable="page-first"/>
    <text variable="locator" prefix=" (" suffix=")"/>
  </macro>
  <macro name="edition">
    <choose>
      <if match="any" is-numeric="edition">
        <group delimiter=" ">
          <number vertical-align="baseline" suffix=" " variable="edition" form="ordinal"/>
          <text term="edition" form="short" suffix="."/>
          <date date-parts="year" form="text" variable="issued" prefix=" (" suffix=")"/>
        </group>
      </if>
      <else-if variable="edition">
        <text variable="edition" form="short"/>
        <date date-parts="year" form="text" variable="issued" prefix=" (" suffix=")"/>
      </else-if>
      <!-- display year without brackets if this is the first edition (aka variable edition is not set) -->
      <else>
        <date date-parts="year" form="text" variable="issued" prefix=" "/>
      </else>
    </choose>
  </macro>
  <citation et-al-min="5" et-al-use-first="1">
    <layout delimiter="; ">
      <choose>
        <!-- Journal article
             Style: <authors italic>, <journalname short> <journal-year>, <first-page>, <locator/cited page(s)>    
        -->
        <if type="article-journal">
          <group delimiter=", ">
            <text macro="author-note"/>
            <text macro="journalname-year"/>
            <text macro="firstpage-locator"/>
          </group>
        </if>
        <else-if type="article-newspaper">
          <text macro="author-note" suffix=", "/>
          <text variable="container-title"/>
          <date form="numeric" variable="issued" prefix=" v. "/>
          <text variable="URL" prefix=", "/>
        </else-if>
        <!-- Book
             Style: <authors italic>, <title short>, [<edition>. Aufl. ]<year>, <locator/cited page(s)>    
        -->
        <else-if type="book">
          <text macro="autor-editor-note" suffix=", "/>
          <choose>
            <if match="none" position="first">
              <group delimiter=" " prefix="(" suffix="), ">
                <text value="o. Fn."/>
                <text variable="first-reference-note-number"/>
              </group>
            </if>
            <else>
              <text variable="title" text-case="title" form="short" suffix=", "/>
              <text macro="edition"/>
            </else>
          </choose>
          <choose>
              <!-- "S." as a locator is ommited. Many books however are instead cited by § plus margin number. The § has to appear. -->
              <if locator="page">
                  <text variable="locator" prefix=", "/>
              </if>
              <else>
                  <label variable="locator" form="symbol" prefix=", "/>
                  <text variable="locator" prefix=" "/>
              </else>
          </choose>
        </else-if>
        <!-- Legal commentary or handbook should be of publication type "entry-encyclopedia"
        - The term "Bearbeiter" (author of a certain chapter) in the following examples should be added by you and is not governed by this stylesheet

        Style:
        - if container-title (=Zotero.encyclopediaTitle) is NOT set: <editor non-italic>, <title short>, [<edition>. Aufl. ]<year>, <locator/cited page(s)>
        -.- i.e. Bearbeiter, in: Taeger/Gabel, BDSG, 2. Aufl. 2013, ... (where you should add "Bearbeiter, in: " yourself)
        - else <container-title>, [<edition>. Aufl. ]<year>, <locator/cited page(s)>
        -.- i.e. Bearbeiter, in: BeckTKG, 4. Auflage 2013, ... (where you should add "Bearbeiter, in: " yourself)

        if there is at least one series-editor (CSL.collection-editor) set: <collection-editor>, [<edition>. Aufl. ]<year>, <locator/cited page(s)> 
        -.- i.e. Bearbeiter, in: Palandt, BGB, 73. Aufl. 2014, ... (where you should add "Bearbeiter, in: " yourself)
        -->
        <else-if type="entry-encyclopedia">
          <choose>
            <if variable="container-title">
              <text variable="container-title" suffix=", "/>
            </if>
            <else>
              <text macro="author-commentary" suffix=", "/>
              <choose>
                <if match="none" position="first">
                  <group delimiter=" " prefix="(" suffix="), ">
                    <text value="o. Fn."/>
                    <text variable="first-reference-note-number"/>
                  </group>
                </if>
                <else>
                  <text variable="title" suffix=", " form="short"/>
                </else>
              </choose>
            </else>
          </choose>
          <choose>
            <if match="any" position="first">
              <text macro="edition"/>
            </if>
          </choose>
          <text variable="locator" prefix=", "/>
        </else-if>
        <!-- Chapter
        Style: <author italic>, in: <book-author>, <title short>, [<edition>. Aufl.] <year>, <page> (<locator>)
        e.g.: Mantz in Spindler, Rechtliche Rahmenbedingungen von Open Access-Publikationen, 2006, 55 (57)
        -->
        <else-if type="chapter">
          <text macro="autor-editor-note" suffix=", in: "/>
          <text macro="author-chapter" suffix=", "/>
          <text variable="container-title" suffix=", "/>
          <text macro="edition"/>
          <text macro="firstpage-locator" prefix=", "/>
        </else-if>
        <!-- Legal case
        Style:
        if case is published in journal:  <court> <journal> <journal-year>, <first-page>, <locator> [ <en-dash> <case name>]
        otherwise:                        <court>, <type of decision> v. <dated-decided> <en-dash> <docketnumber> [ <en-dash> <case name>]   (type of decision is saved in field "note")
        -->
        <else-if type="legal_case" match="any">
          <choose>
            <!-- is the case published in a journal? -->
            <if variable="container-title">
              <text variable="authority" suffix=" "/>
              <text variable="container-title" form="short" suffix=" "/>
              <text variable="volume" suffix=", "/>
              <text macro="firstpage-locator"/>
            </if>
            <else>
              <text variable="authority" suffix=", "/>
              <text variable="genre" suffix=" v. "/>
              <date form="numeric" variable="issued" suffix=" &#8211; "/>
              <text variable="number"/>
            </else>
          </choose>
          <choose>
            <if variable="title-short">
              <text variable="title-short" prefix=" &#8211; "/>
            </if>
          </choose>
        </else-if>
        <else>
          <group delimiter=", ">
            <text macro="author-note"/>
            <text variable="title"/>
            <text macro="locator-with-label"/>
          </group>
        </else>
      </choose>
    </layout>
  </citation>
  <bibliography>
    <sort>
      <key macro="author"/>
      <key variable="issued"/>
    </sort>
    <layout>
      <choose>
        <if type="article-journal">
          <group delimiter=", ">
            <text macro="author-note"/>
            <text variable="title"/>
            <text macro="journalname-year"/>
            <text macro="firstpage-locator"/>
          </group>
        </if>
        <else-if type="book">
          <text macro="autor-editor-note" suffix=", "/>
          <text variable="title" form="short" suffix=", "/>
          <text macro="edition"/>
        </else-if>
        <else-if type="article-newspaper">
          <text macro="author-note" suffix=", "/>
          <text variable="title" suffix=", "/>
          <text variable="container-title"/>
          <date form="numeric" variable="issued" prefix=" v. "/>
          <text variable="URL" prefix=", "/>
        </else-if>
        <else-if type="entry-encyclopedia">
          <choose>
            <if variable="container-title">
              <text variable="container-title" suffix=", "/>
            </if>
            <else>
              <text macro="author-commentary" suffix=", "/>
              <text variable="title" suffix=", " form="short"/>
            </else>
          </choose>
          <text macro="edition"/>
        </else-if>
        <else-if type="chapter">
          <text macro="autor-editor-note" suffix=", in: "/>
          <text macro="author-chapter" suffix=", "/>
          <text variable="container-title" suffix=", "/>
          <text macro="edition"/>
          <text variable="page-first" prefix=", "/>
        </else-if>
      </choose>
    </layout>
  </bibliography>
</style>
andras-simonyi commented 2 years ago

Thanks for the report! Currently citeproc-el's CSL engine totally disregards the language field, so this is to be expected, the biblatex -> CSL mapping also simply drops the langid field. None of this should be complicated to change, however, so I'll try to push a fix soon.

andras-simonyi commented 2 years ago

I've merged a PR (#86) which should fix this -- thanks again. Please note that -- following the CSL standard -- items without a set individual language field are considered to be in the language of the locale, so with

#+language: de

only items with set English langids will be title-cased. (I hope this is the behaviour you expect...)

Quintus commented 2 years ago

Thank you! I tested 538fed794c29acf81efee8a2674268bd3d7cc471 and it now works as expected.

Please note that -- following the CSL standard -- items without a set individual language field are considered to be in the language of the local […]. (I hope this is the behaviour you expect...)

This is what I expect. It’s fine and actually comforts me, because notably some older entries in my bib files do not have langid fields and they are mostly German. I keep adding langid to them when I reference them, though. Ultimately all my entries will have a langid field.