diff options
author | Karl Berry <karl@freefriends.org> | 2022-01-11 22:01:01 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2022-01-11 22:01:01 +0000 |
commit | fa4d2a5e2aa4aef4c17f825a54127ab10979e27c (patch) | |
tree | 950f60c4d5dda23e9195af93d49623c0d27b6dc3 /Master/texmf-dist/source | |
parent | 94a61ef951904c933eda185e73e73a42ce34725f (diff) |
zref-clever (11jan22)
git-svn-id: svn://tug.org/texlive/trunk@61572 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source')
-rw-r--r-- | Master/texmf-dist/source/latex/zref-clever/zref-clever.dtx | 1469 | ||||
-rw-r--r-- | Master/texmf-dist/source/latex/zref-clever/zref-clever.ins | 15 |
2 files changed, 1033 insertions, 451 deletions
diff --git a/Master/texmf-dist/source/latex/zref-clever/zref-clever.dtx b/Master/texmf-dist/source/latex/zref-clever/zref-clever.dtx index ac9d81f44e6..3027bcab15e 100644 --- a/Master/texmf-dist/source/latex/zref-clever/zref-clever.dtx +++ b/Master/texmf-dist/source/latex/zref-clever/zref-clever.dtx @@ -4,7 +4,7 @@ % % This file is part of the LaTeX package "zref-clever". % -% Copyright (C) 2021 Gustavo Barros +% Copyright (C) 2021-2022 Gustavo Barros % % It may be distributed and/or modified under the conditions of the % LaTeX Project Public License (LPPL), either version 1.3c of this @@ -63,6 +63,9 @@ % \NewDocumentCommand\githubissue{m}{^^A % issue~\href{https://github.com/gusbrs/zref-clever/issues/#1}{\##1}} % +% \NewDocumentCommand\githubPR{m}{^^A +% PR~\href{https://github.com/gusbrs/zref-clever/pull/#1}{\##1}} +% % ^^A Currently just for keeping semantic markup on this. % \NewDocumentCommand\contributor{m}{#1} % @@ -129,7 +132,7 @@ % \cs{bool_case_true:}\dots{}). We presume \pkg{xparse} (which made to the % kernel in the 2020-10-01 release), and \pkg{expl3} as well (which made to % the kernel in the 2020-02-02 release). We also just use UTF-8 for the -% dictionaries (which became the default input encoding in the 2018-04-01 +% language files (which became the default input encoding in the 2018-04-01 % release). Finally, a couple of changes came with the 2021-11-15 kernel % release, which are important here. First, a fix was made to the new hook % management system (\pkg{ltcmdhooks}), with implications to the hook we add @@ -159,7 +162,7 @@ % % Identify the package. % \begin{macrocode} -\ProvidesExplPackage {zref-clever} {2021-12-07} {0.1.1-alpha} +\ProvidesExplPackage {zref-clever} {2022-01-10} {0.1.2-alpha} {Clever LaTeX cross-references based on zref} % \end{macrocode} % @@ -520,6 +523,11 @@ } \msg_new:nnn { zref-clever } { key-requires-value } { The~'#1'~key~'#2'~requires~a~value~\msg_line_context:. } +\msg_new:nnn { zref-clever } { key-boolean-or-empty } + { + The~key~'#1'~only~accepts~the~values~'true',~'false'~ + or~an~empty~value~\msg_line_context:. + } \msg_new:nnn { zref-clever } { language-declared } { Language~'#1'~is~already~declared~\msg_line_context:.~Nothing~to~do. } \msg_new:nnn { zref-clever } { unknown-language-alias } @@ -597,14 +605,15 @@ { Unknown~value~'#1'~for~'nudgeif'~option~\msg_line_context:. } \msg_new:nnn { zref-clever } { option-document-only } { Option~'#1'~is~only~available~after~\iow_char:N\\begin\{document\}. } -\msg_new:nnn { zref-clever } { dict-loaded } - { Loaded~'#1'~dictionary. } -\msg_new:nnn { zref-clever } { dict-not-available } - { Dictionary~for~'#1'~not~available~\msg_line_context:. } +\msg_new:nnn { zref-clever } { langfile-loaded } + { Loaded~'#1'~language~file. } +\msg_new:nnn { zref-clever } { langfile-not-available } + { Language~file~for~'#1'~not~available~\msg_line_context:. } \msg_new:nnn { zref-clever } { unknown-language-load } { - Language~'#1'~is~unknown~\msg_line_context:.~Unable~to~load~dictionary.~ - See~documentation~for~'\iow_char:N\\zcDeclareLanguage'~and~ + Language~'#1'~is~unknown~\msg_line_context:.~ + Unable~to~load~language~file.~See~documentation~for~ + '\iow_char:N\\zcDeclareLanguage'~and~ '\iow_char:N\\zcDeclareLanguageAlias'. } \msg_new:nnn { zref-clever } { zref-property-undefined } @@ -654,28 +663,33 @@ { Loaded~support~for~'#1'~package. } \msg_new:nnn { zref-clever } { compat-class } { Loaded~support~for~'#1'~documentclass. } +\msg_new:nnn { zref-clever } { option-deprecated } + { + Option~'#1'~has~been~deprecated~\msg_line_context:.\iow_newline: + Use~'#2'~instead. + } % \end{macrocode} % % % \subsection{Data extraction} % % -% \begin{macro}{\@@_def_extract:Nnnn} +% \begin{macro}{\@@_extract_default:Nnnn} % Extract property \meta{prop} from \meta{label} and sets variable \meta{tl % var} with extracted value. Ensure \cs{zref@extractdefault} is expanded % exactly twice, but no further to retrieve the proper value. In case the % property is not found, set \meta{tl var} with \meta{default}. % \begin{syntax} -% \cs{@@_def_extract:Nnnn} \Arg{tl val} +% \cs{@@_extract_default:Nnnn} \Arg{tl val} % ~~\Arg{label} \Arg{prop} \Arg{default} % \end{syntax} % \begin{macrocode} -\cs_new_protected:Npn \@@_def_extract:Nnnn #1#2#3#4 +\cs_new_protected:Npn \@@_extract_default:Nnnn #1#2#3#4 { \exp_args:NNNo \exp_args:NNo \tl_set:Nn #1 { \zref@extractdefault {#2} {#3} {#4} } } -\cs_generate_variant:Nn \@@_def_extract:Nnnn { NVnn } +\cs_generate_variant:Nn \@@_extract_default:Nnnn { NVnn } % \end{macrocode} % \end{macro} % @@ -714,31 +728,32 @@ % % For a general discussion on the precedence rules for reference format % options, see Section ``Reference format'' in the User manual. Internally, -% these precedence rules are handled / enforced in \cs{@@_get_ref_string:nN}, -% \cs{@@_get_ref_font:nN}, and \cs{@@_type_name_setup:} which are the basic -% functions to retrieve proper values for reference format settings. The -% ``fallback'' settings are stored in \cs{g_@@_fallback_dict_prop}. +% these precedence rules are handled / enforced in +% \cs{@@_get_ref_opt_typeset:nN}, \cs{@@_get_ref_opt_font:nN}, and +% \cs{@@_type_name_setup:} which are the basic functions to retrieve proper +% values for reference format settings. The ``fallback'' settings are stored +% in \cs{g_@@_fallback_unknown_lang_prop}. % % % \begin{macro} % { % \l_@@_setup_type_tl , -% \l_@@_dict_language_tl , -% \l_@@_dict_decl_case_tl , -% \l_@@_dict_declension_seq , -% \l_@@_dict_gender_seq , +% \l_@@_base_language_tl , +% \l_@@_lang_decl_case_tl , +% \l_@@_lang_declension_seq , +% \l_@@_lang_gender_seq , % } % Store ``current'' type, language, and declension cases in different places -% for option and translation handling, notably in -% \cs{@@_provide_dictionary:n}, \cs{zcRefTypeSetup}, and -% \cs{zcLanguageSetup}. But also for translations retrieval, in -% \cs{@@_get_type_transl:nnnN} and \cs{@@_get_default_transl:nnN}. +% for type-specific and language-specific options handling, notably in +% \cs{@@_provide_langfile:n}, \cs{zcRefTypeSetup}, and +% \cs{zcLanguageSetup}. But also for language options retrieval, in +% \cs{@@_get_lang_opt_type:nnnN} and \cs{@@_get_lang_opt_default:nnN}. % \begin{macrocode} \tl_new:N \l_@@_setup_type_tl -\tl_new:N \l_@@_dict_language_tl -\tl_new:N \l_@@_dict_decl_case_tl -\seq_new:N \l_@@_dict_declension_seq -\seq_new:N \l_@@_dict_gender_seq +\tl_new:N \l_@@_base_language_tl +\tl_new:N \l_@@_lang_decl_case_tl +\seq_new:N \l_@@_lang_declension_seq +\seq_new:N \l_@@_lang_gender_seq % \end{macrocode} % \end{macro} % @@ -773,13 +788,13 @@ listsep , lastsep , rangesep , - refpre , - refpos , + preref , + postref , } % \end{macrocode} % Only ``type names'' are ``necessarily type-specific'', which makes them % somewhat special on the retrieval side of things. In short, they don't have -% their values queried by \cs{@@_get_ref_string:nN}, but by +% their values queried by \cs{@@_get_ref_opt_typeset:nN}, but by % \cs{@@_type_name_setup:}. % \begin{macrocode} \seq_const_from_clist:Nn @@ -830,12 +845,13 @@ % % \begin{macro}{\g_@@_languages_prop} % Stores the names of known languages and the mapping from ``language name'' -% to ``dictionary name''. Whether or not a language or alias is known to +% to ``base language name''. Whether or not a language or alias is known to % \pkg{zref-clever} is decided by its presence in this property list. A % ``base language'' (loose concept here, meaning just ``the name we gave for -% the dictionary in that particular language'') is just like any other one, -% the only difference is that the ``language name'' happens to be the same -% as the ``dictionary name'', in other words, it is an ``alias to itself''. +% the language file in that particular language'') is just like any other +% one, the only difference is that the ``language name'' happens to be the +% same as the ``base language name'', in other words, it is an ``alias to +% itself''. % \begin{macrocode} \prop_new:N \g_@@_languages_prop % \end{macrocode} @@ -844,7 +860,7 @@ % % \begin{macro}[int]{\zcDeclareLanguage} % Declare a new language for use with \pkg{zref-clever}. \meta{language} is -% taken to be both the ``language name'' and the ``dictionary name''. +% taken to be both the ``language name'' and the ``base language name''. % \oarg{options} receive a \texttt{k=v} set of options, with three valid % options. The first, \opt{declension}, takes the noun declension cases % prefixes for \meta{language} as a comma separated list, whose first @@ -856,7 +872,7 @@ % \meta{language} is already known, just warn. This implies a particular % restriction regarding \oarg{options}, namely that these options, when % defined by the package, cannot be redefined by the user. This is -% deliberate, otherwise the built-in dictionaries would become much too +% deliberate, otherwise the built-in language files would become much too % sensitive to this particular user input, and unnecessarily so. % \cs{zcDeclareLanguage} is preamble only. % \begin{syntax} @@ -872,8 +888,8 @@ { \msg_warning:nnn { zref-clever } { language-declared } {#2} } { \prop_gput:Nnn \g_@@_languages_prop {#2} {#2} - \prop_new:c { g_@@_dict_ #2 _prop } - \tl_set:Nn \l_@@_dict_language_tl {#2} + \prop_new:c { g_@@_lang_ #2 _prop } + \tl_set:Nn \l_@@_base_language_tl {#2} \keys_set:nn { zref-clever / declarelang } {#1} } } @@ -885,10 +901,10 @@ % % % \begin{macro}[int]{\zcDeclareLanguageAlias} -% Declare \meta{language alias} to be an alias of \meta{aliased language}. -% \meta{aliased language} must be already known to \pkg{zref-clever}, as -% stored in \cs{g_@@_languages_prop}. \cs{zcDeclareLanguageAlias} is -% preamble only. +% Declare \meta{language alias} to be an alias of \meta{aliased language} +% (or ``base language''). \meta{aliased language} must be already known to +% \pkg{zref-clever}, as stored in \cs{g_@@_languages_prop}. +% \cs{zcDeclareLanguageAlias} is preamble only. % \begin{syntax} % \cs{zcDeclareLanguageAlias} \marg{language alias} \marg{aliased language} % \end{syntax} @@ -918,21 +934,21 @@ declension .code:n = { \prop_gput:cnn - { g_@@_dict_ \l_@@_dict_language_tl _prop } + { g_@@_lang_ \l_@@_base_language_tl _prop } { declension } {#1} } , declension .value_required:n = true , gender .code:n = { \prop_gput:cnn - { g_@@_dict_ \l_@@_dict_language_tl _prop } + { g_@@_lang_ \l_@@_base_language_tl _prop } { gender } {#1} } , gender .value_required:n = true , allcaps .code:n = { \prop_gput:cnn - { g_@@_dict_ \l_@@_dict_language_tl _prop } + { g_@@_lang_ \l_@@_base_language_tl _prop } { allcaps } { true } } , allcaps .value_forbidden:n = true , @@ -956,7 +972,7 @@ { \exp_args:NNx \prop_get:NnNTF \g_@@_languages_prop { \l_@@_ref_language_tl } - \l_@@_dict_language_tl + \l_@@_base_language_tl { % \end{macrocode} % Validate the declension case (\opt{d}) option against the declared cases for @@ -967,16 +983,16 @@ % warning about it. % \begin{macrocode} \exp_args:NNx \seq_set_from_clist:Nn - \l_@@_dict_declension_seq + \l_@@_lang_declension_seq { \prop_item:cn { - g_@@_dict_ - \l_@@_dict_language_tl _prop + g_@@_lang_ + \l_@@_base_language_tl _prop } { declension } } - \seq_if_empty:NTF \l_@@_dict_declension_seq + \seq_if_empty:NTF \l_@@_lang_declension_seq { \tl_if_empty:NF \l_@@_ref_decl_case_tl { @@ -990,18 +1006,18 @@ { \tl_if_empty:NTF \l_@@_ref_decl_case_tl { - \seq_get_left:NN \l_@@_dict_declension_seq + \seq_get_left:NN \l_@@_lang_declension_seq \l_@@_ref_decl_case_tl } { - \seq_if_in:NVF \l_@@_dict_declension_seq + \seq_if_in:NVF \l_@@_lang_declension_seq \l_@@_ref_decl_case_tl { \msg_warning:nnxx { zref-clever } { unknown-decl-case } { \l_@@_ref_decl_case_tl } { \l_@@_ref_language_tl } - \seq_get_left:NN \l_@@_dict_declension_seq + \seq_get_left:NN \l_@@_lang_declension_seq \l_@@_ref_decl_case_tl } } @@ -1012,16 +1028,16 @@ % genders declared for the former, clear \cs{l_@@_ref_gender_tl} and warn. % \begin{macrocode} \exp_args:NNx \seq_set_from_clist:Nn - \l_@@_dict_gender_seq + \l_@@_lang_gender_seq { \prop_item:cn { - g_@@_dict_ - \l_@@_dict_language_tl _prop + g_@@_lang_ + \l_@@_base_language_tl _prop } { gender } } - \seq_if_empty:NTF \l_@@_dict_gender_seq + \seq_if_empty:NTF \l_@@_lang_gender_seq { \tl_if_empty:NF \l_@@_ref_gender_tl { @@ -1036,7 +1052,7 @@ { \tl_if_empty:NF \l_@@_ref_gender_tl { - \seq_if_in:NVF \l_@@_dict_gender_seq + \seq_if_in:NVF \l_@@_lang_gender_seq \l_@@_ref_gender_tl { \msg_warning:nnxx { zref-clever } @@ -1048,20 +1064,20 @@ } } % \end{macrocode} -% Ensure \cs{l_@@_capitalize_bool} is set to \texttt{true} when the language -% was declared with \opt{allcaps} option. +% Ensure the \opt{cap} in \cs{l_@@_ref_options_prop} is set to \texttt{true} +% when the language was declared with \opt{allcaps} option. % \begin{macrocode} \str_if_eq:eeT { \prop_item:cn { - g_@@_dict_ - \l_@@_dict_language_tl _prop + g_@@_lang_ + \l_@@_base_language_tl _prop } { allcaps } } { true } - { \bool_set_true:N \l_@@_capitalize_bool } + { \prop_put:Nnn \l_@@_ref_options_prop { cap } { true } } } { % \end{macrocode} @@ -1091,26 +1107,25 @@ % % % -% \subsection{Dictionaries} +% \subsection{Language files} % % Contrary to general options and type options, which are always \emph{local}, -% ``dictionaries'', ``translations'' or ``language-specific settings'' are -% always \emph{global}. Hence, the loading of built-in dictionaries, as well -% as settings done with \cs{zcLanguageSetup}, should set the relevant -% variables globally. -% -% The built-in dictionaries and their related infrastructure are designed to -% perform ``on the fly'' loading of dictionaries, ``lazily'' as needed. Much -% like \pkg{babel} does for languages not declared in the preamble, but used -% in the document. This offers some convenience, of course, and that's one -% reason to do it. But it also has the purpose of parsimony, of ``loading the -% least possible''. Therefore, we load at \texttt{begindocument} one single -% language (see \zcref[ref=title, noname]{sec:lang-option}), as specified by -% the user in the preamble with the \opt{lang} option or, failing any -% specification, the current language of the document, which is the default. -% Anything else is lazily loaded, on the fly, along the document. -% -% This design decision has also implications to the \emph{form} the dictionary +% language-specific settings are always \emph{global}. Hence, the loading of +% built-in language files, as well as settings done with \cs{zcLanguageSetup}, +% should set the relevant variables globally. +% +% The built-in language files and their related infrastructure are designed to +% perform ``on the fly'' loading of the language files, ``lazily'' as needed. +% Much like \pkg{babel} does for languages not declared in the preamble, but +% used in the document. This offers some convenience, of course, and that's +% one reason to do it. But it also has the purpose of parsimony, of ``loading +% the least possible''. Therefore, we load at \texttt{begindocument} one +% single language (see \zcref[ref=title, noname]{sec:lang-option}), as +% specified by the user in the preamble with the \opt{lang} option or, failing +% any specification, the current language of the document, which is the +% default. Anything else is lazily loaded, on the fly, along the document. +% +% This design decision has also implications to the \emph{form} the language % files assumed. As far as my somewhat impressionistic sampling goes, % dictionary or localization files of the most common packages in this area of % functionality, are usually a set of commands which perform the relevant @@ -1126,193 +1141,196 @@ % \file{.ini} files are not in this form, but actually resemble % ``configuration files'' of sorts, which means they are read and processed % somehow else than with just \cs{input}. So we do the more or less the same -% here. It seems a reasonable way to ensure we can load dictionaries on the +% here. It seems a reasonable way to ensure we can load language files on the % fly robustly mid-document, without getting paranoid with the last bit of % white-space in them, and without introducing any undue content on the stream % when we cannot afford to do it. Hence, \pkg{zref-clever}'s built-in -% dictionary files are a set of \emph{key-value options} which are read from -% the file, and fed to \texttt{\cs{keys_set:nn}\{zref-clever/dictionary\}} by -% \cs{@@_provide_dictionary:n}. And they use the same syntax and options as -% \cs{zcLanguageSetup} does. The dictionary file itself is read with +% language files are a set of \emph{key-value options} which are read from the +% file, and fed to \texttt{\cs{keys_set:nn}\{zref-clever/langfile\}} by +% \cs{@@_provide_langfile:n}. And they use the same syntax and options as +% \cs{zcLanguageSetup} does. The language file itself is read with % \cs{ExplSyntaxOn} with the usual implications for white-space and catcodes. % -% \cs{@@_provide_dictionary:n} is only meant to load the built-in -% dictionaries. For languages declared by the user, or for any settings to a -% known language made with \cs{zcLanguageSetup}, values are populated directly -% to a variable \cs{g_@@_dict_\meta{language}_prop}. Hence, there is no need -% to ``load'' anything in this case: definitions and assignments made by the -% user are performed immediately. +% \cs{@@_provide_langfile:n} is only meant to load the built-in language +% files. For languages declared by the user, or for any settings to a known +% language made with \cs{zcLanguageSetup}, values are populated directly to a +% variable \cs{g_@@_lang_\meta{language}_prop}. Hence, there is no need to +% ``load'' anything in this case: definitions and assignments made by the user +% are performed immediately. % % % \subsubsection*{Provide} % -% \begin{macro}{\g_@@_loaded_dictionaries_seq} -% Used to keep track of whether a dictionary has already been loaded or not. +% \begin{macro}{\g_@@_loaded_langfiles_seq} +% Used to keep track of whether a language file has already been loaded or +% not. % \begin{macrocode} -\seq_new:N \g_@@_loaded_dictionaries_seq +\seq_new:N \g_@@_loaded_langfiles_seq % \end{macrocode} % \end{macro} % -% \begin{macro}{\l_@@_load_dict_verbose_bool} -% Controls whether \cs{@@_provide_dictionary:n} fails silently or verbosely -% in case of unknown languages or dictionaries not found. +% \begin{macro}{\l_@@_load_langfile_verbose_bool} +% Controls whether \cs{@@_provide_langfile:n} fails silently or verbosely +% in case of unknown languages or not found language files. % \begin{macrocode} -\bool_new:N \l_@@_load_dict_verbose_bool +\bool_new:N \l_@@_load_langfile_verbose_bool % \end{macrocode} % \end{macro} % % -% \begin{macro}{\@@_provide_dictionary:n} -% Load dictionary for known \meta{language} if it is available and if it has -% not already been loaded. +% \begin{macro}{\@@_provide_langfile:n} +% Load language file for known \meta{language} if it is available and if it +% has not already been loaded. % \begin{syntax} -% \cs{@@_provide_dictionary:n} \Arg{language} +% \cs{@@_provide_langfile:n} \Arg{language} % \end{syntax} % \begin{macrocode} -\cs_new_protected:Npn \@@_provide_dictionary:n #1 +\cs_new_protected:Npn \@@_provide_langfile:n #1 { \group_begin: \@bsphack \prop_get:NnNTF \g_@@_languages_prop {#1} - \l_@@_dict_language_tl + \l_@@_base_language_tl { \seq_if_in:NVF - \g_@@_loaded_dictionaries_seq - \l_@@_dict_language_tl + \g_@@_loaded_langfiles_seq + \l_@@_base_language_tl { \exp_args:Nx \file_get:nnNTF - { zref-clever- \l_@@_dict_language_tl .dict } + { zref-clever- \l_@@_base_language_tl .lang } { \ExplSyntaxOn } \l_tmpa_tl { \tl_clear:N \l_@@_setup_type_tl \exp_args:NNx \seq_set_from_clist:Nn - \l_@@_dict_declension_seq + \l_@@_lang_declension_seq { \prop_item:cn { - g_@@_dict_ - \l_@@_dict_language_tl _prop + g_@@_lang_ + \l_@@_base_language_tl _prop } { declension } } - \seq_if_empty:NTF \l_@@_dict_declension_seq - { \tl_clear:N \l_@@_dict_decl_case_tl } + \seq_if_empty:NTF \l_@@_lang_declension_seq + { \tl_clear:N \l_@@_lang_decl_case_tl } { - \seq_get_left:NN \l_@@_dict_declension_seq - \l_@@_dict_decl_case_tl + \seq_get_left:NN \l_@@_lang_declension_seq + \l_@@_lang_decl_case_tl } \exp_args:NNx \seq_set_from_clist:Nn - \l_@@_dict_gender_seq + \l_@@_lang_gender_seq { \prop_item:cn { - g_@@_dict_ - \l_@@_dict_language_tl _prop + g_@@_lang_ + \l_@@_base_language_tl _prop } { gender } } - \keys_set:nV { zref-clever / dictionary } \l_tmpa_tl - \seq_gput_right:NV \g_@@_loaded_dictionaries_seq - \l_@@_dict_language_tl - \msg_note:nnx { zref-clever } { dict-loaded } - { \l_@@_dict_language_tl } + \keys_set:nV { zref-clever / langfile } \l_tmpa_tl + \seq_gput_right:NV \g_@@_loaded_langfiles_seq + \l_@@_base_language_tl + \msg_note:nnx { zref-clever } { langfile-loaded } + { \l_@@_base_language_tl } } { - \bool_if:NT \l_@@_load_dict_verbose_bool + \bool_if:NT \l_@@_load_langfile_verbose_bool { - \msg_warning:nnx { zref-clever } { dict-not-available } - { \l_@@_dict_language_tl } + \msg_warning:nnx { zref-clever } { langfile-not-available } + { \l_@@_base_language_tl } } % \end{macrocode} -% Even if we don't have the actual dictionary, we register it as ``loaded''. -% At this point, it is a known language, properly declared. There is no point -% in trying to load it multiple times, because users cannot really provide the -% dictionary files (well, technically they could, but we are working so they -% don't need to, and have better ways to do what they want). And if the users -% had provided some translations themselves, by means of \cs{zcLanguageSetup}, -% everything would be in place, and they could use the \opt{lang} option -% multiple times, and the \texttt{dict-not-available} warning would never go -% away. -% \begin{macrocode} - \seq_gput_right:NV \g_@@_loaded_dictionaries_seq - \l_@@_dict_language_tl +% Even if we don't have the actual language file, we register it as +% ``loaded''. At this point, it is a known language, properly declared. +% There is no point in trying to load it multiple times, because users cannot +% really provide the language files (well, technically they could, but we are +% working so they don't need to, and have better ways to do what they want). +% And if the users had provided some language-specific options themselves, by +% means of \cs{zcLanguageSetup}, everything would be in place, and they could +% use the \opt{lang} option multiple times, and the +% \texttt{langfile-not-available} warning would never go away. +% \begin{macrocode} + \seq_gput_right:NV \g_@@_loaded_langfiles_seq + \l_@@_base_language_tl } } } { - \bool_if:NT \l_@@_load_dict_verbose_bool + \bool_if:NT \l_@@_load_langfile_verbose_bool { \msg_warning:nnn { zref-clever } { unknown-language-load } {#1} } } \@esphack \group_end: } -\cs_generate_variant:Nn \@@_provide_dictionary:n { x } +\cs_generate_variant:Nn \@@_provide_langfile:n { x } % \end{macrocode} % \end{macro} % % -% \begin{macro}{\@@_provide_dictionary_verbose:n} -% Does the same as \cs{@@_provide_dictionary:n}, but warns if the loading of -% the dictionary has failed. +% \begin{macro}{\@@_provide_langfile_verbose:n} +% Does the same as \cs{@@_provide_langfile:n}, but warns if the loading of +% the language file has failed. % \begin{syntax} -% \cs{@@_provide_dictionary_verbose:n} \Arg{language} +% \cs{@@_provide_langfile_verbose:n} \Arg{language} % \end{syntax} % \begin{macrocode} -\cs_new_protected:Npn \@@_provide_dictionary_verbose:n #1 +\cs_new_protected:Npn \@@_provide_langfile_verbose:n #1 { \group_begin: - \bool_set_true:N \l_@@_load_dict_verbose_bool - \@@_provide_dictionary:n {#1} + \bool_set_true:N \l_@@_load_langfile_verbose_bool + \@@_provide_langfile:n {#1} \group_end: } -\cs_generate_variant:Nn \@@_provide_dictionary_verbose:n { x } +\cs_generate_variant:Nn \@@_provide_langfile_verbose:n { x } % \end{macrocode} % \end{macro} % % % \begin{macro} % { -% \@@_provide_dict_type_transl:nn , -% \@@_provide_dict_default_transl:nn , +% \@@_provide_lang_opt_type:nn , +% \@@_provide_lang_opt_default:nn , % } % A couple of auxiliary functions for the of -% \texttt{{zref-clever/dictionary}} keys set in -% \cs{@@_provide_dictionary:n}. They respectively ``provide'' (i.e. set if +% \texttt{{zref-clever/langfile}} keys set in +% \cs{@@_provide_langfile:n}. They respectively ``provide'' (i.e. set if % it value does not exist, do nothing if it already does) ``type-specific'' -% and ``default'' translations. Both receive \meta{key} and -% \meta{translation} as arguments, but \cs{@@_provide_dict_type_transl:nn} +% and ``default'' language options. Both receive \meta{key} and +% \meta{value} as arguments, but \cs{@@_provide_lang_opt_type:nn} % relies on the current value of \cs{l_@@_setup_type_tl}, as set by the % \texttt{type} key. % \begin{syntax} -% \cs{@@_provide_dict_type_transl:nn} \Arg{key} \Arg{translation} -% \cs{@@_provide_dict_default_transl:nn} \Arg{key} \Arg{translation} +% \cs{@@_provide_lang_opt_type:nn} \Arg{key} \Arg{value} +% \cs{@@_provide_lang_opt_default:nn} \Arg{key} \Arg{value} % \end{syntax} % \begin{macrocode} -\cs_new_protected:Npn \@@_provide_dict_type_transl:nn #1#2 +\cs_new_protected:Npn \@@_provide_lang_opt_type:nn #1#2 { \exp_args:Nnx \prop_gput_if_new:cnn - { g_@@_dict_ \l_@@_dict_language_tl _prop } + { g_@@_lang_ \l_@@_base_language_tl _prop } { type- \l_@@_setup_type_tl - #1 } {#2} } -\cs_new_protected:Npn \@@_provide_dict_default_transl:nn #1#2 +\cs_generate_variant:Nn \@@_provide_lang_opt_type:nn { nV } +\cs_new_protected:Npn \@@_provide_lang_opt_default:nn #1#2 { \prop_gput_if_new:cnn - { g_@@_dict_ \l_@@_dict_language_tl _prop } + { g_@@_lang_ \l_@@_base_language_tl _prop } { default- #1 } {#2} } +\cs_generate_variant:Nn \@@_provide_lang_opt_default:nn { nV } % \end{macrocode} % \end{macro} % % -% The set of keys for \texttt{{zref-clever/dictionary}}, which is used to -% process the dictionary files in \cs{@@_provide_dictionary:n}. The no-op -% cases for each category have their messages sent to ``info''. These -% messages should not occur, as long as the dictionaries are well formed, but -% they're placed there nevertheless, and can be leveraged in regression tests. +% The set of keys for \texttt{{zref-clever/langfile}}, which is used to +% process the language files in \cs{@@_provide_langfile:n}. The no-op cases +% for each category have their messages sent to ``info''. These messages +% should not occur, as long as the language files are well formed, but they're +% placed there nevertheless, and can be leveraged in regression tests. % % \begin{macrocode} -\keys_define:nn { zref-clever / dictionary } +\keys_define:nn { zref-clever / langfile } { type .code:n = { @@ -1320,31 +1338,33 @@ { \tl_clear:N \l_@@_setup_type_tl } { \tl_set:Nn \l_@@_setup_type_tl {#1} } } , + case .code:n = { - \seq_if_empty:NTF \l_@@_dict_declension_seq + \seq_if_empty:NTF \l_@@_lang_declension_seq { \msg_info:nnxx { zref-clever } { language-no-decl-setup } - { \l_@@_dict_language_tl } {#1} + { \l_@@_base_language_tl } {#1} } { - \seq_if_in:NnTF \l_@@_dict_declension_seq {#1} - { \tl_set:Nn \l_@@_dict_decl_case_tl {#1} } + \seq_if_in:NnTF \l_@@_lang_declension_seq {#1} + { \tl_set:Nn \l_@@_lang_decl_case_tl {#1} } { \msg_info:nnxx { zref-clever } { unknown-decl-case } - {#1} { \l_@@_dict_language_tl } - \seq_get_left:NN \l_@@_dict_declension_seq - \l_@@_dict_decl_case_tl + {#1} { \l_@@_base_language_tl } + \seq_get_left:NN \l_@@_lang_declension_seq + \l_@@_lang_decl_case_tl } } } , case .value_required:n = true , + gender .code:n = { - \seq_if_empty:NTF \l_@@_dict_gender_seq + \seq_if_empty:NTF \l_@@_lang_gender_seq { \msg_info:nnxxx { zref-clever } { language-no-gender } - { \l_@@_dict_language_tl } { gender } {#1} + { \l_@@_base_language_tl } { gender } {#1} } { \tl_if_empty:NTF \l_@@_setup_type_tl @@ -1353,27 +1373,71 @@ { option-only-type-specific } { gender } } { - \seq_if_in:NnTF \l_@@_dict_gender_seq {#1} - { \@@_provide_dict_type_transl:nn { gender } {#1} } + \clist_clear:N \l_tmpa_clist + \clist_map_inline:nn {#1} + { + \seq_if_in:NnTF \l_@@_lang_gender_seq {##1} + { \clist_put_right:Nn \l_tmpa_clist {##1} } + { + \msg_info:nnxx { zref-clever } + { gender-not-declared } + { \l_@@_base_language_tl } {##1} + } + } + \clist_if_empty:NF \l_tmpa_clist { - \msg_info:nnxx { zref-clever } { gender-not-declared } - { \l_@@_dict_language_tl } {#1} + \exp_args:Nnx \@@_provide_lang_opt_type:nn + { gender } { \clist_use:Nn \l_tmpa_clist { , } } } } } } , gender .value_required:n = true , + + cap .choices:nn = + { true , false } + { + \tl_if_empty:NTF \l_@@_setup_type_tl + { + \@@_provide_lang_opt_default:nV + { cap } \l_keys_choice_tl + } + { + \@@_provide_lang_opt_type:nV + { cap } \l_keys_choice_tl + } + } , + cap .default:n = true , + nocap .meta:n = { cap = false } , + nocap .value_forbidden:n = true , + + abbrev .choices:nn = + { true , false } + { + \tl_if_empty:NTF \l_@@_setup_type_tl + { + \@@_provide_lang_opt_default:nV + { abbrev } \l_keys_choice_tl + } + { + \@@_provide_lang_opt_type:nV + { abbrev } \l_keys_choice_tl + } + } , + abbrev .default:n = true , + noabbrev .meta:n = { abbrev = false }, + noabbrev .value_forbidden:n = true , } \seq_map_inline:Nn \c_@@_ref_options_necessarily_not_type_specific_seq { - \keys_define:nn { zref-clever / dictionary } + \keys_define:nn { zref-clever / langfile } { #1 .value_required:n = true , #1 .code:n = { \tl_if_empty:NTF \l_@@_setup_type_tl - { \@@_provide_dict_default_transl:nn {#1} {##1} } + { \@@_provide_lang_opt_default:nn {#1} {##1} } { \msg_info:nnn { zref-clever } { option-not-type-specific } {#1} @@ -1384,21 +1448,21 @@ \seq_map_inline:Nn \c_@@_ref_options_possibly_type_specific_seq { - \keys_define:nn { zref-clever / dictionary } + \keys_define:nn { zref-clever / langfile } { #1 .value_required:n = true , #1 .code:n = { \tl_if_empty:NTF \l_@@_setup_type_tl - { \@@_provide_dict_default_transl:nn {#1} {##1} } - { \@@_provide_dict_type_transl:nn {#1} {##1} } + { \@@_provide_lang_opt_default:nn {#1} {##1} } + { \@@_provide_lang_opt_type:nn {#1} {##1} } } , } } \seq_map_inline:Nn \c_@@_ref_options_type_names_seq { - \keys_define:nn { zref-clever / dictionary } + \keys_define:nn { zref-clever / langfile } { #1 .value_required:n = true , #1 .code:n = @@ -1409,11 +1473,11 @@ { option-only-type-specific } {#1} } { - \tl_if_empty:NTF \l_@@_dict_decl_case_tl - { \@@_provide_dict_type_transl:nn {#1} {##1} } + \tl_if_empty:NTF \l_@@_lang_decl_case_tl + { \@@_provide_lang_opt_type:nn {#1} {##1} } { - \@@_provide_dict_type_transl:nn - { \l_@@_dict_decl_case_tl - #1 } {##1} + \@@_provide_lang_opt_type:nn + { \l_@@_lang_decl_case_tl - #1 } {##1} } } } , @@ -1425,22 +1489,22 @@ % % \subsubsection*{Fallback} % -% All ``strings'' queried with \cs{@@_get_ref_string:nN} -- in practice, those -% in either \cs{c_@@_ref_options_necessarily_not_type_specific_seq} or +% All ``strings'' queried with \cs{@@_get_ref_opt_typeset:nN} -- in practice, +% those in either \cs{c_@@_ref_options_necessarily_not_type_specific_seq} or % \cs{c_@@_ref_options_possibly_type_specific_seq} -- must have their values % set for ``fallback'', even if to empty ones, since this is what will be -% retrieved in the absence of a proper translation, which will be the case if -% \pkg{babel} or \pkg{polyglossia} is loaded and sets a language which -% \pkg{zref-clever} does not know. On the other hand, ``type names'' are not -% looked for in ``fallback'', since it is indeed impossible to provide any -% reasonable value for them for a ``specified but unknown language''. Also -% ``font'' options -- those in \cs{c_@@_ref_options_font_seq}, and queried -% with \cs{@@_get_ref_font:nN} -- do not need to be provided here, since the -% later function sets an empty value if the option is not found. +% retrieved in the absence of a proper language-specific option, which will be +% the case if \pkg{babel} or \pkg{polyglossia} is loaded and sets a language +% which \pkg{zref-clever} does not know. On the other hand, ``type names'' +% are not looked for in ``fallback'', since it is indeed impossible to provide +% any reasonable value for them for a ``specified but unknown language''. +% Also ``font'' options -- those in \cs{c_@@_ref_options_font_seq}, and +% queried with \cs{@@_get_ref_opt_font:nN} -- do not need to be provided here, +% since the later function sets an empty value if the option is not found. % % \begin{macrocode} -\prop_new:N \g_@@_fallback_dict_prop -\prop_gset_from_keyval:Nn \g_@@_fallback_dict_prop +\prop_new:N \g_@@_fallback_unknown_lang_prop +\prop_gset_from_keyval:Nn \g_@@_fallback_unknown_lang_prop { tpairsep = {,~} , tlistsep = {,~} , @@ -1451,33 +1515,33 @@ listsep = {,~} , lastsep = {,~} , rangesep = {\textendash} , - refpre = {} , - refpos = {} , + preref = {} , + postref = {} , } % \end{macrocode} % % % -% \subsubsection*{Get translations} +% \subsubsection*{Get language options} % -% \begin{macro}{\@@_get_type_transl:nnnNF} -% Get type-specific translation of \meta{key} for \meta{type} and +% \begin{macro}{\@@_get_lang_opt_type:nnnNF} +% Get type-specific language option of \meta{key} for \meta{type} and % \meta{language}, and store it in \meta{tl variable} if found. If not % found, leave the \meta{false code} on the stream, in which case the value % of \meta{tl variable} should not be relied upon. % \begin{syntax} -% \cs{@@_get_type_transl:nnnNF} \Arg{language} \Arg{type} \Arg{key} +% \cs{@@_get_lang_opt_type:nnnNF} \Arg{language} \Arg{type} \Arg{key} % ~~\meta{tl variable} \Arg{false code} % \end{syntax} % \begin{macrocode} \prg_new_protected_conditional:Npnn - \@@_get_type_transl:nnnN #1#2#3#4 { F } + \@@_get_lang_opt_type:nnnN #1#2#3#4 { F } { \prop_get:NnNTF \g_@@_languages_prop {#1} - \l_@@_dict_language_tl + \l_@@_base_language_tl { \prop_get:cnNTF - { g_@@_dict_ \l_@@_dict_language_tl _prop } + { g_@@_lang_ \l_@@_base_language_tl _prop } { type- #2 - #3 } #4 { \prg_return_true: } { \prg_return_false: } @@ -1485,29 +1549,29 @@ { \prg_return_false: } } \prg_generate_conditional_variant:Nnn - \@@_get_type_transl:nnnN { xxxN , xxnN } { F } + \@@_get_lang_opt_type:nnnN { xxxN , xxnN } { F } % \end{macrocode} % \end{macro} % % -% \begin{macro}{\@@_get_default_transl:nnNF} -% Get default translation of \meta{key} for \meta{language}, and store it in -% \meta{tl variable} if found. If not found, leave the \meta{false code} on -% the stream, in which case the value of \meta{tl variable} should not be -% relied upon. +% \begin{macro}{\@@_get_lang_opt_default:nnNF} +% Get default language option of \meta{key} for \meta{language}, and store +% it in \meta{tl variable} if found. If not found, leave the \meta{false +% code} on the stream, in which case the value of \meta{tl variable} should +% not be relied upon. % \begin{syntax} -% \cs{@@_get_default_transl:nnNF} \Arg{language} \Arg{key} +% \cs{@@_get_lang_opt_default:nnNF} \Arg{language} \Arg{key} % ~~\meta{tl variable} \Arg{false code} % \end{syntax} % \begin{macrocode} \prg_new_protected_conditional:Npnn - \@@_get_default_transl:nnN #1#2#3 { F } + \@@_get_lang_opt_default:nnN #1#2#3 { F } { \prop_get:NnNTF \g_@@_languages_prop {#1} - \l_@@_dict_language_tl + \l_@@_base_language_tl { \prop_get:cnNTF - { g_@@_dict_ \l_@@_dict_language_tl _prop } + { g_@@_lang_ \l_@@_base_language_tl _prop } { default- #2 } #3 { \prg_return_true: } { \prg_return_false: } @@ -1515,25 +1579,26 @@ { \prg_return_false: } } \prg_generate_conditional_variant:Nnn - \@@_get_default_transl:nnN { xnN } { F } + \@@_get_lang_opt_default:nnN { xnN } { F } % \end{macrocode} % \end{macro} % % -% \begin{macro}{\@@_get_fallback_transl:nNF} -% Get fallback translation of \meta{key}, and store it in \meta{tl variable} -% if found. If not found, leave the \meta{false code} on the stream, in -% which case the value of \meta{tl variable} should not be relied upon. +% \begin{macro}{\@@_get_fallback_unknown_lang_opt:nNF} +% Get fallback language option of \meta{key}, and store it in \meta{tl +% variable} if found. If not found, leave the \meta{false code} on the +% stream, in which case the value of \meta{tl variable} should not be relied +% upon. % \begin{syntax} -% \cs{@@_get_fallback_transl:nNF} \Arg{key} +% \cs{@@_get_fallback_unknown_lang_opt:nNF} \Arg{key} % ~~\meta{tl variable} \Arg{false code} % \end{syntax} % \begin{macrocode} % {<key>}<tl var to set> \prg_new_protected_conditional:Npnn - \@@_get_fallback_transl:nN #1#2 { F } + \@@_get_fallback_unknown_lang_opt:nN #1#2 { F } { - \prop_get:NnNTF \g_@@_fallback_dict_prop + \prop_get:NnNTF \g_@@_fallback_unknown_lang_prop { #1 } #2 { \prg_return_true: } { \prg_return_false: } @@ -1712,14 +1777,26 @@ % \subsubsection*{\opt{cap} and \opt{capfirst} options} % % \begin{macrocode} -\bool_new:N \l_@@_capitalize_bool \bool_new:N \l_@@_capitalize_first_bool \keys_define:nn { zref-clever / reference } { - cap .bool_set:N = \l_@@_capitalize_bool , - cap .initial:n = false , + cap .code:n = + { + \tl_if_empty:nTF {#1} + { \prop_remove:Nn \l_@@_ref_options_prop { cap } } + { + \bool_lazy_or:nnTF + { \str_if_eq_p:nn {#1} { true } } + { \str_if_eq_p:nn {#1} { false } } + { \prop_put:Nnn \l_@@_ref_options_prop { cap } {#1} } + { + \msg_warning:nnn { zref-clever } + { key-boolean-or-empty } {#1} + } + } + } , cap .default:n = true , - nocap .meta:n = { cap = false }, + nocap .meta:n = { cap = false } , nocap .value_forbidden:n = true , capfirst .bool_set:N = \l_@@_capitalize_first_bool , @@ -1732,12 +1809,24 @@ % \subsubsection*{\opt{abbrev} and \opt{noabbrevfirst} options} % % \begin{macrocode} -\bool_new:N \l_@@_abbrev_bool \bool_new:N \l_@@_noabbrev_first_bool \keys_define:nn { zref-clever / reference } { - abbrev .bool_set:N = \l_@@_abbrev_bool , - abbrev .initial:n = false , + abbrev .code:n = + { + \tl_if_empty:nTF {#1} + { \prop_remove:Nn \l_@@_ref_options_prop { abbrev } } + { + \bool_lazy_or:nnTF + { \str_if_eq_p:nn {#1} { true } } + { \str_if_eq_p:nn {#1} { false } } + { \prop_put:Nnn \l_@@_ref_options_prop { abbrev } {#1} } + { + \msg_warning:nnn { zref-clever } + { key-boolean-or-empty } {#1} + } + } + } , abbrev .default:n = true , noabbrev .meta:n = { abbrev = false }, noabbrev .value_forbidden:n = true , @@ -1871,8 +1960,8 @@ % executed. Finally, we set a third \texttt{begindocument} hook, at % \texttt{begindocument/before}, so that it runs after any options set in the % preamble. This hook redefines the \opt{lang} option for immediate execution -% in the document body, and ensures the \texttt{current} language's dictionary -% gets loaded, if it hadn't been already. +% in the document body, and ensures the \texttt{current} language's language +% file gets loaded, if it hadn't been already. % % For the \pkg{babel} and \pkg{polyglossia} variables which store the % ``current'' and ``main'' languages, see @@ -1911,9 +2000,9 @@ % Provide default value for \cs{l_@@_ref_language_tl} corresponding to option % \opt{current}, but do so outside of the \pkg{l3keys} machinery (that is, % instead of using \texttt{.initial:n}), so that we are able to distinguish -% when the user actually gave the option, in which case the dictionary loading -% is done verbosely, from when we are setting the default value (here), in -% which case the dictionary loading is done silently. +% when the user actually gave the option, in which case the language file +% loading is done verbosely, from when we are setting the default value +% (here), in which case the language file loading is done silently. % \begin{macrocode} \tl_set:Nn \l_@@_ref_language_tl { \l_@@_current_language_tl } @@ -1934,7 +2023,7 @@ { \tl_set:Nn \l_@@_ref_language_tl { \l_@@_current_language_tl } - \@@_provide_dictionary_verbose:x + \@@_provide_langfile_verbose:x { \l_@@_ref_language_tl } } @@ -1942,7 +2031,7 @@ { \tl_set:Nn \l_@@_ref_language_tl { \l_@@_main_language_tl } - \@@_provide_dictionary_verbose:x + \@@_provide_langfile_verbose:x { \l_@@_ref_language_tl } } } @@ -1955,7 +2044,7 @@ \tl_set:Nn \l_@@_ref_language_tl { \l_@@_current_language_tl } } - \@@_provide_dictionary_verbose:x + \@@_provide_langfile_verbose:x { \l_@@_ref_language_tl } } } @@ -1975,12 +2064,12 @@ % language is already loaded, otherwise, ensure the default one % (\texttt{current}) gets loaded early, but not verbosely. % \begin{macrocode} - \@@_provide_dictionary:x { \l_@@_ref_language_tl } + \@@_provide_langfile:x { \l_@@_ref_language_tl } % \end{macrocode} % Redefinition of the \texttt{lang} key option for the document body. Also, -% drop the verbose dictionary loading in the document body, as it can become -% intrusive depending on the use case, and does not provide much ``juice'' -% anyway: in \cs{zcref} missing names warnings will already ensue. +% drop the verbose language file loading in the document body, as it can +% become intrusive depending on the use case, and does not provide much +% ``juice'' anyway: in \cs{zcref} missing names warnings will already ensue. % \begin{macrocode} \keys_define:nn { zref-clever / reference } { @@ -1992,7 +2081,7 @@ { \tl_set:Nn \l_@@_ref_language_tl { \l_@@_current_language_tl } - \@@_provide_dictionary:x + \@@_provide_langfile:x { \l_@@_ref_language_tl } } @@ -2000,7 +2089,7 @@ { \tl_set:Nn \l_@@_ref_language_tl { \l_@@_main_language_tl } - \@@_provide_dictionary:x + \@@_provide_langfile:x { \l_@@_ref_language_tl } } } @@ -2013,7 +2102,7 @@ \tl_set:Nn \l_@@_ref_language_tl { \l_@@_current_language_tl } } - \@@_provide_dictionary:x + \@@_provide_langfile:x { \l_@@_ref_language_tl } } } , @@ -2480,8 +2569,8 @@ % ``not necessarily type-specific'' options are pertinent here. However, they % \emph{may} either be type-specific or language-specific, and thus must be % stored in a property list, \cs{l_@@_ref_options_prop}, in order to be -% retrieved from the option \emph{name} by \cs{@@_get_ref_string:nN} and -% \cs{@@_get_ref_font:nN} according to context and precedence rules. +% retrieved from the option \emph{name} by \cs{@@_get_ref_opt_typeset:nN} and +% \cs{@@_get_ref_opt_font:nN} according to context and precedence rules. % % The keys are set so that any value, including an empty one, is added to % \cs{l_@@_ref_options_prop}, while a key with \emph{no value} removes the @@ -2505,6 +2594,21 @@ } , } } +\keys_define:nn { zref-clever / reference } + { + refpre .code:n = + { + % NOTE Option deprecated in 2022-01-10 for v0.1.2-alpha. + \msg_warning:nnnn { zref-clever }{ option-deprecated } + { refpre } { preref } + } , + refpos .code:n = + { + % NOTE Option deprecated in 2022-01-10 for v0.1.2-alpha. + \msg_warning:nnnn { zref-clever }{ option-deprecated } + { refpos } { postref } + } , + } % \end{macrocode} % % @@ -2573,13 +2677,12 @@ % % \cs{zcRefTypeSetup} is the main user interface for ``type-specific'' % reference formatting. Settings done by this command have a higher -% precedence than any translation, hence they override any language-specific -% setting, either done at \cs{zcLanguageSetup} or by the package's -% dictionaries. On the other hand, they have a lower precedence than non -% type-specific general options. The \meta{options} should be given in the -% usual \texttt{key=val} format. The \meta{type} does not need to pre-exist, -% the property list variable to store the properties for the type gets created -% if need be. +% precedence than any language-specific setting, either done at +% \cs{zcLanguageSetup} or by the package's language files. On the other hand, +% they have a lower precedence than non type-specific general options. The +% \meta{options} should be given in the usual \texttt{key=val} format. The +% \meta{type} does not need to pre-exist, the property list variable to store +% the properties for the type gets created if need be. % % \begin{macro}[int]{\zcRefTypeSetup} % \begin{syntax} @@ -2599,14 +2702,14 @@ % % Inside \cs{zcRefTypeSetup} any of the options \emph{can} receive empty % values, and those values, if they exist in the property list, will override -% translations, regardless of their emptiness. In principle, we could live -% with the situation of, once a setting has been made in +% language-specific options, regardless of their emptiness. In principle, we +% could live with the situation of, once a setting has been made in % \cs{l_@@_type_<type>_options_prop} or in \cs{l_@@_ref_options_prop} it stays % there forever, and can only be overridden by a new value at the same % precedence level or a higher one. But it would be nice if an user can % ``unset'' an option at either of those scopes to go back to the lower -% precedence level of the translations at any given point. So both in -% \cs{zcRefTypeSetup} and in setting reference options (see +% precedence level of the language-specific options at any given point. So +% both in \cs{zcRefTypeSetup} and in setting reference options (see % \zcref{sec:reference-options}), we leverage the distinction of an ``empty % valued key'' (\texttt{key=} or \texttt{key=\{\}}) from a ``key with no % value'' (\texttt{key}). This distinction is captured internally by the @@ -2618,6 +2721,79 @@ % \url{https://tex.stackexchange.com/q/614690} and % \url{https://github.com/latex3/latex3/pull/988}. % +% +% \begin{macrocode} +\keys_define:nn { zref-clever / typesetup } + { + cap .code:n = + { + \tl_if_empty:nTF {#1} + { + \prop_remove:cn + { + l_@@_type_ + \l_@@_setup_type_tl _options_prop + } + { cap } + } + { + \bool_lazy_or:nnTF + { \str_if_eq_p:nn {#1} { true } } + { \str_if_eq_p:nn {#1} { false } } + { + \prop_put:cnn + { + l_@@_type_ + \l_@@_setup_type_tl _options_prop + } + { cap } {#1} + } + { + \msg_warning:nnn { zref-clever } + { key-boolean-or-empty } {#1} + } + } + } , + cap .default:n = true , + nocap .meta:n = { cap = false } , + nocap .value_forbidden:n = true , + + abbrev .code:n = + { + \tl_if_empty:nTF {#1} + { + \prop_remove:cn + { + l_@@_type_ + \l_@@_setup_type_tl _options_prop + } + { abbrev } + } + { + \bool_lazy_or:nnTF + { \str_if_eq_p:nn {#1} { true } } + { \str_if_eq_p:nn {#1} { false } } + { + \prop_put:cnn + { + l_@@_type_ + \l_@@_setup_type_tl _options_prop + } + { abbrev } {#1} + } + { + \msg_warning:nnn { zref-clever } + { key-boolean-or-empty } {#1} + } + } + } , + abbrev .default:n = true , + noabbrev .meta:n = { abbrev = false }, + noabbrev .value_forbidden:n = true , + } +% \end{macrocode} +% +% % \begin{macrocode} \seq_map_inline:Nn \c_@@_ref_options_necessarily_not_type_specific_seq @@ -2663,6 +2839,21 @@ } , } } +\keys_define:nn { zref-clever / typesetup } + { + refpre .code:n = + { + % NOTE Option deprecated in 2022-01-10 for v0.1.2-alpha. + \msg_warning:nnnn { zref-clever }{ option-deprecated } + { refpre } { preref } + } , + refpos .code:n = + { + % NOTE Option deprecated in 2022-01-10 for v0.1.2-alpha. + \msg_warning:nnnn { zref-clever }{ option-deprecated } + { refpos } { postref } + } , + } % \end{macrocode} % % @@ -2674,9 +2865,9 @@ % between the two cases is captured by the \texttt{type} key, which works as a % sort of a ``switch''. Inside the \meta{options} argument of % \cs{zcLanguageSetup}, any options made before the first \texttt{type} key -% declare ``default'' (non type-specific) translations. When the +% declare ``default'' (non type-specific) language options. When the % \texttt{type} key is given with a value, the options following it will set -% ``type-specific'' translations for that type. The current type can be +% ``type-specific'' language options for that type. The current type can be % switched off by an empty \texttt{type} key. \cs{zcLanguageSetup} is % preamble only. % @@ -2689,32 +2880,32 @@ { \group_begin: \prop_get:NnNTF \g_@@_languages_prop {#1} - \l_@@_dict_language_tl + \l_@@_base_language_tl { \tl_clear:N \l_@@_setup_type_tl \exp_args:NNx \seq_set_from_clist:Nn - \l_@@_dict_declension_seq + \l_@@_lang_declension_seq { \prop_item:cn { - g_@@_dict_ - \l_@@_dict_language_tl _prop + g_@@_lang_ + \l_@@_base_language_tl _prop } { declension } } - \seq_if_empty:NTF \l_@@_dict_declension_seq - { \tl_clear:N \l_@@_dict_decl_case_tl } + \seq_if_empty:NTF \l_@@_lang_declension_seq + { \tl_clear:N \l_@@_lang_decl_case_tl } { - \seq_get_left:NN \l_@@_dict_declension_seq - \l_@@_dict_decl_case_tl + \seq_get_left:NN \l_@@_lang_declension_seq + \l_@@_lang_decl_case_tl } \exp_args:NNx \seq_set_from_clist:Nn - \l_@@_dict_gender_seq + \l_@@_lang_gender_seq { \prop_item:cn { - g_@@_dict_ - \l_@@_dict_language_tl _prop + g_@@_lang_ + \l_@@_base_language_tl _prop } { gender } } @@ -2730,38 +2921,39 @@ % % \begin{macro} % { -% \@@_declare_type_transl:nnnn , -% \@@_declare_default_transl:nnn , +% \@@_declare_lang_opt_type:nnnn , +% \@@_declare_lang_opt_default:nnn , % } % A couple of auxiliary functions for the of -% \texttt{{zref-clever/translation}} keys set in \cs{zcLanguageSetup}. They +% \texttt{{zref-clever/langsetup}} keys set in \cs{zcLanguageSetup}. They % respectively declare (unconditionally set) ``type-specific'' and -% ``default'' translations. +% ``default'' language-specific options. % \begin{syntax} -% \cs{@@_declare_type_transl:nnnn} \Arg{language} \Arg{type} -% ~~\Arg{key} \Arg{translation} -% \cs{@@_declare_default_transl:nnn} \Arg{language} -% ~~\Arg{key} \Arg{translation} +% \cs{@@_declare_lang_opt_type:nnnn} \Arg{language} \Arg{type} +% ~~\Arg{key} \Arg{value} +% \cs{@@_declare_lang_opt_default:nnn} \Arg{language} +% ~~\Arg{key} \Arg{value} % \end{syntax} % \begin{macrocode} -\cs_new_protected:Npn \@@_declare_type_transl:nnnn #1#2#3#4 +\cs_new_protected:Npn \@@_declare_lang_opt_type:nnnn #1#2#3#4 { - \prop_gput:cnn { g_@@_dict_ #1 _prop } + \prop_gput:cnn { g_@@_lang_ #1 _prop } { type- #2 - #3 } {#4} } -\cs_generate_variant:Nn \@@_declare_type_transl:nnnn { VVnn , VVxn } -\cs_new_protected:Npn \@@_declare_default_transl:nnn #1#2#3 +\cs_generate_variant:Nn + \@@_declare_lang_opt_type:nnnn { VVnn , VVxn , VVnx , VVnV } +\cs_new_protected:Npn \@@_declare_lang_opt_default:nnn #1#2#3 { - \prop_gput:cnn { g_@@_dict_ #1 _prop } + \prop_gput:cnn { g_@@_lang_ #1 _prop } { default- #2 } {#3} } -\cs_generate_variant:Nn \@@_declare_default_transl:nnn { Vnn } +\cs_generate_variant:Nn \@@_declare_lang_opt_default:nnn { Vnn , VnV } % \end{macrocode} % \end{macro} % % -% The set of keys for \texttt{{zref-clever/langsetup}}, which is used to -% set language-specific translations in \cs{zcLanguageSetup}. +% The set of keys for \texttt{{zref-clever/langsetup}}, which is used to set +% language-specific options in \cs{zcLanguageSetup}. % % \begin{macrocode} \keys_define:nn { zref-clever / langsetup } @@ -2772,31 +2964,33 @@ { \tl_clear:N \l_@@_setup_type_tl } { \tl_set:Nn \l_@@_setup_type_tl {#1} } } , + case .code:n = { - \seq_if_empty:NTF \l_@@_dict_declension_seq + \seq_if_empty:NTF \l_@@_lang_declension_seq { \msg_warning:nnxx { zref-clever } { language-no-decl-setup } - { \l_@@_dict_language_tl } {#1} + { \l_@@_base_language_tl } {#1} } { - \seq_if_in:NnTF \l_@@_dict_declension_seq {#1} - { \tl_set:Nn \l_@@_dict_decl_case_tl {#1} } + \seq_if_in:NnTF \l_@@_lang_declension_seq {#1} + { \tl_set:Nn \l_@@_lang_decl_case_tl {#1} } { \msg_warning:nnxx { zref-clever } { unknown-decl-case } - {#1} { \l_@@_dict_language_tl } - \seq_get_left:NN \l_@@_dict_declension_seq - \l_@@_dict_decl_case_tl + {#1} { \l_@@_base_language_tl } + \seq_get_left:NN \l_@@_lang_declension_seq + \l_@@_lang_decl_case_tl } } } , case .value_required:n = true , + gender .code:n = { - \seq_if_empty:NTF \l_@@_dict_gender_seq + \seq_if_empty:NTF \l_@@_lang_gender_seq { \msg_warning:nnxxx { zref-clever } { language-no-gender } - { \l_@@_dict_language_tl } { gender } {#1} + { \l_@@_base_language_tl } { gender } {#1} } { \tl_if_empty:NTF \l_@@_setup_type_tl @@ -2805,21 +2999,68 @@ { option-only-type-specific } { gender } } { - \seq_if_in:NnTF \l_@@_dict_gender_seq {#1} + \clist_clear:N \l_tmpa_clist + \clist_map_inline:nn {#1} { - \@@_declare_type_transl:VVnn - \l_@@_dict_language_tl - \l_@@_setup_type_tl - { gender } {#1} + \seq_if_in:NnTF \l_@@_lang_gender_seq {##1} + { \clist_put_right:Nn \l_tmpa_clist {##1} } + { + \msg_warning:nnxx { zref-clever } + { gender-not-declared } + { \l_@@_base_language_tl } {##1} + } } + \clist_if_empty:NF \l_tmpa_clist { - \msg_warning:nnxx { zref-clever } { gender-not-declared } - { \l_@@_dict_language_tl } {#1} + \@@_declare_lang_opt_type:VVnx + \l_@@_base_language_tl + \l_@@_setup_type_tl + { gender } { \clist_use:Nn \l_tmpa_clist { , } } } } } } , gender .value_required:n = true , + + cap .choices:nn = + { true , false } + { + \tl_if_empty:NTF \l_@@_setup_type_tl + { + \@@_declare_lang_opt_default:VnV + \l_@@_base_language_tl + { cap } \l_keys_choice_tl + } + { + \@@_declare_lang_opt_type:VVnV + \l_@@_base_language_tl + \l_@@_setup_type_tl + { cap } \l_keys_choice_tl + } + } , + cap .default:n = true , + nocap .meta:n = { cap = false } , + nocap .value_forbidden:n = true , + + abbrev .choices:nn = + { true , false } + { + \tl_if_empty:NTF \l_@@_setup_type_tl + { + \@@_declare_lang_opt_default:VnV + \l_@@_base_language_tl + { abbrev } \l_keys_choice_tl + } + { + \@@_declare_lang_opt_type:VVnV + \l_@@_base_language_tl + \l_@@_setup_type_tl + { abbrev } \l_keys_choice_tl + } + } , + abbrev .default:n = true , + noabbrev .meta:n = { abbrev = false }, + noabbrev .value_forbidden:n = true , } \seq_map_inline:Nn \c_@@_ref_options_necessarily_not_type_specific_seq @@ -2831,8 +3072,8 @@ { \tl_if_empty:NTF \l_@@_setup_type_tl { - \@@_declare_default_transl:Vnn - \l_@@_dict_language_tl + \@@_declare_lang_opt_default:Vnn + \l_@@_base_language_tl {#1} {##1} } { @@ -2852,19 +3093,34 @@ { \tl_if_empty:NTF \l_@@_setup_type_tl { - \@@_declare_default_transl:Vnn - \l_@@_dict_language_tl + \@@_declare_lang_opt_default:Vnn + \l_@@_base_language_tl {#1} {##1} } { - \@@_declare_type_transl:VVnn - \l_@@_dict_language_tl + \@@_declare_lang_opt_type:VVnn + \l_@@_base_language_tl \l_@@_setup_type_tl {#1} {##1} } } , } } +\keys_define:nn { zref-clever / langsetup } + { + refpre .code:n = + { + % NOTE Option deprecated in 2022-01-10 for v0.1.2-alpha. + \msg_warning:nnnn { zref-clever }{ option-deprecated } + { refpre } { preref } + } , + refpos .code:n = + { + % NOTE Option deprecated in 2022-01-10 for v0.1.2-alpha. + \msg_warning:nnnn { zref-clever }{ option-deprecated } + { refpos } { postref } + } , + } \seq_map_inline:Nn \c_@@_ref_options_type_names_seq { @@ -2879,18 +3135,18 @@ { option-only-type-specific } {#1} } { - \tl_if_empty:NTF \l_@@_dict_decl_case_tl + \tl_if_empty:NTF \l_@@_lang_decl_case_tl { - \@@_declare_type_transl:VVnn - \l_@@_dict_language_tl + \@@_declare_lang_opt_type:VVnn + \l_@@_base_language_tl \l_@@_setup_type_tl {#1} {##1} } { - \@@_declare_type_transl:VVxn - \l_@@_dict_language_tl + \@@_declare_lang_opt_type:VVxn + \l_@@_base_language_tl \l_@@_setup_type_tl - { \l_@@_dict_decl_case_tl - #1 } {##1} + { \l_@@_lang_decl_case_tl - #1 } {##1} } } } , @@ -2938,13 +3194,13 @@ \seq_set_from_clist:Nn \l_@@_zcref_labels_seq {#1} \bool_set:Nn \l_@@_link_star_bool {#2} % \end{macrocode} -% Ensure dictionary for reference language is loaded, if available. We cannot -% rely on \cs{keys_set:nn} for the task, since if the \opt{lang} option is set -% for \texttt{current}, the actual language may have changed outside our -% control. \cs{@@_provide_dictionary:x} does nothing if the dictionary is -% already loaded. +% Ensure language file for reference language is loaded, if available. We +% cannot rely on \cs{keys_set:nn} for the task, since if the \opt{lang} option +% is set for \texttt{current}, the actual language may have changed outside +% our control. \cs{@@_provide_langfile:x} does nothing if the language file +% is already loaded. % \begin{macrocode} - \@@_provide_dictionary:x { \l_@@_ref_language_tl } + \@@_provide_langfile:x { \l_@@_ref_language_tl } % \end{macrocode} % Process \cs{zcDeclareLanguage} options. % \begin{macrocode} @@ -2976,7 +3232,7 @@ % \begin{macrocode} \tl_if_empty:NF \l_@@_zcref_note_tl { - \@@_get_ref_string:nN { notesep } \l_tmpa_tl + \@@_get_ref_opt_typeset:nN { notesep } \l_tmpa_tl \l_tmpa_tl \l_@@_zcref_note_tl } @@ -3175,7 +3431,7 @@ % \begin{macrocode} \cs_new_protected:Npn \@@_label_type_put_new_right:n #1 { - \@@_def_extract:Nnnn + \@@_extract_default:Nnnn \l_@@_label_type_a_tl {#1} { zc@type } { \c_empty_tl } \seq_if_in:NVF \l_@@_label_types_seq \l_@@_label_type_a_tl @@ -3201,9 +3457,9 @@ % \begin{macrocode} \cs_new_protected:Npn \@@_sort_default:nn #1#2 { - \@@_def_extract:Nnnn + \@@_extract_default:Nnnn \l_@@_label_type_a_tl {#1} { zc@type } { zc@missingtype } - \@@_def_extract:Nnnn + \@@_extract_default:Nnnn \l_@@_label_type_b_tl {#2} { zc@type } { zc@missingtype } \tl_if_eq:NNTF @@ -3223,15 +3479,15 @@ % \begin{macrocode} \cs_new_protected:Npn \@@_sort_default_same_type:nn #1#2 { - \@@_def_extract:Nnnn \l_@@_label_enclval_a_tl + \@@_extract_default:Nnnn \l_@@_label_enclval_a_tl {#1} { zc@enclval } { \c_empty_tl } \tl_reverse:N \l_@@_label_enclval_a_tl - \@@_def_extract:Nnnn \l_@@_label_enclval_b_tl + \@@_extract_default:Nnnn \l_@@_label_enclval_b_tl {#2} { zc@enclval } { \c_empty_tl } \tl_reverse:N \l_@@_label_enclval_b_tl - \@@_def_extract:Nnnn \l_@@_label_extdoc_a_tl + \@@_extract_default:Nnnn \l_@@_label_extdoc_a_tl {#1} { externaldocument } { \c_empty_tl } - \@@_def_extract:Nnnn \l_@@_label_extdoc_b_tl + \@@_extract_default:Nnnn \l_@@_label_extdoc_b_tl {#2} { externaldocument } { \c_empty_tl } \bool_set_false:N \l_@@_sort_decided_bool @@ -3638,13 +3894,15 @@ % \l_@@_listsep_tl , % \l_@@_lastsep_tl , % \l_@@_rangesep_tl , -% \l_@@_refpre_tl , -% \l_@@_refpos_tl , +% \l_@@_preref_tl , +% \l_@@_postref_tl , % \l_@@_namefont_tl , % \l_@@_reffont_tl , +% \l_@@_capitalize_bool , +% \l_@@_abbrev_bool , % } -% Auxiliary variables for \cs{@@_typeset_refs:} separators, refpre/pos and -% font options. +% Auxiliary variables for \cs{@@_typeset_refs:} separators, pre-/postref and +% font and other options. % \begin{macrocode} \tl_new:N \l_@@_tpairsep_tl \tl_new:N \l_@@_tlistsep_tl @@ -3654,10 +3912,12 @@ \tl_new:N \l_@@_listsep_tl \tl_new:N \l_@@_lastsep_tl \tl_new:N \l_@@_rangesep_tl -\tl_new:N \l_@@_refpre_tl -\tl_new:N \l_@@_refpos_tl +\tl_new:N \l_@@_preref_tl +\tl_new:N \l_@@_postref_tl \tl_new:N \l_@@_namefont_tl \tl_new:N \l_@@_reffont_tl +\bool_new:N \l_@@_capitalize_bool +\bool_new:N \l_@@_abbrev_bool % \end{macrocode} % \end{macro} % @@ -3692,11 +3952,11 @@ \int_zero:N \l_@@_range_same_count_int % Get type block options (not type-specific). - \@@_get_ref_string:nN { tpairsep } + \@@_get_ref_opt_typeset:nN { tpairsep } \l_@@_tpairsep_tl - \@@_get_ref_string:nN { tlistsep } + \@@_get_ref_opt_typeset:nN { tlistsep } \l_@@_tlistsep_tl - \@@_get_ref_string:nN { tlastsep } + \@@_get_ref_opt_typeset:nN { tlastsep } \l_@@_tlastsep_tl % Process label stack. @@ -3721,9 +3981,11 @@ \tl_set:Nn \l_@@_label_type_b_tl { page } } { - \@@_def_extract:NVnn \l_@@_label_type_a_tl + \@@_extract_default:NVnn + \l_@@_label_type_a_tl \l_@@_label_a_tl { zc@type } { zc@missingtype } - \@@_def_extract:NVnn \l_@@_label_type_b_tl + \@@_extract_default:NVnn + \l_@@_label_type_b_tl \l_@@_label_b_tl { zc@type } { zc@missingtype } } @@ -3777,28 +4039,32 @@ } } - % Get type-specific separators, refpre/pos and font options, once per - % type. + % Get type-specific separators, pre-/postref font and other options, + % once per type. \int_compare:nNnT { \l_@@_label_count_int } = { 0 } { - \@@_get_ref_string:nN { namesep } + \@@_get_ref_opt_typeset:nN { namesep } \l_@@_namesep_tl - \@@_get_ref_string:nN { pairsep } + \@@_get_ref_opt_typeset:nN { pairsep } \l_@@_pairsep_tl - \@@_get_ref_string:nN { listsep } + \@@_get_ref_opt_typeset:nN { listsep } \l_@@_listsep_tl - \@@_get_ref_string:nN { lastsep } + \@@_get_ref_opt_typeset:nN { lastsep } \l_@@_lastsep_tl - \@@_get_ref_string:nN { rangesep } + \@@_get_ref_opt_typeset:nN { rangesep } \l_@@_rangesep_tl - \@@_get_ref_string:nN { refpre } - \l_@@_refpre_tl - \@@_get_ref_string:nN { refpos } - \l_@@_refpos_tl - \@@_get_ref_font:nN { namefont } + \@@_get_ref_opt_typeset:nN { preref } + \l_@@_preref_tl + \@@_get_ref_opt_typeset:nN { postref } + \l_@@_postref_tl + \@@_get_ref_opt_font:nN { namefont } \l_@@_namefont_tl - \@@_get_ref_font:nN { reffont } + \@@_get_ref_opt_font:nN { reffont } \l_@@_reffont_tl + \@@_get_ref_opt_bool:nnN { cap } { false } + \l_@@_capitalize_bool + \@@_get_ref_opt_bool:nnN { abbrev } { false } + \l_@@_abbrev_bool } % Here we send this to a couple of auxiliary functions. @@ -4348,33 +4614,33 @@ } { \bool_if:NF \l_@@_preposinlink_bool - { \exp_not:V \l_@@_refpre_tl } + { \exp_not:V \l_@@_preref_tl } % It's two `@s', but escaped for DocStrip. \exp_not:N \hyper@@@@link { \@@_extract_url_unexp:n {#1} } { \@@_extract_unexp:nnn {#1} { anchor } { } } { \bool_if:NT \l_@@_preposinlink_bool - { \exp_not:V \l_@@_refpre_tl } + { \exp_not:V \l_@@_preref_tl } \exp_not:N \group_begin: \exp_not:V \l_@@_reffont_tl \@@_extract_unexp:nvn {#1} { l_@@_ref_property_tl } { } \exp_not:N \group_end: \bool_if:NT \l_@@_preposinlink_bool - { \exp_not:V \l_@@_refpos_tl } + { \exp_not:V \l_@@_postref_tl } } \bool_if:NF \l_@@_preposinlink_bool - { \exp_not:V \l_@@_refpos_tl } + { \exp_not:V \l_@@_postref_tl } } { - \exp_not:V \l_@@_refpre_tl + \exp_not:V \l_@@_preref_tl \exp_not:N \group_begin: \exp_not:V \l_@@_reffont_tl \@@_extract_unexp:nvn {#1} { l_@@_ref_property_tl } { } \exp_not:N \group_end: - \exp_not:V \l_@@_refpos_tl + \exp_not:V \l_@@_postref_tl } } { \@@_ref_default: } @@ -4421,7 +4687,7 @@ \exp_not:V \l_@@_type_name_tl \exp_not:N \group_end: \exp_not:V \l_@@_namesep_tl - \exp_not:V \l_@@_refpre_tl + \exp_not:V \l_@@_preref_tl \exp_not:N \group_begin: \exp_not:V \l_@@_reffont_tl \@@_extract_unexp:Vvn @@ -4429,10 +4695,10 @@ { l_@@_ref_property_tl } { } \exp_not:N \group_end: \bool_if:NT \l_@@_preposinlink_bool - { \exp_not:V \l_@@_refpos_tl } + { \exp_not:V \l_@@_postref_tl } } \bool_if:NF \l_@@_preposinlink_bool - { \exp_not:V \l_@@_refpos_tl } + { \exp_not:V \l_@@_postref_tl } } { \exp_not:N \group_begin: @@ -4467,7 +4733,7 @@ } { \bool_if:NF \l_@@_preposinlink_bool - { \exp_not:V \l_@@_refpre_tl } + { \exp_not:V \l_@@_preref_tl } % It's two '@s', but escaped for DocStrip. \exp_not:N \hyper@@@@link { @@ -4480,7 +4746,7 @@ } { \bool_if:NT \l_@@_preposinlink_bool - { \exp_not:V \l_@@_refpre_tl } + { \exp_not:V \l_@@_preref_tl } \exp_not:N \group_begin: \exp_not:V \l_@@_reffont_tl \@@_extract_unexp:Vvn @@ -4488,20 +4754,20 @@ { l_@@_ref_property_tl } { } \exp_not:N \group_end: \bool_if:NT \l_@@_preposinlink_bool - { \exp_not:V \l_@@_refpos_tl } + { \exp_not:V \l_@@_postref_tl } } \bool_if:NF \l_@@_preposinlink_bool - { \exp_not:V \l_@@_refpos_tl } + { \exp_not:V \l_@@_postref_tl } } { - \exp_not:V \l_@@_refpre_tl + \exp_not:V \l_@@_preref_tl \exp_not:N \group_begin: \exp_not:V \l_@@_reffont_tl \@@_extract_unexp:Vvn \l_@@_type_first_label_tl { l_@@_ref_property_tl } { } \exp_not:N \group_end: - \exp_not:V \l_@@_refpos_tl + \exp_not:V \l_@@_postref_tl } } { \@@_ref_default: } @@ -4594,15 +4860,17 @@ { \l_@@_nudge_gender_bool } { ! \tl_if_empty_p:N \l_@@_ref_gender_tl } { - \@@_get_type_transl:xxnNF + \@@_get_lang_opt_type:xxnNF { \l_@@_ref_language_tl } { \l_@@_type_first_label_type_tl } { gender } \l_@@_type_name_gender_tl { \tl_clear:N \l_@@_type_name_gender_tl } - \tl_if_eq:NNF - \l_@@_ref_gender_tl + \clist_set:NV \l_tmpa_clist \l_@@_type_name_gender_tl + \clist_if_in:NVF + \l_tmpa_clist + \l_@@_ref_gender_tl { \tl_if_empty:NTF \l_@@_type_name_gender_tl { @@ -4640,7 +4908,7 @@ \tl_put_left:NV \l_@@_name_format_tl \l_@@_ref_decl_case_tl } - \@@_get_type_transl:xxxNF + \@@_get_lang_opt_type:xxxNF { \l_@@_ref_language_tl } { \l_@@_type_first_label_type_tl } { \l_@@_name_format_tl } @@ -4682,13 +4950,13 @@ \l_@@_name_format_fallback_tl \l_@@_ref_decl_case_tl } - \@@_get_type_transl:xxxNF + \@@_get_lang_opt_type:xxxNF { \l_@@_ref_language_tl } { \l_@@_type_first_label_type_tl } { \l_@@_name_format_tl } \l_@@_type_name_tl { - \@@_get_type_transl:xxxNF + \@@_get_lang_opt_type:xxxNF { \l_@@_ref_language_tl } { \l_@@_type_first_label_type_tl } { \l_@@_name_format_fallback_tl } @@ -4776,9 +5044,9 @@ % \begin{macrocode} \cs_new_protected:Npn \@@_labels_in_sequence:nn #1#2 { - \@@_def_extract:Nnnn \l_@@_label_extdoc_a_tl + \@@_extract_default:Nnnn \l_@@_label_extdoc_a_tl {#1} { externaldocument } { \c_empty_tl } - \@@_def_extract:Nnnn \l_@@_label_extdoc_b_tl + \@@_extract_default:Nnnn \l_@@_label_extdoc_b_tl {#2} { externaldocument } { \c_empty_tl } \tl_if_eq:NNT @@ -4855,27 +5123,28 @@ % % % -% Finally, a couple of functions for retrieving options values, according to -% the relevant precedence rules. They both receive an \meta{option} as -% argument, and store the retrieved value in \meta{tl variable}. Though these -% are mostly general functions (for a change\dots{}), they are not completely -% so, they rely on the current state of \cs{l_@@_label_type_a_tl}, as set -% during the processing of the label stack. This could be easily generalized, -% of course, but I don't think it is worth it, \cs{l_@@_label_type_a_tl} is -% indeed what we want in all practical cases. The difference between -% \cs{@@_get_ref_string:nN} and \cs{@@_get_ref_font:nN} is the kind of option -% each should be used for. \cs{@@_get_ref_string:nN} is meant for the general -% options, and attempts to find values for them in all precedence levels (four -% plus ``fallback''). \cs{@@_get_ref_font:nN} is intended for ``font'' +% Finally, some functions for retrieving reference options values, according +% to the relevant precedence rules. They both receive an \meta{option} as +% argument, and store the retrieved value in an appropriate. Though these are +% mostly general functions (for a change\dots{}), they are not completely so, +% they rely on the current state of \cs{l_@@_label_type_a_tl}, as set during +% the processing of the label stack. This could be easily generalized, of +% course, but I don't think it is worth it, \cs{l_@@_label_type_a_tl} is +% indeed what we want in all practical cases. The difference between each of +% these functions is the kind of option each should be used for. +% \cs{@@_get_ref_opt_typeset:nN} is meant for the general options, and +% attempts to find values for them in all precedence levels (four plus +% ``fallback''). \cs{@@_get_ref_opt_font:nN} is intended for ``font'' % options, which cannot be ``language-specific'', thus for these we just -% search general options and type options. +% search general options and type options. \cs{@@_get_ref_opt_bool:nN} is +% intended for boolean options. % -% \begin{macro}{\@@_get_ref_string:nN} +% \begin{macro}{\@@_get_ref_opt_typeset:nN} % \begin{syntax} -% \cs{@@_get_ref_string:nN} \Arg{option} \Arg{tl variable} +% \cs{@@_get_ref_opt_typeset:nN} \Arg{option} \Arg{tl variable} % \end{syntax} % \begin{macrocode} -\cs_new_protected:Npn \@@_get_ref_string:nN #1#2 +\cs_new_protected:Npn \@@_get_ref_opt_typeset:nN #1#2 { % First attempt: general options. \prop_get:NnNF \l_@@_ref_options_prop {#1} #2 @@ -4906,19 +5175,19 @@ {#1} #2 } { - % If not found, try type specific translations. - \@@_get_type_transl:xxnNF + % If not found, try type- and language-specific. + \@@_get_lang_opt_type:xxnNF { \l_@@_ref_language_tl } { \l_@@_label_type_a_tl } {#1} #2 { - % If not found, try default translations. - \@@_get_default_transl:xnNF + % If not found, try language-specific default. + \@@_get_lang_opt_default:xnNF { \l_@@_ref_language_tl } {#1} #2 { % If not found, try fallback. - \@@_get_fallback_transl:nNF {#1} #2 + \@@_get_fallback_unknown_lang_opt:nNF {#1} #2 { \tl_clear:N #2 \msg_warning:nnn { zref-clever } @@ -4932,12 +5201,12 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}{\@@_get_ref_font:nN} +% \begin{macro}{\@@_get_ref_opt_font:nN} % \begin{syntax} -% \cs{@@_get_ref_font:nN} \Arg{option} \Arg{tl variable} +% \cs{@@_get_ref_opt_font:nN} \Arg{option} \Arg{tl variable} % \end{syntax} % \begin{macrocode} -\cs_new_protected:Npn \@@_get_ref_font:nN #1#2 +\cs_new_protected:Npn \@@_get_ref_opt_font:nN #1#2 { % First attempt: general options. \prop_get:NnNF \l_@@_ref_options_prop {#1} #2 @@ -4967,6 +5236,74 @@ % \end{macro} % % +% \begin{macro}{\@@_get_ref_opt_bool:nnN} +% \begin{syntax} +% \cs{@@_get_ref_opt_bool:nN} \Arg{option} +% ~~\Arg{default} \Arg{bool variable} +% \end{syntax} +% \begin{macrocode} +\cs_new_protected:Npn \@@_get_ref_opt_bool:nnN #1#2#3 + { + % First attempt: general options. + \prop_get:NnNF \l_@@_ref_options_prop {#1} \l_tmpa_tl + { + % If not found, try type specific options. + \bool_lazy_and:nnTF + { + \prop_if_exist_p:c + { + l_@@_type_ + \l_@@_label_type_a_tl _options_prop + } + } + { + \prop_if_in_p:cn + { + l_@@_type_ + \l_@@_label_type_a_tl _options_prop + } + {#1} + } + { + \prop_get:cnN + { + l_@@_type_ + \l_@@_label_type_a_tl _options_prop + } + {#1} \l_tmpa_tl + } + { + % If not found, try type- and language-specific. + \@@_get_lang_opt_type:xxnNF + { \l_@@_ref_language_tl } + { \l_@@_label_type_a_tl } + {#1} \l_tmpa_tl + { + % If not found, try language-specific default. + \@@_get_lang_opt_default:xnNF + { \l_@@_ref_language_tl } + {#1} \l_tmpa_tl + { + % If not found, use default argument. + \bool_lazy_or:nnTF + { \str_if_eq_p:nn {#2} { true } } + { \str_if_eq_p:nn {#2} { false } } + { \tl_set:Nn \l_tmpa_tl {#2} } + { + % And, if even that fails, presume false. + \tl_set:Nn \l_tmpa_tl { false } + } + } + } + } + } + % Having retrieved the option value, set the boolean. At this point, we + % *know* '\l_tmpa_tl' is either 'true' or 'false'. + \use:c { bool_set_ \l_tmpa_tl :N } #3 + } +% \end{macrocode} +% \end{macro} +% % % \section{Compatibility} % @@ -5461,8 +5798,8 @@ \zcRefTypeSetup { equation } { reffont = \upshape , - refpre = {\textup{(}} , - refpos = {\textup{)}} , + preref = {\textup{(}} , + postref = {\textup{)}} , } \msg_info:nnn { zref-clever } { compat-package } { amsmath } } @@ -5752,10 +6089,10 @@ % % % -% \section{Dictionaries} +% \section{Language files} % % Initial values for the English, German, French, Portuguese, and Spanish, -% dictionaries have been provided by the author. Translations available for +% language files have been provided by the author. Translations available for % document elements' names in other packages have been an useful reference for % the purpose, namely: \pkg{babel}, \pkg{cleveref}, \pkg{translator}, and % \pkg{translations}. @@ -5763,7 +6100,7 @@ % % \subsection{English} % -% English dictionary has been initially provided by the author. +% English language file has been initially provided by the author. % % \begin{macrocode} %<*package> @@ -5779,7 +6116,7 @@ % \end{macrocode} % % \begin{macrocode} -%<*dict-english> +%<*lang-english> % \end{macrocode} % % \begin{macrocode} @@ -5838,8 +6175,6 @@ type = page , name-sg = page , Name-pl = Pages , name-pl = pages , - name-sg-ab = p. , - name-pl-ab = pp. , rangesep = {\textendash} , type = line , @@ -5897,8 +6232,8 @@ type = equation , name-sg-ab = eq. , Name-pl-ab = Eqs. , name-pl-ab = eqs. , - refpre = {(} , - refpos = {)} , + preref = {(} , + postref = {)} , type = theorem , Name-sg = Theorem , @@ -5980,14 +6315,14 @@ type = solution , % \end{macrocode} % % \begin{macrocode} -%</dict-english> +%</lang-english> % \end{macrocode} % % % % \subsection{German} % -% German dictionary has been initially provided by the author. +% German language file has been initially provided by the author. % % \begin{macrocode} %<*package> @@ -6004,7 +6339,7 @@ type = solution , % \end{macrocode} % % \begin{macrocode} -%<*dict-german> +%<*lang-german> % \end{macrocode} % % \begin{macrocode} @@ -6251,8 +6586,8 @@ type = equation , case = G , Name-sg = Gleichung , Name-pl = Gleichungen , - refpre = {(} , - refpos = {)} , + preref = {(} , + postref = {)} , type = theorem , gender = n , @@ -6451,18 +6786,18 @@ type = solution , % \end{macrocode} % % \begin{macrocode} -%</dict-german> +%</lang-german> % \end{macrocode} % % % % \subsection{French} % -% French dictionary has been initially provided by the author, and has been -% improved thanks to Denis Bitouzé (\githubissue{1}) and participants of the -% Groupe francophone des Utilisateurs de \TeX{} (GUTenberg) (at -% \url{https://groups.google.com/g/gut_fr/c/rNLm6weGcyg}) and the -% \texttt{fr.comp.text.tex} (at +% French language file has been initially provided by the author, and has been +% improved thanks to Denis Bitouzé and François Lagarde (at \githubissue{1}) +% and participants of the Groupe francophone des Utilisateurs de \TeX{} +% (GUTenberg) (at \url{https://groups.google.com/g/gut_fr/c/rNLm6weGcyg}) and +% the \texttt{fr.comp.text.tex} (at % \url{https://groups.google.com/g/fr.comp.text.tex/c/Fa11Tf6MFFs}) mailing % lists. % @@ -6477,7 +6812,7 @@ type = solution , % \end{macrocode} % % \begin{macrocode} -%<*dict-french> +%<*lang-french> % \end{macrocode} % % \begin{macrocode} @@ -6596,8 +6931,8 @@ type = equation , name-sg = équation , Name-pl = Équations , name-pl = équations , - refpre = {(} , - refpos = {)} , + preref = {(} , + postref = {)} , type = theorem , gender = m , @@ -6692,14 +7027,14 @@ type = solution , % \end{macrocode} % % \begin{macrocode} -%</dict-french> +%</lang-french> % \end{macrocode} % % % % \subsection{Portuguese} % -% Portuguese dictionary provided by the author, who's a native speaker of +% Portuguese language file provided by the author, who's a native speaker of % (Brazilian) Portuguese. I do expect this to be sufficiently general, but if % Portuguese speakers from other places feel the need for a Portuguese % variant, please let me know. @@ -6714,7 +7049,7 @@ type = solution , % \end{macrocode} % % \begin{macrocode} -%<*dict-portuguese> +%<*lang-portuguese> % \end{macrocode} % % \begin{macrocode} @@ -6780,8 +7115,6 @@ type = page , name-sg = página , Name-pl = Páginas , name-pl = páginas , - name-sg-ab = p. , - name-pl-ab = pp. , rangesep = {\textendash} , type = line , @@ -6847,8 +7180,8 @@ type = equation , name-sg-ab = eq. , Name-pl-ab = Eqs. , name-pl-ab = eqs. , - refpre = {(} , - refpos = {)} , + preref = {(} , + postref = {)} , type = theorem , gender = m , @@ -6943,14 +7276,14 @@ type = solution , % \end{macrocode} % % \begin{macrocode} -%</dict-portuguese> +%</lang-portuguese> % \end{macrocode} % % % % \subsection{Spanish} % -% Spanish dictionary has been initially provided by the author. +% Spanish language file has been initially provided by the author. % % \begin{macrocode} %<*package> @@ -6959,7 +7292,7 @@ type = solution , % \end{macrocode} % % \begin{macrocode} -%<*dict-spanish> +%<*lang-spanish> % \end{macrocode} % % \begin{macrocode} @@ -7078,8 +7411,8 @@ type = equation , name-sg = ecuación , Name-pl = Ecuaciones , name-pl = ecuaciones , - refpre = {(} , - refpos = {)} , + preref = {(} , + postref = {)} , type = theorem , gender = m , @@ -7174,7 +7507,255 @@ type = solution , % \end{macrocode} % % \begin{macrocode} -%</dict-spanish> +%</lang-spanish> +% \end{macrocode} +% +% +% +% \subsection{Dutch} +% +% Dutch language file initially contributed by \texttt{niluxv} (\githubPR{5}). +% All genders were checked against the ``Dikke Van Dale''. Many words have +% multiple genders. +% +% \begin{macrocode} +%<*package> +\zcDeclareLanguage [ gender = { f , m , n } ] { dutch } +%</package> +% \end{macrocode} +% +% \begin{macrocode} +%<*lang-dutch> +% \end{macrocode} +% +% \begin{macrocode} +namesep = {\nobreakspace} , +pairsep = {~en\nobreakspace} , +listsep = {,~} , +lastsep = {~en\nobreakspace} , +tpairsep = {~en\nobreakspace} , +tlistsep = {,~} , +tlastsep = {,~en\nobreakspace} , +notesep = {~} , +rangesep = {~t/m\nobreakspace} , + +type = book , + gender = n , + Name-sg = Boek , + name-sg = boek , + Name-pl = Boeken , + name-pl = boeken , + +type = part , + gender = n , + Name-sg = Deel , + name-sg = deel , + Name-pl = Delen , + name-pl = delen , + +type = chapter , + gender = n , + Name-sg = Hoofdstuk , + name-sg = hoofdstuk , + Name-pl = Hoofdstukken , + name-pl = hoofdstukken , + +type = section , + gender = m , + Name-sg = Paragraaf , + name-sg = paragraaf , + Name-pl = Paragrafen , + name-pl = paragrafen , + +type = paragraph , + gender = f , + Name-sg = Alinea , + name-sg = alinea , + Name-pl = Alinea's , + name-pl = alinea's , + +type = appendix , + gender = { m , n } , + Name-sg = Appendix , + name-sg = appendix , + Name-pl = Appendices , + name-pl = appendices , + +type = page , + gender = { f , m } , + Name-sg = Pagina , + name-sg = pagina , + Name-pl = Pagina's , + name-pl = pagina's , + rangesep = {\textendash} , + +type = line , + gender = m , + Name-sg = Regel , + name-sg = regel , + Name-pl = Regels , + name-pl = regels , + +type = figure , + gender = { n , f , m } , + Name-sg = Figuur , + name-sg = figuur , + Name-pl = Figuren , + name-pl = figuren , + +type = table , + gender = { f , m } , + Name-sg = Tabel , + name-sg = tabel , + Name-pl = Tabellen , + name-pl = tabellen , + +type = item , + gender = n , + Name-sg = Punt , + name-sg = punt , + Name-pl = Punten , + name-pl = punten , + +type = footnote , + gender = { f , m } , + Name-sg = Voetnoot , + name-sg = voetnoot , + Name-pl = Voetnoten , + name-pl = voetnoten , + +type = endnote , + gender = { f , m } , + Name-sg = Eindnoot , + name-sg = eindnoot , + Name-pl = Eindnoten , + name-pl = eindnoten , + +type = note , + gender = f , + Name-sg = Opmerking , + name-sg = opmerking , + Name-pl = Opmerkingen , + name-pl = opmerkingen , + +type = equation , + gender = f , + Name-sg = Vergelijking , + name-sg = vergelijking , + Name-pl = Vergelijkingen , + name-pl = vergelijkingen , + Name-sg-ab = Vgl. , + name-sg-ab = vgl. , + Name-pl-ab = Vgl.'s , + name-pl-ab = vgl.'s , + preref = {(} , + postref = {)} , + +type = theorem , + gender = f , + Name-sg = Stelling , + name-sg = stelling , + Name-pl = Stellingen , + name-pl = stellingen , +% \end{macrocode} +% +% 2022-01-09, \texttt{niluxv}: An alternative plural is ``lemmata''. That is +% also a correct English plural for lemma, but the English language file +% chooses ``lemmas''. For consistency we therefore choose ``lemma's''. +% +% \begin{macrocode} +type = lemma , + gender = n , + Name-sg = Lemma , + name-sg = lemma , + Name-pl = Lemma's , + name-pl = lemma's , + +type = corollary , + gender = n , + Name-sg = Gevolg , + name-sg = gevolg , + Name-pl = Gevolgen , + name-pl = gevolgen , + +type = proposition , + gender = f , + Name-sg = Propositie , + name-sg = propositie , + Name-pl = Proposities , + name-pl = proposities , + +type = definition , + gender = f , + Name-sg = Definitie , + name-sg = definitie , + Name-pl = Definities , + name-pl = definities , + +type = proof , + gender = n , + Name-sg = Bewijs , + name-sg = bewijs , + Name-pl = Bewijzen , + name-pl = bewijzen , + +type = result , + gender = n , + Name-sg = Resultaat , + name-sg = resultaat , + Name-pl = Resultaten , + name-pl = resultaten , + +type = remark , + gender = f , + Name-sg = Opmerking , + name-sg = opmerking , + Name-pl = Opmerkingen , + name-pl = opmerkingen , + +type = example , + gender = n , + Name-sg = Voorbeeld , + name-sg = voorbeeld , + Name-pl = Voorbeelden , + name-pl = voorbeelden , + +type = algorithm , + gender = { n , f , m } , + Name-sg = Algoritme , + name-sg = algoritme , + Name-pl = Algoritmes , + name-pl = algoritmes , +% \end{macrocode} +% +% 2022-01-09, \texttt{niluxv}: EN-NL Van Dale translates listing as (3) +% ``uitdraai van computerprogramma'', ``listing''. +% +% \begin{macrocode} +type = listing , + gender = m , + Name-sg = Listing , + name-sg = listing , + Name-pl = Listings , + name-pl = listings , + +type = exercise , + gender = { f , m } , + Name-sg = Opgave , + name-sg = opgave , + Name-pl = Opgaven , + name-pl = opgaven , + +type = solution , + gender = f , + Name-sg = Oplossing , + name-sg = oplossing , + Name-pl = Oplossingen , + name-pl = oplossingen , +% \end{macrocode} +% +% \begin{macrocode} +%</lang-dutch> % \end{macrocode} % % diff --git a/Master/texmf-dist/source/latex/zref-clever/zref-clever.ins b/Master/texmf-dist/source/latex/zref-clever/zref-clever.ins index 46d9982dc46..69c052679e4 100644 --- a/Master/texmf-dist/source/latex/zref-clever/zref-clever.ins +++ b/Master/texmf-dist/source/latex/zref-clever/zref-clever.ins @@ -4,7 +4,7 @@ % % This file is part of the LaTeX package "zref-clever". % -% Copyright (C) 2021 Gustavo Barros +% Copyright (C) 2021-2022 Gustavo Barros % % It may be distributed and/or modified under the conditions of the % LaTeX Project Public License (LPPL), either version 1.3c of this @@ -50,7 +50,7 @@ This file was generated from file(s) of the LaTeX package "zref-clever". -Copyright (C) 2021 Gustavo Barros +Copyright (C) 2021-2022 Gustavo Barros It may be distributed and/or modified under the conditions of the LaTeX Project Public License (LPPL), either version 1.3c of this @@ -90,10 +90,11 @@ for those people who are interested. \endpostamble \generate{\file{zref-clever.sty}{\from{zref-clever.dtx}{package}}} -\generate{\file{zref-clever-english.dict}{\from{zref-clever.dtx}{dict-english}}} -\generate{\file{zref-clever-german.dict}{\from{zref-clever.dtx}{dict-german}}} -\generate{\file{zref-clever-french.dict}{\from{zref-clever.dtx}{dict-french}}} -\generate{\file{zref-clever-portuguese.dict}{\from{zref-clever.dtx}{dict-portuguese}}} -\generate{\file{zref-clever-spanish.dict}{\from{zref-clever.dtx}{dict-spanish}}} +\generate{\file{zref-clever-english.lang}{\from{zref-clever.dtx}{lang-english}}} +\generate{\file{zref-clever-german.lang}{\from{zref-clever.dtx}{lang-german}}} +\generate{\file{zref-clever-french.lang}{\from{zref-clever.dtx}{lang-french}}} +\generate{\file{zref-clever-portuguese.lang}{\from{zref-clever.dtx}{lang-portuguese}}} +\generate{\file{zref-clever-spanish.lang}{\from{zref-clever.dtx}{lang-spanish}}} +\generate{\file{zref-clever-dutch.lang}{\from{zref-clever.dtx}{lang-dutch}}} \endbatchfile |