\IfDocumentMetadataTF{}{\DocumentMetadata{}}
\documentclass[12pt,dutch]{article}
\usepackage{babel}
\usepackage{regulatory}

\newcommand\translation[2]{#2}

% Every source in this file was checked on 2024-01-01, and this document speaks as
% of that same day: nothing changed between the two.
\sourcedate{2024-01-01}
\loadsources{sources}
% The third route: a source that stands in the document itself, with no file.
\newsource{uavg}{regeling}{%
    citeertitel = Uitvoeringswet Algemene verordening gegevensbescherming,
    afkorting = UAVG,
    lidwoord = de, geldig = 2024-01-01%
}
% The same regulation as a German and a French document cite it: the register
% belongs to the source, so the source carries its name in the language it is cited
% in. These two use the English field names and the rest the Dutch ones; both are
% meant to work.
\newsource{avgde}{euact}{%
    kind = Verordnung, number = {(EU) 2016/679},
    shortname = Datenschutz-Grundverordnung, abbreviation = DSGVO,
    register = german_eu, valid = 2024-01-01%
}
\newsource{avgfr}{euact}{%
    kind = Règlement, number = {(UE) 2016/679},
    shortname = {règlement général sur la protection des données},
    abbreviation = RGPD, register = french_eu, valid = 2024-01-01%
}
% And as an English document cites it, which is the one register that turns the
% parts around: the deepest level first.
\newsource{avgen}{euact}{%
    kind = Regulation, number = {(EU) 2016/679},
    shortname = General Data Protection Regulation, abbreviation = GDPR,
    determiner = the, register = english_eu, valid = 2024-01-01%
}
% In English a treaty takes an article and a regulation does not, and that follows
% from the kind and not from the register.
\newsource{vweu}{regulation}{%
    citetitle = Treaty on the Functioning of the European Union,
    kind = Treaty, abbreviation = TFEU, register = english_eu, valid = 2024-01-01%
}
\newsource{wetib}{regeling}{%
    citeertitel = Wet inkomstenbelasting 2001,
    afkorting = Wet IB 2001,
    lidwoord = de, geldig = 2024-01-01%
}

\hypersetup{pdftitle={Voorbeeld Bronnen}}

% What the suite reads. A field that was read in wrongly does not show in the PDF,
% so it is named here where an assertion can reach it.
\newcommand\report[2]{\typeout{SRC #1 #2 = \srcfield{#1}{#2}}}
% The same for a citation: it is built first and typeset afterwards, so what was
% built is what an assertion can read. A citation in the wrong register fails
% nowhere, it simply stands there wrong.
\makeatletter
\newcommand\citereport[2]{#1\typeout{CITE #2 = \regulatory@src@last}}
\makeatother

% Which registers this bundle ships. The manual names them one by one and says
% which legal order each of them words, so the list is a claim like any other: a
% register added or renamed without the manual following would go unnoticed, since
% no document cites a register that is not there. Written in the order they were
% declared, which is the order the language files are read in.
\ExplSyntaxOn
\NewDocumentCommand \registerreport { }
  { \iow_term:e { REGISTERS~=~\seq_use:Nn \g__regulatory_src_registers_seq { ,~ } } }
\ExplSyntaxOff

\begin{document}
    \begin{center}
        \Huge Voorbeeld Bronnen
    \end{center}

    \registerreport
    \typeout{SRC bw6 type = \srctype{bw6}}
    \report{bw6}{citeertitel}
    \report{bw6}{afkorting}
    \report{bw6}{boek}
    \report{bw6}{bwbid}
    \report{bw6}{geldig}
    \typeout{SRC avg type = \srctype{avg}}
    \report{avg}{roepnaam}
    \report{avg}{afkorting}
    \report{avg}{pb}
    \report{uavg}{citeertitel}
    \typeout{SRC bw6 leeg = [\srcfield{bw6}{ditveldbestaatniet}]}
    \ifsourceexists{avg}{\typeout{SRC avg bestaat}}{\typeout{SRC avg ontbreekt}}
    \ifsourceexists{onbekend}{\typeout{SRC onbekend bestaat}}{\typeout{SRC onbekend ontbreekt}}

    \citereport{\srcref[artikel=96, lid=2, onderdeel=c]{bw6}}{nl-voluit}
    \citereport{\srcref*[artikel=96, lid=2, onderdeel=c]{bw6}}{nl-verkort}
    \citereport{\srcref[artikel=6, lid=1, onderdeel=a]{avg}}{eu-voluit}
    \citereport{\srcref*[artikel=6, lid=1, onderdeel=a]{avg}}{eu-verkort}
    \citereport{\srcref{avg}}{bron-voluit}
    \citereport{\srcref*{avg}}{bron-verkort}
    \citereport{\srcref[artikel=3.126, lid=1, onderdeel=d, onder=2]{wetib}}{vierde-niveau}
    \citereport{\srcref[artikel=6, lid=1, onderdeel=a]{avgde}}{de-voluit}
    \citereport{\srcref*[artikel=6, lid=1, onderdeel=a]{avgde}}{de-verkort}
    \citereport{\srcref[artikel=6, lid=1, onderdeel=a]{avgfr}}{fr-voluit}
    \citereport{\srcref*[artikel=6, lid=1, onderdeel=a]{avgfr}}{fr-verkort}
    % The same two citations with the English key names. The Dutch ones are
    % aliases of these, so both lines have to produce the same thing word for word;
    % where anything differs, the alias is not what it says it is.
    \citereport{\srcref[article=96, paragraph=2, point=c]{bw6}}{nl-engelse-sleutels}
    \citereport{\srcref[article=3.126, paragraph=1, point=d, subpoint=2]{wetib}}{vierde-niveau-engels}
    % Lists and runs: the author writes what he means, the register decides how it
    % reads.
    \citereport{\srcref[artikel=3.126, lid=1, onderdeel={c,d}]{wetib}}{lijst-nl}
    \citereport{\srcref[artikel={162--164}]{bw6}}{bereik-nl}
    \citereport{\srcref*[artikel={162--164}]{bw6}}{bereik-verkort}
    \citereport{\srcref[artikel=6, lid=1, onderdeel={c,e}]{avg}}{lijst-eu}
    \citereport{\srcref[artikel=6, lid=1, onderdeel={c,e}]{avgde}}{lijst-de}
    \citereport{\srcref[artikel=6, lid=1, onderdeel={a--c}]{avgde}}{bereik-de}
    \citereport{\srcref[artikel=6, lid={1,2,4}]{avgfr}}{lijst-fr}
    % English turns the parts around and writes the paragraph inside the article.
    \citereport{\srcref[artikel=6, lid=1, onderdeel=a]{avgen}}{en-voluit}
    \citereport{\srcref*[artikel=6, lid=1, onderdeel=a]{avgen}}{en-verkort}
    \citereport{\srcref[artikel=6]{avgen}}{en-artikel}
    \citereport{\srcref[lid=1, onderdeel=e]{avgen}}{en-lid-los}
    \citereport{\srcref[artikel=58, lid=1, onderdeel={e,f}]{avgen}}{en-lijst}
    \citereport{\srcref[artikel={12--15}]{avgen}}{en-bereik}
    \citereport{\srcref[artikel=58, lid=2, onderdeel={a--c}]{avgen}}{en-bereik-punten}
    \citereport{\srcref[lid={1--3}]{avgen}}{en-bereik-leden}
    \citereport{\srcref[artikel=6, lid={1,2,3}]{avgen}}{en-leden}
    \citereport{\srcref[artikel=6]{vweu}}{en-verdrag}

    \article{Bronnen}\label{art:bronnen}
    \begin{paras}
        \item \label{lid:regeling} \srcfield{bw6}{citeertitel} (\srcfield{bw6}{afkorting}),
            Boek~\srcfield{bw6}{boek}.
        \item \label{lid:euhandeling} \srcfield{avg}{soort}~\srcfield{avg}{nummer},
            \srcfield{avg}{roepnaam} (\srcfield{avg}{afkorting}).
        \item \label{lid:eigen} \srcfield{uavg}{citeertitel} (\srcfield{uavg}{afkorting}).
    \end{paras}

    \article{Verwijzingen}\label{art:verwijzingen}
    \begin{paras}
        \item \label{lid:voluit} Zoals bepaald in
            \srcref[artikel=96, lid=2, onderdeel=c]{bw6}.
        \item \label{lid:verkort} Zoals bepaald in
            \srcref*[artikel=96, lid=2, onderdeel=c]{bw6}.
        \item \label{lid:eu} Zoals bepaald in
            \srcref[artikel=6, lid=1, onderdeel=a]{avg}.
    \end{paras}
\end{document}
