plk / biblatex-apa

APA style for BibLaTeX
90 stars 48 forks source link

Problem with long dates in Spanish #114

Closed joaquimllisterri closed 4 years ago

joaquimllisterri commented 4 years ago

I am using the latest version of biblatex-apa with the spanish-apa.lbx file for localisation and there seems to be a problem with long dates with the same month but different days. For example,

2019-03-27/2019-04-29 is correctly rendered as "(2019, 27 de marzo-29 de abril)"

but

2019-03-27/2019-03-29 is rendered as "(2019, 27 de marzo-)" instead of "(2019, 27-29 de marzo)".

I have tried also with Galician (galician-apa.lbx), which has the same kind of date formats as Spanish, with the same results.

I originally asked the question on Tex stackexchange and the code provided in the answer (based on German) produces the correct rendering for long dates in Spanish:

`\documentclass[spanish]{article} \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \usepackage{babel} \usepackage{csquotes}

\usepackage[style=apa, backend=biber]{biblatex}

\makeatletter \DefineBibliographyExtras{spanish}{% \def\urldatecomma{\addcomma\addspace}% \protected\def\mkbibdateapalong#1#2#3{% % As per 10.1, Articles only have year \ifboolexpr{ test {\ifentrytype{article}} and not test {\ifkeyword{nonacademic}} } {\clearfield{labelmonth}% \clearfield{labelday}} {}% \iffieldundef{#1}% {}% {\iffieldbibstring{#1}{\biblcstring{\thefield{#1}}}{\thefield{#1}}% \ifboolexpr{test {\iffieldundef{#3}} and test {\iffieldundef{#2}}} {} {\addcomma\space}}% \iffieldundef{#3}% {}% {\stripzeros{\thefield{#3}}% \iffieldundef{#2} {} {\addspace de\space}}% \iffieldundef{#2}% {}% {\mkbibmonth{\thefield{#2}}}}% \protected\def\mkbibdateapalongextra#1#2#3{% % As per 10.1, Articles only have year \ifboolexpr{ test {\ifentrytype{article}} and not test {\ifkeyword{nonacademic}} } {\clearfield{labelmonth}% \clearfield{labelday}} {}% \iffieldundef{#1}% {}% {\iffieldbibstring{#1}{\biblcstring{\thefield{#1}}}{\thefield{#1}}% \printfield{extradate}% \ifboolexpr{test {\iffieldundef{#3}} and test {\iffieldundef{#2}}} {} {\addcomma\space}}% \iffieldundef{#3}% {}% {\stripzeros{\thefield{#3}}% \iffieldundef{#2} {} {\addspace de\space}}% \iffieldundef{#2}% {}% {\mkbibmonth{\thefield{#2}}}}% \protected\def\mkbibdateapalongmdy#1#2#3{% % As per 10.1, Articles only have year \ifboolexpr{ test {\ifentrytype{article}} and not test {\ifkeyword{nonacademic}} } {\clearfield{labelmonth}% \clearfield{labelday}} {}% \iffieldundef{#3}% {}% {el\addspace\stripzeros{\thefield{#3}}}% \iffieldundef{#2}% {\addspace{en}\addspace}% {\iffieldundef{#3}% {en\addspace}% {\addspace{de}\addspace}% \mkbibmonth{\thefield{#2}}{\addspace{de}\addspace}}% \iffieldundef{#1}% {}% {\iffieldundef{#2}% {}% {\addspace}% \thefield{#1}}}% \def\apa@lbx@es@mkdaterangeapalong#1{% \begingroup \blx@metadateinfo{#1}% \iffieldundef{#1year}{} {\datecircaprint \ifstrequal{#1}{url}% URL dates are unlikely to be BCE ... {\printtext{% \iffieldsequal{#1year}{#1endyear} {\iffieldsequal{#1month}{#1endmonth} {\mkbibdateapalongmdy{}{}{#1day}} {\mkbibdateapalongmdy{}{#1month}{#1day}}} {\mkbibdateapalongmdy{#1year}{#1month}{#1day}}% \iffieldundef{#1endyear}% {}% {\iffieldequalstr{#1endyear}{}% open-ended range? {\mbox{\bibdatedash}} {\bibdatedash% \mkbibdateapalongmdy{#1endyear}{#1endmonth}{#1endday}}}% \dateuncertainprint}} {\printtext{% \ifboolexpr{test {\iffieldsequal{#1year}{#1endyear}} and test {\iffieldsequal{#1month}{#1endmonth}}} {\mkbibdateapalong{#1year}{}{#1day}}% {\mkbibdateapalong{#1year}{#1month}{#1day}}% \dateeraprint{#1year}% \iffieldundef{#1endyear}% {}% {\iffieldequalstr{#1endyear}{}% open-ended range? {\mbox{\bibdatedash}} {\bibdatedash% \iffieldsequal{#1year}{#1endyear}% {\mkbibdateapalong{}{#1endmonth}{#1endday}}% {\mkbibdateapalong{#1endyear}{#1endmonth}{#1endday}% \dateeraprint{#1endyear}}}% \enddateuncertainprint}}}}% \endgroup}% \def\apa@lbx@es@mkdaterangeapalongextra#1{% \begingroup \blx@metadateinfo{#1}% \iffieldundef{#1year}{} {\printtext{% \datecircaprint \ifboolexpr{test {\iffieldsequal{#1year}{#1endyear}} and test {\iffieldsequal{#1month}{#1endmonth}}} {\mkbibdateapalongextra{#1year}{}{#1day}}% {\mkbibdateapalongextra{#1year}{#1month}{#1day}}% \dateeraprint{#1year}% \dateuncertainprint \iffieldundef{#1endyear}% {}% {\iffieldequalstr{#1endyear}{}% open-ended range? {\mbox{\bibdatedash}} {\bibdatedash% \iffieldsequal{#1year}{#1endyear}% {\mkbibdateapalongextra{}{#1endmonth}{#1endday}} {\mkbibdateapalongextra{#1endyear}{#1endmonth}{#1endday}% \dateeraprint{#1endyear}}}% \enddateuncertainprint}}}% \endgroup}% \savecommand\mkdaterangeapalong \savecommand\mkdaterangeapalongextra \def\mkdaterangeapalong{% \apa@lbx@es@mkdaterangeapalong}% \def\mkdaterangeapalongextra#1{% \apa@lbx@es@mkdaterangeapalongextra{#1}}% }

\UndefineBibliographyExtras{spanish}{% \restorecommand\mkdaterangeapalong \restorecommand\mkdaterangeapalongextra } \makeatother

\begin{filecontents}[force]{\jobname.bib} @book{appleby, author = {Humphrey Appleby}, title = {On the Importance of the Civil Service}, date = {2019-03-27/2019-03-29}, } @book{bppleby, author = {Humphrey Bppleby}, title = {On the Importance of the Civil Service}, date = {2019-03-27/2019-04-29}, } \end{filecontents} \addbibresource{\jobname.bib} \addbibresource{biblatex-examples.bib}

\begin{document} X\cite{sigfridsson,appleby,bppleby}X \printbibliography \end{document}`

Many thanks for the fast reply and for all the work with biblatex-apa.

plk commented 4 years ago

Can you get this file:

https://github.com/plk/biblatex-apa/raw/master/tex/latex/biblatex-apa/lbx/spanish-apa.lbx

and drop it over yours and see if it works for you?

You can find the location of your current file by running:

kpsewhich spanish-apa.lbx

joaquimllisterri commented 4 years ago

Can you get this file:

https://github.com/plk/biblatex-apa/raw/master/tex/latex/biblatex-apa/lbx/spanish-apa.lbx

and drop it over yours and see if it works for you?

You can find the location of your current file by running:

kpsewhich spanish-apa.lbx

I have replaced the old file, used the new one with several date formats in Spanish and, as far as I can see, all renderings are now correct. Thank you very much! It was really helpful.

plk commented 4 years ago

9.13 is released with this fix