summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Master/texmf-dist/doc/latex/cooking-units/README.md2
-rw-r--r--Master/texmf-dist/doc/latex/cooking-units/cooking-units.pdfbin738814 -> 742764 bytes
-rw-r--r--Master/texmf-dist/source/latex/cooking-units/cooking-units.dtx351
-rw-r--r--Master/texmf-dist/tex/latex/cooking-units/cooking-units.sty143
4 files changed, 440 insertions, 56 deletions
diff --git a/Master/texmf-dist/doc/latex/cooking-units/README.md b/Master/texmf-dist/doc/latex/cooking-units/README.md
index f5ab89dd310..5f441d3c1c5 100644
--- a/Master/texmf-dist/doc/latex/cooking-units/README.md
+++ b/Master/texmf-dist/doc/latex/cooking-units/README.md
@@ -49,7 +49,7 @@ Supported Languages
* German
* English
-* French (suboptimal)
+* French
License
-------
diff --git a/Master/texmf-dist/doc/latex/cooking-units/cooking-units.pdf b/Master/texmf-dist/doc/latex/cooking-units/cooking-units.pdf
index d4b06cbb013..7360d46430c 100644
--- a/Master/texmf-dist/doc/latex/cooking-units/cooking-units.pdf
+++ b/Master/texmf-dist/doc/latex/cooking-units/cooking-units.pdf
Binary files differ
diff --git a/Master/texmf-dist/source/latex/cooking-units/cooking-units.dtx b/Master/texmf-dist/source/latex/cooking-units/cooking-units.dtx
index 574f2b7fcd8..b953801209b 100644
--- a/Master/texmf-dist/source/latex/cooking-units/cooking-units.dtx
+++ b/Master/texmf-dist/source/latex/cooking-units/cooking-units.dtx
@@ -59,7 +59,7 @@ Supported Languages
* German
* English
-* French (suboptimal)
+* French
License
-------
@@ -221,14 +221,21 @@ and the derived file cooking-units.sty.
cudefinekeys ,
, cudefinekeychain , cuaddtokeychain
, cudeclareunitgroup
+ , cookingunits_print_fraction:nnn , cookingunits_print_range:nn
+ , ExplSyntaxOff, ExplSyntaxOn
}
\NewDocumentCommand \mycs { m }
{
- \clist_if_in:NnTF \l_cookingunits_list_of_defined_befehlen_clist {#1}
+ \tl_set_rescan:Nnn \l_tmpa_tl
+ {
+ \char_set_catcode_letter:N \_ %
+ \char_set_catcode_letter:N \: %
+ } {#1}
+ \clist_if_in:NVTF \l_cookingunits_list_of_defined_befehlen_clist \l_tmpa_tl
{
- \cs_if_exist:cTF {#1}
- { \cs{\textcolor{blue}{#1}} }
+ \cs_if_exist:cTF { \l_tmpa_tl }
+ { \cs{\textcolor{blue}{ \l_tmpa_tl }} }
{ \tl_show:n {#1}\mycsERRORII }
}
{ \tl_show:n {#1} \mycsERROR }
@@ -806,6 +813,9 @@ and the derived file cooking-units.sty.
% \changes {2022/03/26} {2.00a} {Bugfix: |\cuam| prints a unit in case of an error. This also happens with \opt{parse-number=false}.}
% \changes {2022/03/26} {2.00a} {Bugfix: Remove \cs{peek_meaning_ignore_spaces:NTF}.}
%
+% \changes {2022/06/06} {2.01} {Correction of french language. Thanks to Alexis Jeandeau}
+% \changes {2022/06/06} {2.01} {Implement a way to define the plural-finding algorithm.}
+% \changes {2022/06/06} {2.01} {Add two public commands \cs{cookingunits_print_fraction:nnn} and \cs{cookingunits_print_range:nn}.}
%
%
%
@@ -859,7 +869,7 @@ and the derived file cooking-units.sty.
% \begin{itemize}
% \item German
% \item English
-% \item French (currently suboptimal\footnote{You can only get limited information from the internet.})
+% \item French
% \end{itemize}
% Want to contribute a new language or make a correction to an existing one?
% See \cref{sec:bug-feed} for more details. Wanna just check the
@@ -1066,9 +1076,9 @@ and the derived file cooking-units.sty.
%
%
%
+% \section{Good to know stuff}
%
-%
-%\subsection{Rounding temperatures}
+% \subsection{Rounding temperatures}
%
%
% By default temperatures are rounded to integers (using \opt{round-precision=0}).
@@ -1088,6 +1098,40 @@ and the derived file cooking-units.sty.
% \cunum[C=K]{180}{C} \\
% \end{cuexamplecode}
%
+%
+% \subsection{At which point is the plural used?}
+% While using \cCutext\ one may wonder which rules are used in order to determine
+% if the printed unit is singular or plural. If rules for a specific language are not found
+% the default ruleset is used. There are currently two rule sets: One default
+% and one if you are using french.
+%
+% Each set has three seperate rules: one for \enquote{normal} numbers, one for
+% ranges and one for fractions.
+%
+% \subsubsection*{French}
+%
+% Use singular if:
+% \begin{description}
+% \item[normal] The absolute value of the number is smaller $2$
+% \item[fraction] The absolute value of the evaluated fraction is smaller $2$.
+% (e.g.\ $1\,\sfrac{1}{2} = 1.5$ uses singular, $2\,\sfrac{3}{4} = 2.75$ uses plural).
+% \item[range] The absolute value of the second number is smaller $2$.
+% (e.g.\ \cuam{1--2}: Take $2$.)
+% \end{description}
+%
+% For sources see \cite{Plural-French-Academia}, \cite{Plural-French-absolute-1} \&
+% \cite{Plural-French-absolute-2}\footnote{Thanks a lot to Alexis Jeandeau! I never would
+% have imagined that the french language uses the sinfular for everything smaller $2$.}.
+%
+% \subsubsection*{Default (all other languages)}
+%
+% Use singular if:
+% \begin{description}
+% \item[normal] The number is equal to $1$.
+% \item[fraction] There is no mixed fraction part and the nominator is equal to $1$.
+% \item[range] The second number is equal to $1$. (e.g.\ \cuam{1--2}: Take $2$.)
+% \end{description}
+%
% \section{Predefined units \& some notes}
% \label{sec:pred-units}
%
@@ -1760,7 +1804,8 @@ and the derived file cooking-units.sty.
% {dl} {dL}
% {cl} {cL}
% {ml} {mL}
-% {decimal-mark} {.}
+% {cutext-range-sign} {~\`{a}~}
+% {decimal-mark} {,}
% {one(m)} {un}
% {one(f)} {une}
% {one(n)} {un}
@@ -3202,6 +3247,52 @@ and the derived file cooking-units.sty.
%
%
%
+%
+%
+%
+% \section{Public Commands}
+%
+% This section describes some public functions, Their main usage is the printing of
+% stuff. They are primtivies used between an \mycs{ExplSyntaxOn} and
+% \mycs{ExplSyntaxOff}; for usage in a document you may do the following:
+% \begin{lstlisting}
+% \ExplSyntaxOn
+% \NewDocumentCommand \cuprintfrac { O{} m m }
+% {
+% \cookingunits_print_fraction:nnn {#1} {#2} {#3}
+% }
+% \NewDocumentCommand \cuprintrange { m m }
+% {
+% \cookingunits_print_range:nn {#1} {#2}
+% }
+% \ExplSyntaxOff
+% \end{lstlisting}
+%
+%
+% \begin{function}{\cookingunits_print_fraction:nnn}
+% \begin{syntax}
+% \mycs{cookingunits_print_fraction:nnn} \marg{mixed-part}\marg{numerator}\marg{denominator}
+% \end{syntax}
+% \emph{Note:} There is no parsing and processing done in this command, it just
+% prints the input.
+%
+% Uses the internal fraction printing command to print a fraction. \Arg{mixed-part}
+% can be empty if no mixed part is needed.
+% \end{function}
+%
+%
+% \begin{function}{\cookingunits_print_range:nn}
+% \begin{syntax}
+% \mycs{cookingunits_print_range:nn} \marg{left-part}\marg{right-part}
+% \end{syntax}
+% \emph{Note:} There is no parsing and processing done in this command, ist just
+% prints the input.
+%
+% Uses the internal range printing command to print a range (using the same range sign as
+% \mycs{cunum} would use)
+% \end{function}
+%
+%
%^^A \section{Notes}
%
%^^A There is a unit called \enquote{Batman}.
@@ -3235,8 +3326,7 @@ and the derived file cooking-units.sty.
% header).
%
% Furthermore, as you can see I am not able to speak too many
-% languages (german and english to be precise; I managed to add french
-% with the help of the internet, which is not optimal) so if you are
+% languages (german and english to be precise) so if you are
% able to speak a language not yet implemented and would like to help
% you can send me the translations known to you. A list of all units
% (and their current translations) is given in \cref{sec:Translations}.
@@ -3603,8 +3693,8 @@ and the derived file cooking-units.sty.
% \begin{macrocode}
\ProvidesExplPackage
{cooking-units}
- {2022/03/26}
- {2.00a}
+ {2022/06/06}
+ {2.01}
{Ein Paket fuer Kocheinheiten}
% \end{macrocode}
%
@@ -4149,7 +4239,7 @@ and the derived file cooking-units.sty.
% , \l_@@_pckopt_print_numeral_bool
% , \l_@@_lokal_numeral_bool
% , \l_@@_phrase_negative_bool
-% , \l_@@_cutext_last_amount_equ_one_bool
+% , \l_@@_cutext_use_single_bool
% , \l_@@_symbol_was_set_by_key_bool
% , \l_@@_contains_valid_key_bool
% , \l_@@_check_decimal_bool
@@ -4184,7 +4274,7 @@ and the derived file cooking-units.sty.
\bool_new:N \l_@@_pckopt_print_numeral_bool
\bool_new:N \l_@@_lokal_numeral_bool
\bool_new:N \l_@@_phrase_negative_bool
-\bool_new:N \l_@@_cutext_last_amount_equ_one_bool
+\bool_new:N \l_@@_cutext_use_single_bool
\bool_new:N \l_@@_symbol_was_set_by_key_bool
\bool_new:N \l_@@_contains_valid_key_bool
\bool_new:N \l_@@_check_decimal_bool
@@ -6579,6 +6669,7 @@ and the derived file cooking-units.sty.
\@@_culang_def_base:nnn { name } { decimal-mark } { . }
\@@_culang_def_base:nnn { name-pl } { decimal-mark } { \c_@@_no_translation_str }
\@@_culang_def_for:nnnn { German } { name-pl } { decimal-mark } { , }
+\@@_culang_def_for:nnnn { French } { name-pl } { decimal-mark } { , }
% \end{macrocode}
% Note that the plural versions just exist for completing the set.
% \begin{macrocode}
@@ -6599,12 +6690,18 @@ and the derived file cooking-units.sty.
\@@_culang_def_for:nnnn { German } { name } { one (f) } { eine }
\@@_culang_def_for:nnnn { German } { name } { one (n) } { ein }
% \end{macrocode}
+% \begin{macrocode}
+\@@_culang_def_for:nnnn { French } { name } { one (m) } { un }
+\@@_culang_def_for:nnnn { French } { name } { one (f) } { une }
+\@@_culang_def_for:nnnn { French } { name } { one (n) } { un }
+% \end{macrocode}
%
% \begin{macrocode}
\@@_culang_def_base:nnn { name } { cutext-range-sign } { -- }
\@@_culang_def_base:nnn { name-pl } { cutext-range-sign } { \c_@@_no_translation_str }
\@@_culang_def_for:nnnn { German } { name } { cutext-range-sign } { ~bis~ }
\@@_culang_def_for:nnnn { English } { name } { cutext-range-sign } { ~to~ }
+\@@_culang_def_for:nnnn { French } { name } { cutext-range-sign } { ~\`{a}~ }
% \end{macrocode}
%
%
@@ -6754,7 +6851,7 @@ and the derived file cooking-units.sty.
{
\bool_if:NT \l_@@_pckopt_cutext_to_cunum_bool
{ \@@_set_cmd_type_to:n { cunum } }
- \bool_set_false:N \l_@@_cutext_last_amount_equ_one_bool
+ \bool_set_false:N \l_@@_cutext_use_single_bool
}
% \end{macrocode}
% \end{macro}
@@ -7030,12 +7127,17 @@ and the derived file cooking-units.sty.
\l_@@_mixed_fraction_tl
\l_@@_number_tmpa_tl
\l_@@_number_tmpb_tl
- \@@_if_print_type_equal:nT { number }
+ \@@_if_print_type_equal:nTF { number }
{
\@@_convert_fraction_to_number_in_input:NNN
\l_@@_mixed_fraction_tl
\l_@@_number_tmpa_tl
\l_@@_number_tmpb_tl
+ }{
+ \@@_post_process_fraction_accordingly:NNN
+ \l_@@_mixed_fraction_tl
+ \l_@@_number_tmpa_tl
+ \l_@@_number_tmpb_tl
}
}
% \end{macrocode}
@@ -7226,6 +7328,24 @@ and the derived file cooking-units.sty.
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}{ \@@_post_process_fraction_accordingly:NNN }
+% Decided to make this into its own command. This post processes fractions
+% which is only needed by \cCutext.
+% \begin{macrocode}
+\cs_new:Npn \@@_post_process_fraction_accordingly:NNN #1#2#3
+ {
+ \tl_case:NnF \l_@@_cmd_type_tl
+ {
+ \c_@@_cmd_type_cunum_tl { }
+ \c_@@_cmd_type_cCutext_tl { \@@_cutext_post_process_fraction_input:NNN #1#2#3 }
+ \c_@@_cmd_type_cuam_tl { }
+ }{
+ \@@_create_internal_error:nN { post-process-frac } \l_@@_cmd_type_tl
+ }
+ }
+% \end{macrocode}
+% \end{macro}
+%
% \begin{macro}{ \@@_print_numerical_input:N }
% The base printing command for numbers. Makes sure the minus sign
% and decimal-mark are correct.
@@ -7970,7 +8090,7 @@ and the derived file cooking-units.sty.
\bool_if:NTF \l_@@_lokal_numeral_bool
{ \l_@@_cutext_numeral_space_tl }
{ \l_@@_cutext_space_tl }
- \bool_if:NTF \l_@@_cutext_last_amount_equ_one_bool
+ \bool_if:NTF \l_@@_cutext_use_single_bool
{ \@@_culang_print:nV { name } \l_@@_decided_unit_tl }
{ \@@_culang_print:nV { name-pl } \l_@@_decided_unit_tl }
}
@@ -8019,8 +8139,15 @@ and the derived file cooking-units.sty.
\cs_new:Npn \@@_cutext_post_process_input:NN #1#2
{
\@@_if_parse_and_process_type_equal:nTF { range }
- { \@@_cutext_check_if_amount_single:N #2 }
- { \@@_cutext_check_if_amount_single:N #1 }
+ {
+ \@@_culang_let:nnN { pluraltest } { range } \l_@@_translation_tmpa_tl
+ \use:c { @@_pluraltest_range_ \l_@@_translation_tmpa_tl :NN } #1#2
+% \@@_cutext_check_if_plural_is_needed:N #2
+ }{
+ \@@_culang_let:nnN { pluraltest } { normal } \l_@@_translation_tmpa_tl
+ \use:c { @@_pluraltest_normal_ \l_@@_translation_tmpa_tl :N } #1
+% \@@_cutext_check_if_plural_is_needed:N #1
+ }
\bool_if:NT \l_@@_lokal_numeral_bool
{
\@@_if_contain_decimals:NNTF #1#2
@@ -8030,18 +8157,29 @@ and the derived file cooking-units.sty.
}
% \end{macrocode}
% \end{macro}
-% \begin{macro} { \@@_cutext_check_if_amount_single:N }
-% Check if the input is equal to |#1|. Use fp as it is not necessary an integer.
-% Set the boolean according to the result.
+% \begin{macro} { \@@_cutext_post_process_fraction_input:NNN }
% \begin{macrocode}
-\cs_new:Npn \@@_cutext_check_if_amount_single:N #1
+\cs_new:Npn \@@_cutext_post_process_fraction_input:NNN #1#2#3
{
- \fp_compare:nNnTF {#1} = { 1.0 }
- { \bool_set_true:N } { \bool_set_false:N }
- \l_@@_cutext_last_amount_equ_one_bool
+ \@@_culang_let:nnN { pluraltest } { fraction } \l_@@_translation_tmpa_tl
+ \use:c { @@_pluraltest_fraction_ \l_@@_translation_tmpa_tl :NNN } #1#2#3
}
% \end{macrocode}
% \end{macro}
+% \begin{macro} { \@@_cutext_check_if_plural_is_needed:N }
+% Check if the input is equal to |#1|. Use fp as it is not necessary an integer.
+% Set the boolean according to the result.
+% \begin{macrocode}
+%\cs_new:Npn \@@_cutext_check_if_plural_is_needed:N #1
+% {
+% \fp_compare:nNnTF {#1} = { 1.0 }
+% { \bool_set_true:N } { \bool_set_false:N }
+% \l_@@_cutext_use_single_bool
+% }
+% \end{macrocode}
+% \end{macro}
+%
+%
% \begin{macro} { \@@_check_if_integer_can_be_numerals:NN }
% At this point we know that we have integers, so check if they are
% below |\l_@@_print_numerals_below_int|. If they are, fine. Else,
@@ -8128,7 +8266,7 @@ and the derived file cooking-units.sty.
%
%
% Just a helper macro to tidy up the main macro. The first thing to
-% do is to check if the nummerical input consits of integers. This
+% do is to check if the numerical input consits of integers. This
% is done both both numerical values (if a range exists).
% Afterwards check if phrases are used and can be used at all. This needs
% to be done before the numeral check as it can change the input.
@@ -8293,6 +8431,40 @@ and the derived file cooking-units.sty.
%
%
%
+%
+% \subsection{Public Primitives}
+%
+% Two public commands.
+% \begin{macro}{ \cookingunits_print_fraction:nnn }
+% \begin{macrocode}
+\cs_new:Npn \cookingunits_print_fraction:nnn #1#2#3
+ {
+ \group_begin:
+ \@@_set_amount:Nn \l_@@_mixed_fraction_tl {#1}
+ \@@_set_amount:Nn \l_@@_number_tmpa_tl {#2}
+ \@@_set_amount:Nn \l_@@_number_tmpb_tl {#3}
+ \@@_print_fractions:Nnn
+ \l_@@_mixed_fraction_tl
+ \l_@@_number_tmpa_tl
+ \l_@@_number_tmpb_tl
+ \group_end:
+ }
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{ \cookingunits_print_range:nn }
+% \begin{macrocode}
+\cs_new:Npn \cookingunits_print_range:nn #1#2
+ {
+ \group_begin:
+ \@@_set_cmd_type_to:n { cunum }
+ #1
+ \@@_print_range_sign:
+ #2
+ \group_end:
+ }
+% \end{macrocode}
+% \end{macro}
+%
% \subsection{\mycs{cucomp}}
%
%
@@ -9511,6 +9683,101 @@ and the derived file cooking-units.sty.
% \end{macrocode}
% \end{macro}
%
+%
+% \subsection {Define plural-usage for \cCutext}
+%
+% \begin{macro}{ pluraltest: normal/range/fraction }
+% Some translations used in a second. Define one for \enquote{normal}
+% (just a number), \enquote{range} and \enquote{fraction}.
+% \begin{macrocode}
+\@@_culang_def_base:nnn { pluraltest } { normal } { \c_@@_no_translation_str }
+\@@_culang_def_base:nnn { pluraltest } { range } { \c_@@_no_translation_str }
+\@@_culang_def_base:nnn { pluraltest } { fraction } { \c_@@_no_translation_str }
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{ @@_pluraltest_normal_<default>:N,
+% @@_pluraltest_range_<default>:NN,
+% @@_pluraltest_fraction_<default>:NNN }
+% Here we define the default behavior, if no explicit rule is given for a language.
+% By default, use the singular only if the value in question is equal to $1$.
+% For ranges take the last value, for fractions make sure there are no mixed fractions
+% and that the nominator is equal to $1$.
+% \begin{macrocode}
+\cs_set:cpn { @@_pluraltest_normal_ \c_@@_no_translation_str :N } #1
+ {
+ \fp_compare:nNnTF {#1} = { 1.0 }
+ { \bool_set_true:N } { \bool_set_false:N }
+ \l_@@_cutext_use_single_bool
+ }
+\cs_set:cpn { @@_pluraltest_range_ \c_@@_no_translation_str :NN } #1#2
+ {
+ \fp_compare:nNnTF {#2} = { 1.0 }
+ { \bool_set_true:N } { \bool_set_false:N }
+ \l_@@_cutext_use_single_bool
+ }
+\cs_set:cpn { @@_pluraltest_fraction_ \c_@@_no_translation_str :NNN } #1#2#3
+ {
+ \tl_if_empty:NTF #1
+ { \fp_compare:nNnTF {#2} = { 1.0 } } { \use_ii:nn }
+ { \bool_set_true:N } { \bool_set_false:N }
+ \l_@@_cutext_use_single_bool
+ }
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{ \@@_pluraltest_define:nn , \@@_pluraltest_define_range:nn , \@@_pluraltest_define_fraction:nn }
+% Allow to define a when to use the singular/plural for a given language.
+% Nothing more happens here. The default was already defined in the last step.
+% \begin{macrocode}
+\cs_new:Npn \@@_pluraltest_define:nn #1#2
+ {
+ \@@_culang_def_for:nnnn {#1} { pluraltest } { normal } {#1}
+ \cs_set:cpn { @@_pluraltest_normal_ #1 :N } ##1 {#2}
+ }
+\cs_new:Npn \@@_pluraltest_define_range:nn #1#2
+ {
+ \@@_culang_def_for:nnnn {#1} { pluraltest } { range } {#1}
+ \cs_set:cpn { @@_pluraltest_range_ #1 :NN } ##1##2 {#2}
+ }
+\cs_new:Npn \@@_pluraltest_define_fraction:nn #1#2
+ {
+ \@@_culang_def_for:nnnn {#1} { pluraltest } { fraction } {#1}
+ \cs_set:cpn { @@_pluraltest_fraction_ #1 :NNN } ##1##2##3 {#2}
+ }
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{ Pluraltest: French }
+% As source see
+% \begin{itemize}
+% \item \url{https://github.com/Vidabe/cooking-units/pull/29#issue-1190629683}
+% \item \url{https://www.dictionnaire-academie.fr/article/A9P2979}
+% \end{itemize}
+% Note: At this point the minus signs were already removed from fractions; thus
+% all their values are positive.
+% \begin{macrocode}
+\@@_pluraltest_define:nn { French }
+ {
+ \fp_compare:nNnTF { \fp_abs:n {#1} } < { 2.0 }
+ { \bool_set_true:N } { \bool_set_false:N }
+ \l_@@_cutext_use_single_bool
+ }
+\@@_pluraltest_define_range:nn { French }
+ {
+ \fp_compare:nNnTF { \fp_abs:n {#2} } < { 2.0 }
+ { \bool_set_true:N } { \bool_set_false:N }
+ \l_@@_cutext_use_single_bool
+ }
+\@@_pluraltest_define_fraction:nn { French }
+ {
+ \quark_if_nil:NTF #1
+ { \fp_compare:nNnTF { #2/#3 } < { 2.0 } }
+ { \fp_compare:nNnTF { #1 + #2/#3 } < { 2.0 } }
+ { \bool_set_true:N } { \bool_set_false:N }
+ \l_@@_cutext_use_single_bool
+ }
+% \end{macrocode}
+% \end{macro}
+%
+%
% \subsection {cudefinesymbol}
%
% \begin{macro}{ \cudefinesymbol }
@@ -10290,8 +10557,8 @@ and the derived file cooking-units.sty.
{
{ kg } { kilogramme } [ kilogrammes ]
{ dag } { d\'{e}cagramme } [ d\'{e}cagrammes]
- { g } { gramme } [ gramme ]
- { oz } { once } < f >
+ { g } { gramme } [ grammes ]
+ { oz } { once } [ onces ] < f >
{ lb } { livre } [ livres ] < f >
% \end{macrocode}
% \begin{macrocode}
@@ -10320,19 +10587,19 @@ and the derived file cooking-units.sty.
{ ml } [ mL ] { millilitre } [ millilitres ]
% \end{macrocode}
% \begin{macrocode}
- { cal } { calorie } [ calorie ]
- { kcal } { kilocalorie } [ kilocalories ]
+ { cal } { calorie } [ calories ] < f >
+ { kcal } { kilocalorie } [ kilocalories ] < f >
{ J } { joule } [ joules ]
{ kJ } { kilojoule } [ kilojoules ]
{ eV } { \'{e}lectron-volt } [ \'{e}lectron-volts ]
% \end{macrocode}
% \begin{macrocode}
- { pn } { pinc\'{e}e } < f >
- { EL } [c.\`{a}.s.] { cuill\`{e}re \space \`{a} \space soupe } < f >
- { TL } [c.\`{a}.c.] { cuill\`{e}re \space \`{a} \space caf\'{e} } < f >
+ { pn } [ pinc\'{e}e ] { pinc\'{e}e } [ pinc\'{e}es ] < f >
+ { EL } [c.\`{a}.s.] { cuill\`{e}re \space \`{a} \space soupe } [ cuill\`{e}res \space \`{a} \space soupe ] < f >
+ { TL } [c.\`{a}.c.] { cuill\`{e}re \space \`{a} \space caf\'{e} } [ cuill\`{e}res \space \`{a} \space caf\'{e} ] < f >
% \end{macrocode}
% \begin{macrocode}
- { decimal-mark } { . }
+ { decimal-mark } { , }
{ one (m) } { un }
{ one (f) } { une }
{ one (n) } { un }
@@ -10524,6 +10791,20 @@ and the derived file cooking-units.sty.
%
% \bibitem{StickSource} \url{https://cooking.stackexchange.com/questions/784/translating-cooking-terms-between-us-uk-au-ca-nz}
%
+% \bibitem{Plural-French-Academia}
+% Dictionnaire de l’Académie française.
+% \url{https://www.dictionnaire-academie.fr/article/A9P2979}
+% [Last checked: 2022-05-29]
+%
+% \bibitem{Plural-French-absolute-1}
+% \url{https://www.antidote.info/fr/blogue/enquetes/15-gramme-ou-15-grammes}
+% [Last checked: 2022-05-29]
+%
+% \bibitem{Plural-French-absolute-2}
+% \url{https://french.stackexchange.com/q/1975}
+% [Last checked: 2022-05-29]
+%
+%
% \end{thebibliography}
%
%
diff --git a/Master/texmf-dist/tex/latex/cooking-units/cooking-units.sty b/Master/texmf-dist/tex/latex/cooking-units/cooking-units.sty
index 923010ee9d3..f7564c0d864 100644
--- a/Master/texmf-dist/tex/latex/cooking-units/cooking-units.sty
+++ b/Master/texmf-dist/tex/latex/cooking-units/cooking-units.sty
@@ -30,8 +30,8 @@
{ \RequirePackage {expl3} }
\ProvidesExplPackage
{cooking-units}
- {2022/03/26}
- {2.00a}
+ {2022/06/06}
+ {2.01}
{Ein Paket fuer Kocheinheiten}
\@ifpackagelater { expl3 } { 2022/02/24 }
{ }
@@ -276,7 +276,7 @@
\bool_new:N \l__cookingunits_pckopt_print_numeral_bool
\bool_new:N \l__cookingunits_lokal_numeral_bool
\bool_new:N \l__cookingunits_phrase_negative_bool
-\bool_new:N \l__cookingunits_cutext_last_amount_equ_one_bool
+\bool_new:N \l__cookingunits_cutext_use_single_bool
\bool_new:N \l__cookingunits_symbol_was_set_by_key_bool
\bool_new:N \l__cookingunits_contains_valid_key_bool
\bool_new:N \l__cookingunits_check_decimal_bool
@@ -1596,6 +1596,7 @@
\__cookingunits_culang_def_base:nnn { name } { decimal-mark } { . }
\__cookingunits_culang_def_base:nnn { name-pl } { decimal-mark } { \c__cookingunits_no_translation_str }
\__cookingunits_culang_def_for:nnnn { German } { name-pl } { decimal-mark } { , }
+\__cookingunits_culang_def_for:nnnn { French } { name-pl } { decimal-mark } { , }
\__cookingunits_culang_def_base:nnn { name } { one (m) } { \c__cookingunits_no_translation_str }
\__cookingunits_culang_def_base:nnn { name } { one (f) } { \c__cookingunits_no_translation_str }
\__cookingunits_culang_def_base:nnn { name } { one (n) } { \c__cookingunits_no_translation_str }
@@ -1608,10 +1609,14 @@
\__cookingunits_culang_def_for:nnnn { German } { name } { one (m) } { ein }
\__cookingunits_culang_def_for:nnnn { German } { name } { one (f) } { eine }
\__cookingunits_culang_def_for:nnnn { German } { name } { one (n) } { ein }
+\__cookingunits_culang_def_for:nnnn { French } { name } { one (m) } { un }
+\__cookingunits_culang_def_for:nnnn { French } { name } { one (f) } { une }
+\__cookingunits_culang_def_for:nnnn { French } { name } { one (n) } { un }
\__cookingunits_culang_def_base:nnn { name } { cutext-range-sign } { -- }
\__cookingunits_culang_def_base:nnn { name-pl } { cutext-range-sign } { \c__cookingunits_no_translation_str }
\__cookingunits_culang_def_for:nnnn { German } { name } { cutext-range-sign } { ~bis~ }
\__cookingunits_culang_def_for:nnnn { English } { name } { cutext-range-sign } { ~to~ }
+\__cookingunits_culang_def_for:nnnn { French } { name } { cutext-range-sign } { ~\`{a}~ }
\cs_new:Npn \__cookingunits_def_new_type:nnn #1#2#3
{
\tl_new:c { l__cookingunits_ #1 _tl }
@@ -1690,7 +1695,7 @@
{
\bool_if:NT \l__cookingunits_pckopt_cutext_to_cunum_bool
{ \__cookingunits_set_cmd_type_to:n { cunum } }
- \bool_set_false:N \l__cookingunits_cutext_last_amount_equ_one_bool
+ \bool_set_false:N \l__cookingunits_cutext_use_single_bool
}
\cs_new:Npn \__cookingunits_initialize_new_default:nnn #1#2#3
{
@@ -1846,12 +1851,17 @@
\l__cookingunits_mixed_fraction_tl
\l__cookingunits_number_tmpa_tl
\l__cookingunits_number_tmpb_tl
- \__cookingunits_if_print_type_equal:nT { number }
+ \__cookingunits_if_print_type_equal:nTF { number }
{
\__cookingunits_convert_fraction_to_number_in_input:NNN
\l__cookingunits_mixed_fraction_tl
\l__cookingunits_number_tmpa_tl
\l__cookingunits_number_tmpb_tl
+ }{
+ \__cookingunits_post_process_fraction_accordingly:NNN
+ \l__cookingunits_mixed_fraction_tl
+ \l__cookingunits_number_tmpa_tl
+ \l__cookingunits_number_tmpb_tl
}
}
\cs_new:Npn \__cookingunits_process_and_remove_minus_in_fraction:NNNN #1 #2#3#4
@@ -1975,6 +1985,17 @@
\__cookingunits_create_internal_error:nN { post-process } \l__cookingunits_cmd_type_tl
}
}
+\cs_new:Npn \__cookingunits_post_process_fraction_accordingly:NNN #1#2#3
+ {
+ \tl_case:NnF \l__cookingunits_cmd_type_tl
+ {
+ \c__cookingunits_cmd_type_cunum_tl { }
+ \c__cookingunits_cmd_type_cCutext_tl { \__cookingunits_cutext_post_process_fraction_input:NNN #1#2#3 }
+ \c__cookingunits_cmd_type_cuam_tl { }
+ }{
+ \__cookingunits_create_internal_error:nN { post-process-frac } \l__cookingunits_cmd_type_tl
+ }
+ }
\cs_new_protected:Npn \__cookingunits_print_numerical_input:N #1
{
\tl_if_in:NnT #1 { . }
@@ -2356,7 +2377,7 @@
\bool_if:NTF \l__cookingunits_lokal_numeral_bool
{ \l__cookingunits_cutext_numeral_space_tl }
{ \l__cookingunits_cutext_space_tl }
- \bool_if:NTF \l__cookingunits_cutext_last_amount_equ_one_bool
+ \bool_if:NTF \l__cookingunits_cutext_use_single_bool
{ \__cookingunits_culang_print:nV { name } \l__cookingunits_decided_unit_tl }
{ \__cookingunits_culang_print:nV { name-pl } \l__cookingunits_decided_unit_tl }
}
@@ -2384,8 +2405,13 @@
\cs_new:Npn \__cookingunits_cutext_post_process_input:NN #1#2
{
\__cookingunits_if_parse_and_process_type_equal:nTF { range }
- { \__cookingunits_cutext_check_if_amount_single:N #2 }
- { \__cookingunits_cutext_check_if_amount_single:N #1 }
+ {
+ \__cookingunits_culang_let:nnN { pluraltest } { range } \l__cookingunits_translation_tmpa_tl
+ \use:c { __cookingunits_pluraltest_range_ \l__cookingunits_translation_tmpa_tl :NN } #1#2
+ }{
+ \__cookingunits_culang_let:nnN { pluraltest } { normal } \l__cookingunits_translation_tmpa_tl
+ \use:c { __cookingunits_pluraltest_normal_ \l__cookingunits_translation_tmpa_tl :N } #1
+ }
\bool_if:NT \l__cookingunits_lokal_numeral_bool
{
\__cookingunits_if_contain_decimals:NNTF #1#2
@@ -2393,11 +2419,10 @@
{ \__cookingunits_check_if_integer_can_be_numerals:NN #1#2 }
}
}
-\cs_new:Npn \__cookingunits_cutext_check_if_amount_single:N #1
+\cs_new:Npn \__cookingunits_cutext_post_process_fraction_input:NNN #1#2#3
{
- \fp_compare:nNnTF {#1} = { 1.0 }
- { \bool_set_true:N } { \bool_set_false:N }
- \l__cookingunits_cutext_last_amount_equ_one_bool
+ \__cookingunits_culang_let:nnN { pluraltest } { fraction } \l__cookingunits_translation_tmpa_tl
+ \use:c { __cookingunits_pluraltest_fraction_ \l__cookingunits_translation_tmpa_tl :NNN } #1#2#3
}
\cs_new:Npn \__cookingunits_check_if_integer_can_be_numerals:NN #1#2
{
@@ -2563,6 +2588,27 @@
\l__cookingunits_phrase_text_tl
}
}
+\cs_new:Npn \cookingunits_print_fraction:nnn #1#2#3
+ {
+ \group_begin:
+ \__cookingunits_set_amount:Nn \l__cookingunits_mixed_fraction_tl {#1}
+ \__cookingunits_set_amount:Nn \l__cookingunits_number_tmpa_tl {#2}
+ \__cookingunits_set_amount:Nn \l__cookingunits_number_tmpb_tl {#3}
+ \__cookingunits_print_fractions:Nnn
+ \l__cookingunits_mixed_fraction_tl
+ \l__cookingunits_number_tmpa_tl
+ \l__cookingunits_number_tmpb_tl
+ \group_end:
+ }
+\cs_new:Npn \cookingunits_print_range:nn #1#2
+ {
+ \group_begin:
+ \__cookingunits_set_cmd_type_to:n { cunum }
+ #1
+ \__cookingunits_print_range_sign:
+ #2
+ \group_end:
+ }
%% To be deleted. In order to remove error messages.
\NewDocumentCommand \cudefinekeys { m m }
@@ -3208,6 +3254,63 @@
\__cookingunits_parse_definename_start_cycle:
}
\cs_generate_variant:Nn \__cookingunits_parse_name_finish_cycle_and_start_new:nn { VV }
+\__cookingunits_culang_def_base:nnn { pluraltest } { normal } { \c__cookingunits_no_translation_str }
+\__cookingunits_culang_def_base:nnn { pluraltest } { range } { \c__cookingunits_no_translation_str }
+\__cookingunits_culang_def_base:nnn { pluraltest } { fraction } { \c__cookingunits_no_translation_str }
+\cs_set:cpn { __cookingunits_pluraltest_normal_ \c__cookingunits_no_translation_str :N } #1
+ {
+ \fp_compare:nNnTF {#1} = { 1.0 }
+ { \bool_set_true:N } { \bool_set_false:N }
+ \l__cookingunits_cutext_use_single_bool
+ }
+\cs_set:cpn { __cookingunits_pluraltest_range_ \c__cookingunits_no_translation_str :NN } #1#2
+ {
+ \fp_compare:nNnTF {#2} = { 1.0 }
+ { \bool_set_true:N } { \bool_set_false:N }
+ \l__cookingunits_cutext_use_single_bool
+ }
+\cs_set:cpn { __cookingunits_pluraltest_fraction_ \c__cookingunits_no_translation_str :NNN } #1#2#3
+ {
+ \tl_if_empty:NTF #1
+ { \fp_compare:nNnTF {#2} = { 1.0 } } { \use_ii:nn }
+ { \bool_set_true:N } { \bool_set_false:N }
+ \l__cookingunits_cutext_use_single_bool
+ }
+\cs_new:Npn \__cookingunits_pluraltest_define:nn #1#2
+ {
+ \__cookingunits_culang_def_for:nnnn {#1} { pluraltest } { normal } {#1}
+ \cs_set:cpn { __cookingunits_pluraltest_normal_ #1 :N } ##1 {#2}
+ }
+\cs_new:Npn \__cookingunits_pluraltest_define_range:nn #1#2
+ {
+ \__cookingunits_culang_def_for:nnnn {#1} { pluraltest } { range } {#1}
+ \cs_set:cpn { __cookingunits_pluraltest_range_ #1 :NN } ##1##2 {#2}
+ }
+\cs_new:Npn \__cookingunits_pluraltest_define_fraction:nn #1#2
+ {
+ \__cookingunits_culang_def_for:nnnn {#1} { pluraltest } { fraction } {#1}
+ \cs_set:cpn { __cookingunits_pluraltest_fraction_ #1 :NNN } ##1##2##3 {#2}
+ }
+\__cookingunits_pluraltest_define:nn { French }
+ {
+ \fp_compare:nNnTF { \fp_abs:n {#1} } < { 2.0 }
+ { \bool_set_true:N } { \bool_set_false:N }
+ \l__cookingunits_cutext_use_single_bool
+ }
+\__cookingunits_pluraltest_define_range:nn { French }
+ {
+ \fp_compare:nNnTF { \fp_abs:n {#2} } < { 2.0 }
+ { \bool_set_true:N } { \bool_set_false:N }
+ \l__cookingunits_cutext_use_single_bool
+ }
+\__cookingunits_pluraltest_define_fraction:nn { French }
+ {
+ \quark_if_nil:NTF #1
+ { \fp_compare:nNnTF { #2/#3 } < { 2.0 } }
+ { \fp_compare:nNnTF { #1 + #2/#3 } < { 2.0 } }
+ { \bool_set_true:N } { \bool_set_false:N }
+ \l__cookingunits_cutext_use_single_bool
+ }
\NewDocumentCommand \cudefinesymbol { m m }
{
\tl_set:Nn \l__cookingunits_language_tl {#1}
@@ -3684,8 +3787,8 @@
{
{ kg } { kilogramme } [ kilogrammes ]
{ dag } { d\'{e}cagramme } [ d\'{e}cagrammes]
- { g } { gramme } [ gramme ]
- { oz } { once } < f >
+ { g } { gramme } [ grammes ]
+ { oz } { once } [ onces ] < f >
{ lb } { livre } [ livres ] < f >
{ d } { jour } [ jours ]
{ h } { heure } [ heures ] < f >
@@ -3704,15 +3807,15 @@
{ dl } [ dL ] { d\'{e}cilitre } [ d\'{e}cilitres ]
{ cl } [ cL ] { centilitre } [ centilitres ]
{ ml } [ mL ] { millilitre } [ millilitres ]
- { cal } { calorie } [ calorie ]
- { kcal } { kilocalorie } [ kilocalories ]
+ { cal } { calorie } [ calories ] < f >
+ { kcal } { kilocalorie } [ kilocalories ] < f >
{ J } { joule } [ joules ]
{ kJ } { kilojoule } [ kilojoules ]
{ eV } { \'{e}lectron-volt } [ \'{e}lectron-volts ]
- { pn } { pinc\'{e}e } < f >
- { EL } [c.\`{a}.s.] { cuill\`{e}re \space \`{a} \space soupe } < f >
- { TL } [c.\`{a}.c.] { cuill\`{e}re \space \`{a} \space caf\'{e} } < f >
- { decimal-mark } { . }
+ { pn } [ pinc\'{e}e ] { pinc\'{e}e } [ pinc\'{e}es ] < f >
+ { EL } [c.\`{a}.s.] { cuill\`{e}re \space \`{a} \space soupe } [ cuill\`{e}res \space \`{a} \space soupe ] < f >
+ { TL } [c.\`{a}.c.] { cuill\`{e}re \space \`{a} \space caf\'{e} } [ cuill\`{e}res \space \`{a} \space caf\'{e} ] < f >
+ { decimal-mark } { , }
{ one (m) } { un }
{ one (f) } { une }
{ one (n) } { un }