# Main text and bibliography in two languages but with alternate date format

I'm writing a text in American English and German (new orthography), so I use \usepackage[ngerman,USenglish]{babel}. The biblatex bibliography also contains English and German references. I need the hyphenation rules of each language in the bibliography, so I use \usepackage[backend=biber,language=autobib,autolang=hyphen]{biblatex} and then specify the language of individual bibliography entries like this: langid = {ngerman}.

I would like all of the dates, however, to be in Australian format (dd Mon. YYYY). How can I get this date format (especially in the bibliography)?

(If I didn't need German hyphenation rules in the bibliography, I'd simply remove autolang and langid and use\usepackage[backend=biber,language=australian{biblatex}, although this would change the style of hyphenation, quotations, commas, etc. in the bibliography to australian style, too.)

• – moewe Mar 26 '19 at 12:25

I don't know an easy way to make all dates in the entire document follow the Australian format, but I know how to apply the Australian date format to the bibliography without affecting the hyphenation style.

You can add australian to babel and then switch the language to australian before printing the bibliography. Then all the dates in the bibliography will be Australian-style.

Be aware that this solution also affects other style factors within the bibliography such as serial commas (as described here) and quotation mark formatting. For example, references to articles printed in USenglish format use double quotes and keep end punctuation inside the quotes, while those printed in australian format use single quotes and keep the end punctuation outside the quotes:

"Article Title in American English."
'Article Title in Australian English'.

The following code exemplifies the result:

\documentclass{article}
\usepackage[ngerman,australian,USenglish]{babel}
\usepackage[autostyle]{csquotes}
\usepackage[backend=biber,language=autobib,autolang=hyphen,sorting=none]{biblatex}

\begin{filecontents}{testbib.bib}
@article{default2014,
author = {Vorname Nachname},
title = {The German Rindfleischetikettierungs\"uberwachungsaufgaben\"ubertragungsgesetz},
journaltitle = {Default Journal of Gastroenterology},
date = {2014-03-20},
}
@article{au2014,
author = {Vorname Nachname},
title = {The German Rindfleischetikettierungs\"uberwachungsaufgaben\"ubertragungsgesetz},
journaltitle = {Australian Journal of Gastroenterology},
date = {2014-03-20},
langid = {australian},
}
@article{us2014,
author = {Vorname Nachname},
title = {The German Rindfleischetikettierungs\"uberwachungsaufgaben\"ubertragungsgesetz},
journaltitle = {American Journal of Gastroenterology},
date = {2014-03-20},
langid = {USenglish},
}
@article{de2014,
author = {Vorname Nachname},
title = {Das deutsche Rindfleischetikettierungs\"uberwachungsaufgaben\"ubertragungsgesetz},
journaltitle = {Zeitschrift f\"ur Gastroenterologie},
date = {2014-03-20},
langid = {ngerman},
}
\end{filecontents}

\begin{document}
% main text here in USenglish (switch to ngerman when necessary)
The hyphenation rules of Australian English, American English, and German are\
different~\cite{default2014,au2014,us2014,de2014}.

\selectlanguage{australian} % for proper day/month order
\printbibliography
\end{document}


When the langid field is omitted, the hyphenation style defaults to that of the currently-selected language (in this example, australian).

• Your clarification shows why your second approach (your other answer to this question) is really the better way to go. – moewe Mar 22 '14 at 12:40
• @moewe Right! Originally, I didn't know exactly what other style changes existed between australian and USenglish. Once I found out, I knew I had to edit this answer to warn others. Still, this answer is a very simple way to change the date format if the user doesn't care about the other style changes. But for those who want to be more precise, the other solution is better. – Cerran Mar 22 '14 at 12:53
• australian is basically just an alias of british with the one exception that \mkbibdatelong is slightly altered. british and american differ in quotation marks, Oxford comma usage, and date formats (as you rightly mention above). – moewe Mar 22 '14 at 12:58

Thanks to moewe's answer here, I was able to figure out how to change all long dates in the entire document to Australian format. I then figured out how to display all short dates in d/m/y format (using code found in british.lbx, which is where australian.lbx inherits its short date format from). This answer changes the date formats (both short and long) and nothing else. It applies day-before-month style to an entire document written in American English.

The simplest way is to insert this in the preamble:

\DefineBibliographyExtras{USenglish}{%

% d-m-y format for long dates
\protected\def\mkbibdatelong#1#2#3{%
\iffieldundef{#3}
{}
{\stripzeros{\thefield{#3}}%
\iffieldundef{#2}{}{\nobreakspace}}%
\iffieldundef{#2}
{}
{\mkbibmonth{\thefield{#2}}%
\iffieldundef{#1}{}{\space}}%
\iffieldbibstring{#1}{\bibstring{\thefield{#1}}}{\stripzeros{\thefield{#1}}}}%

% d-m-y format for short dates
\protected\def\mkbibdateshort#1#2#3{%
\iffieldundef{#3}
{}
{\mkdatezeros{\thefield{#3}}%
\iffieldundef{#2}{}{/}}%
\iffieldundef{#2}
{}
{\mkdatezeros{\thefield{#2}}%
\iffieldundef{#1}{}{/}}%
\iffieldbibstring{#1}{\bibstring{\thefield{#1}}}{\mkdatezeros{\thefield{#1}}}}%
}


I wrote the code with the alias USenglish, but you can replace that with american if you choose. They are two names for the same style. You need to be sure that it's the same alias used when calling \usepackage{babel}, though. (If you change the properties of USenglish, don't expect the changes to be carried over to american!)

A more elegant solution is to make an .lbx file to stay more organized and make this style easily accessible in future documents. The code only differs at the beginning and end. You need to add \ProvidesFile to the top and \endinput to the bottom. Then add two \Inherit... commands and change any \Define... commands to Declare... commands.

\ProvidesFile{USenglish-dmy.lbx}[USenglish localization with d-m-y format for dates]

\InheritBibliographyExtras{USenglish}
\DeclareBibliographyExtras{%

% d-m-y format for long dates
\protected\def\mkbibdatelong#1#2#3{%
\iffieldundef{#3}
{}
{\stripzeros{\thefield{#3}}%
\iffieldundef{#2}{}{\nobreakspace}}%
\iffieldundef{#2}
{}
{\mkbibmonth{\thefield{#2}}%
\iffieldundef{#1}{}{\space}}%
\iffieldbibstring{#1}{\bibstring{\thefield{#1}}}{\stripzeros{\thefield{#1}}}}%

% d-m-y format for short dates
\protected\def\mkbibdateshort#1#2#3{%
\iffieldundef{#3}
{}
{\mkdatezeros{\thefield{#3}}%
\iffieldundef{#2}{}{/}}%
\iffieldundef{#2}
{}
{\mkdatezeros{\thefield{#2}}%
\iffieldundef{#1}{}{/}}%
\iffieldbibstring{#1}{\bibstring{\thefield{#1}}}{\mkdatezeros{\thefield{#1}}}}%
}

\InheritBibliographyStrings{USenglish}
\endinput


Save this as USenglish-dmy.lbx and then add this in your preamble: \DeclareLanguageMapping{USenglish}{USenglish-dmy}. That's it! Now all dates should have the day before the month, and nothing else (e.g. hyphenation or quotation styles) is affected.

• It actually does not matter whether you use american or USenglish, as the latter is just an alias for the former. – moewe Mar 22 '14 at 14:42
• @moewe Right, that was my point. Some people might not be familiar with the USenglish alias, so I wanted to say that they can replace it with american if they prefer. I guess I didn't get my point across, though, so I'll try to make it clearer. – Cerran Mar 22 '14 at 15:55

Had to use \DefineBibliographyExtras{english} to get the workaround to work on my setup (Biblatex + Polyglossia).

Polyglossia, via option processing, understands Australian as a variant of English,

\setmainlanguage[variant=australian,ordinalmonthday=true]{english}


but that doesn't change anything. The variant doesn't get into Biblatex and, unfortunately, the gloss-english.ldf language definition file sets \english@ordinalmonthday to false (and also \if@british@locale is false, so that \today gets redefined as American format).

In any case, Biblatex sees english as the polyglossia language, and so the dates in citations and references come out typeset as American format (which is default for english).

Biblatex on its own, without polyglossia, understands Australian dates.

So: since typesetting in a language is, in the end, a set of user options or design choices, like a 'style' or a 'theme' (hyphenation patterns, the names of months and document parts, quotation marks and punctuation, page geometry), and since the Biblatex documentation thinks that Australian is a language ("known to Polyglossia"), why not make it one?

gloss-australian.ldf, which is just gloss-english.ldf with some minor tweaks:

\ProvidesFile{gloss-australian.ldf}[polyglossia: module for australian english]%<=== changed for australian
\PolyglossiaSetup{australian}{%<=== changed for australian
hyphennames={english,australian,american,usenglish,USenglish},%<=== changed for australian
hyphenmins={2,3},
fontsetup=true,
}

\newif\if@british@locale
\@british@localetrue %<=== changed for australian
\providebool{@british@hyphen}
\providebool{english@ordinalmonthday}

\define@boolkey{english}[english@]{ordinalmonthday}[true]{}

%% English is a special case in that \l@english is reserved for US English, so
%% we need to handle it differently
\define@key{english}{variant}{%
%needs to be reset for loop over hyphennames below:
\def\do##1{%
\xpg@ifdefined{#1}%
{\csletcs{l@english}{l@#1}\listbreak}%
{}%
}%
\ifstrequal{#1}{uk}%
{\@british@localetrue
\xpg@info{Option: english variant=british}}%
{\ifstrequal{#1}{british}%
{\@british@localetrue
\xpg@info{Option: english variant=british}}%
{\ifstrequal{#1}{us}% these patterns are the default so we don't need to reset them
{\@british@hyphenfalse\english@ordinalmonthdayfalse
\xpg@info{Option: english variant=american}}%
{\ifstrequal{#1}{american}%
{\@british@hyphenfalse\english@ordinalmonthdayfalse
\xpg@info{Option: english variant=american}}%
{\ifstrequal{#1}{usmax}%
{\@british@hyphenfalse\english@ordinalmonthdayfalse
\ifluatex\else\setkeys[xpg@setup]{english}{hyphennames={usenglishmax}}\fi
\xpg@info{Option: english variant=american (with additional patterns)}%
\xpg@ifdefined{usenglishmax}{}%
{\xpg@warning{No hyphenation patterns were loaded for "US English Max"\MessageBreak
I will use the standard patterns for US English instead}%
\gdef\english@language{\language=\l@usenglishmax}}%
{\ifstrequal{#1}{australian}%
{\@british@hyphentrue\english@ordinalmonthdaytrue %<=== changed for australian
\xpg@info{Option: english variant=australian}}%
{\ifstrequal{#1}{newzealand}%
{\@british@hyphentrue\english@ordinalmonthdayfalse
\xpg@info{Option: english variant=newzealand}}%
{\xpg@warning{Unknown English variant #1'}}%
}}}}}}%
\if@british@locale\@british@hyphentrue\english@ordinalmonthdaytrue\fi
\if@british@hyphen
\ifluatex\else\setkeys[xpg@setup]{english}{hyphennames={ukenglish,british,UKenglish}}\fi
\xpg@ifdefined{ukenglish}{}%
{\xpg@warning{No hyphenation patterns were loaded for British English\MessageBreak
I will use the patterns for US English instead}%
\gdef\english@language{\language=\l@ukenglish\xpg@set@language@luatex@ii{ukenglish}}%
\fi
% and we reset \do to its previous definition here:
\def\do##1{\setotherlanguage{#1}}%
}

\def\captionsenglish{%
\def\prefacename{Preface}%
\def\refname{References}%
\def\abstractname{Abstract}%
\def\bibname{Bibliography}%
\def\chaptername{Chapter}%
\def\appendixname{Appendix}%
\def\contentsname{Contents}%
\def\listfigurename{List of Figures}%
\def\listtablename{List of Tables}%
\def\indexname{Index}%
\def\figurename{Figure}%
\def\tablename{Table}%
\def\partname{Part}%
\def\enclname{encl}%
\def\ccname{cc}%
\def\pagename{Page}%
\def\seename{see}%
\def\proofname{Proof}%
}
\def\dateenglish{%
\def\english@day{%
\ifenglish@ordinalmonthday
\ifcase\day\or
1st\or 2nd\or 3rd\or 4th\or 5th\or
6th\or 7th\or 8th\or 9th\or 10th\or
11th\or 12th\or 13th\or 14th\or 15th\or
16th\or 17th\or 18th\or 19th\or 20th\or
21st\or 22nd\or 23rd\or 24th\or 25th\or
26th\or 27th\or 28th\or 29th\or 30th\or
31st\fi
\else\number\day\fi}%
\def\english@month{\ifcase\month\or
January\or February\or March\or April\or May\or June\or
July\or August\or September\or October\or November\or December\fi}%
\def\today{%
\if@british@locale
\english@day\space\english@month\space\number\year
\else
\ifenglish@ordinalmonthday%<=== inserted for australian
\english@day\space\english@month\space\number\year%<=== inserted for australian
\else%<=== inserted for australian
\english@month\space\english@day,\space\number\year
\fi%<=== inserted for australian
\fi}%
}

\endinput


MWE, language set to australian in Polyglossia giving the DMY format in Biblatex, with datetime2 package to reset \today back to what it should be (for the title), and csquotes package for the quotation marks.

\RequirePackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@periodical{jtest,journaltitle={The Martian Chronicle},location={Mars},date={2148-03-26},}
@article{atest,author={AI Author},title={Human professor explores Olympus},crossref={jtest},pages={para 9},}
\end{filecontents*}

\documentclass[12pt]{article}

% SETTINGS
%  ===================================
\newcommand\mytitle{A Title}
\newcommand\myauthorname{An Author}
\newcommand\mybibfilename{\jobname.bib}
%  ===================================
\usepackage{fontspec}
\setmainfont{Noto Serif} %arbitrary font
\usepackage{polyglossia}
\setmainlanguage{australian}
\usepackage[british]{datetime2} % for date formatting of \today: put after polyglossia

\usepackage[style=british]{csquotes}
\usepackage[style=oxnotes,    citereset=section,
ibidtracker=true,
sortlocale=en_AU,
scnames=true,
%annotation = true,
indexing=cite,
mincrossrefs=20,
backend=biber,
isbn=false,
%backref=true,
language=australian,
abbreviate=true,
date=long,
%babel=hyphen
%autolang=true
]{biblatex}

\title{\mytitle} % provide title info
\author{\myauthorname}          % provide author info
\date{\today}           % provide date

\begin{document}
\maketitle
Text\cite{atest}.
\printbibliography
\end{document}


Result:

Changing the language to english gives the cite/bib MDY format

\setmainlanguage{english}`