Skip to content

Set the CSL item language so non-English titles aren't wrongly title-cased#167

Open
robin-morand wants to merge 1 commit into
pkp:stable-3_5_0from
robin-morand:fix/item-language-title-case
Open

Set the CSL item language so non-English titles aren't wrongly title-cased#167
robin-morand wants to merge 1 commit into
pkp:stable-3_5_0from
robin-morand:fix/item-language-title-case

Conversation

@robin-morand

Copy link
Copy Markdown

Problem

On a journal whose name is not in English, the "How to cite" block (and every
citeproc-rendered citation) title-cases the journal name incorrectly. Example, a French
journal named "Revue suisse de pédagogie spécialisée" is rendered as:

… (2026). Revue Suisse De pédagogie spécialisée, 16(02), 2-8. https://doi.org/…

Note the wrongly capitalized particle "De" (and "Suisse"). The stored journal name is
correctly lower-cased; the capitalization is introduced at render time.

Root cause

getCitation() builds the $citationData object but never sets the item language.
When the item has no language, citeproc-php assumes English and applies English
title-casing (text-case="title", used by APA/most styles on container-title). Per the
CSL spec, title-casing should only apply to English-language items — so the real fix is to
tell citeproc the item's language.

Fix

Set $citationData->language from the publication locale (falling back to the context
primary locale), normalized to a BCP-47-ish form (fr_FRfr-FR), before the
type-specific branches so it applies to articles, books and chapters alike:

$citationData->language = str_replace('_', '-', (string) ($publication->getData('locale') ?: $context->getPrimaryLocale()));

With a non-English language, citeproc no longer applies English title-case and the stored
casing is preserved for French/German/Italian/… journals. English journals are unaffected
(their locale is en*, so title-casing still applies as before).

How to reproduce / test

  1. Create/have a journal whose name contains a lowercase particle, e.g. "Revue suisse de …"
    or "Schweizerische Zeitschrift für …", with a non-English primary locale.
  2. Open a published article → "How to cite". Before: "Revue Suisse De …". After: "Revue
    suisse de …".
  3. Verified on OJS 3.5.0-4 (APA default style, fr_FR journal): the container-title casing is
    preserved, English journals unchanged.

getCitation() never set the item language, so citeproc assumed English and applied
English title-casing to fields like container-title, wrongly capitalizing lowercase
particles in non-English journal names (e.g. "Revue suisse de pédagogie spécialisée"
-> "Revue Suisse De pédagogie spécialisée"). Set language from the publication locale
(fallback to the context primary locale) so citeproc preserves the stored casing.
@asmecher

asmecher commented Jul 2, 2026

Copy link
Copy Markdown
Member

Thanks for the detailed filing, @robin-morand! Tagging @kaitlinnewson for a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants