Set the CSL item language so non-English titles aren't wrongly title-cased#167
Open
robin-morand wants to merge 1 commit into
Open
Set the CSL item language so non-English titles aren't wrongly title-cased#167robin-morand wants to merge 1 commit into
robin-morand wants to merge 1 commit into
Conversation
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.
Member
|
Thanks for the detailed filing, @robin-morand! Tagging @kaitlinnewson for a look. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
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$citationDataobject but never sets the itemlanguage.When the item has no language, citeproc-php assumes English and applies English
title-casing (
text-case="title", used by APA/most styles oncontainer-title). Per theCSL 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->languagefrom the publication locale (falling back to the contextprimary locale), normalized to a BCP-47-ish form (
fr_FR→fr-FR), before thetype-specific branches so it applies to articles, books and chapters alike:
With a non-English
language, citeproc no longer applies English title-case and the storedcasing 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
or "Schweizerische Zeitschrift für …", with a non-English primary locale.
suisse de …".
preserved, English journals unchanged.