diff options
author | Karl Berry <karl@freefriends.org> | 2018-05-13 21:53:50 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2018-05-13 21:53:50 +0000 |
commit | 55be422dc01e60cfae781a9a4a310a96c9e99256 (patch) | |
tree | b14b9bb277ef27dd73b7c28fa74939f6f0eb72d7 /Master/texmf-dist/source/latex/tracklang | |
parent | 0596b70ef858295d6f164ff4603a889c42876365 (diff) |
tracklang (13may18)
git-svn-id: svn://tug.org/texlive/trunk@47704 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/tracklang')
-rw-r--r-- | Master/texmf-dist/source/latex/tracklang/tracklang.dtx | 198 | ||||
-rw-r--r-- | Master/texmf-dist/source/latex/tracklang/tracklang.ins | 2 |
2 files changed, 152 insertions, 48 deletions
diff --git a/Master/texmf-dist/source/latex/tracklang/tracklang.dtx b/Master/texmf-dist/source/latex/tracklang/tracklang.dtx index b63bb9e3dec..3c809a3d6db 100644 --- a/Master/texmf-dist/source/latex/tracklang/tracklang.dtx +++ b/Master/texmf-dist/source/latex/tracklang/tracklang.dtx @@ -2,15 +2,15 @@ % tracklang.dtx generated using makedtx version 1.2 (c) Nicola Talbot % Command line args: % -section "chapter" -% -doc "tracklang-manual.tex" % -author "Nicola Talbot" % -src "tracklang.sty\Z=>tracklang.sty" % -src "tracklang.tex\Z=>tracklang.tex" % -src "tracklang-region-codes.tex\Z=>tracklang-region-codes.tex" % -src "tracklang-scripts.sty\Z=>tracklang-scripts.sty" % -src "tracklang-scripts.tex\Z=>tracklang-scripts.tex" +% -doc "tracklang-manual.tex" % tracklang -% Created on 2018/2/21 13:08 +% Created on 2018/5/13 13:19 %\fi %\iffalse %<*package> @@ -59,7 +59,7 @@ pdfauthor={Nicola L.C. Talbot}, pdftitle={tracklang: tracking language options}]{hyperref} -\CheckSum{3914} +\CheckSum{3961} \appto\MacroFont{\scriptsize} \renewcommand*{\usage}[1]{\textit{\hyperpage{#1}}} @@ -278,11 +278,11 @@ and~\ref{tab:nonisoopts}} % %\MakeShortVerb{"} % -%\title{tracklang v1.3.5: +%\title{tracklang v1.3.6: %tracking language options} %\author{Nicola L. C. Talbot\\\url{http://www.dickimaw-books.com/}} % -%\date{2018-02-21} +%\date{2018-05-13} %\maketitle % %\begin{abstract} @@ -1351,14 +1351,26 @@ and~\ref{tab:nonisoopts}} %to the tracked language list, if it's not already present.) % %If you want to find out if any of the tracked dialects -%match a particular language tag, you can use: +%matches a particular language tag, you can use: %\begin{definition}[\DescribeMacro\GetTrackedDialectFromLanguageTag] -%\cs{GetTrackedDialectFromLanguageTag}\marg{tag}\marg{cs} +%\ics{GetTrackedDialectFromLanguageTag}\marg{tag}\marg{cs} %\end{definition} %If successful, the supplied control sequence \meta{cs} is set to the -%dialect label, otherwise \meta{cs} is set to empty. Note that the -%extension (that is, the option part that may occur at the end of -%the tag) isn't used in the comparison. +%dialect label, otherwise \meta{cs} is set to empty. The test is for an exact +%match on the root language, script, sub-language, variant and +%region. The control sequence \meta{cs} will be empty if none of the +%tracked dialects matches all five of those elements. (If the script +%isn't given explicitly, the default for that language is assumed.) +%In the event that \meta{cs} is empty, you can now (as from v1.3.6) +%get the closest match with +%\begin{definition}[\DescribeMacro\TrackedDialectClosestSubMatch] +%\ics{TrackedDialectClosestSubMatch} +%\end{definition} +%(which is set by \cs{GetTrackedDialectFromLanguageTag}). +%This will be empty if no tracked dialects match on the root +%language or if there's a tracked dialect label that exactly matches +%the label formed by concatenating the language code, sub-language, +%script, region, modifier and variant. % %For example (Plain \TeX): %\begin{verbatim} @@ -1381,6 +1393,30 @@ and~\ref{tab:nonisoopts}} %It also works if the dialect has been tracked using other commands, %such as \cs{TrackLocale}. % +%Here's an example that doesn't have an exact match, but does have a +%partial match: +%\begin{verbatim} +%\input tracklang +%\TrackLanguageTag{de-CH-1996} +%Has de-DE-1996 been tracked? +%\GetTrackedDialectFromLanguageTag{de-DE-1996}{\thisdialect}% +%\ifx\thisdialect\empty +% No! +% \ifx\TrackedDialectClosestSubMatch\empty +% No match on root language. +% \else +% Closest match: \TrackedDialectClosestSubMatch. +% \fi +%\else +% Yes! Dialect label: \thisdialect. +%\fi +%\bye +%\end{verbatim} +%In this case the result is: +%\begin{quote} +%Has de-DE-1996 been tracked? No! Closest match: nswissgerman. +%\end{quote} +% %You can iterate through each tracked dialect using: %\begin{definition}[\DescribeMacro\ForEachTrackedDialect] %\cs{ForEachTrackedDialect}\marg{cs}\marg{code} @@ -3214,7 +3250,7 @@ and~\ref{tab:nonisoopts}} % packages such as \styfmt{etoolbox}. % \begin{macrocode} \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{tracklang}[2018/02/21 v1.3.5 (NLCT) Track Languages] +\ProvidesPackage{tracklang}[2018/05/13 v1.3.6 (NLCT) Track Languages] % \end{macrocode} %\begin{macro}{\@tracklang@declareoption} % Set up package options. @@ -3492,7 +3528,7 @@ and~\ref{tab:nonisoopts}} % Version info. % \begin{macrocode} \expandafter\def\csname ver@tracklang.tex\endcsname{% - 2018/02/21 v1.3.5 (NLCT) Track Languages Generic Code} + 2018/05/13 v1.3.6 (NLCT) Track Languages Generic Code} % \end{macrocode} % Define a long command for determining the existence of a control % sequence by its name. (\cs{relax} is considered undefined.) @@ -6012,10 +6048,18 @@ and~\ref{tab:nonisoopts}} %\end{definition} %Find the tracked dialect that matches the given language tag and %stores the dialect label in \meta{cs}. If no match found, \meta{cs} -%will be empty. Doesn't check the additional information +%will be empty. Just tests the root language, script, variant, +%sub-language and region. Doesn't check the additional information. +%As from v1.3.6, this sets \cs{TrackedDialectClosestSubMatch} to the +%closest sub-match. % \begin{macrocode} \def\GetTrackedDialectFromLanguageTag#1#2{% +% \end{macrocode} +%Initialise default values (in case of no match). +%\changes{1.3.6}{2018-05-13}{added \cs{TrackedDialectClosestSubMatch}} +% \begin{macrocode} \def#2{}% + \def\TrackedDialectClosestSubMatch{}% \@tracklang@parselangtag{#1}% \edef\@tracklang@dialect{% \@TrackLangEnvLang @@ -6027,14 +6071,14 @@ and~\ref{tab:nonisoopts}} % \end{macrocode} % Has this dialect label been tracked? % \begin{macrocode} - \IfTrackedDialect{\@tracklang@dialect}% - {% + \IfTrackedDialect{\@tracklang@dialect}% + {% % \end{macrocode} % Found it. All done. % \begin{macrocode} \let#2\@tracklang@dialect - }% - {% + }% + {% % \end{macrocode} % Get the root language label. % \begin{macrocode} @@ -6044,6 +6088,10 @@ and~\ref{tab:nonisoopts}} % \begin{macrocode} \edef\@tracklang@defscript{\TrackLangGetDefaultScript\@tracklang@lang}% % \end{macrocode} +% Keep track of best match. +% \begin{macrocode} + \def\@tracklang@bestmatch{0}% +% \end{macrocode} % Get the list of tracked dialects for this language. % \begin{macrocode} \edef\@tracklang@dialects{\TrackedDialectsFromLanguage\@tracklang@lang}% @@ -6051,54 +6099,110 @@ and~\ref{tab:nonisoopts}} % For each dialect in this list, check if it matches. % \begin{macrocode} \@tracklang@for\@tracklang@dialect:=\@tracklang@dialects\do{% +% \end{macrocode} +% Does the script match? (Initialise to no.) +% \begin{macrocode} + \def\@tracklang@currentmatch{0}% \edef\@tracklang@tmp{% - \TrackedIsoCodeFromLanguage{3166-1}{\@tracklang@dialect}}% - \ifx\@tracklang@tmp\@TrackLangEnvTerritory + \GetTrackedDialectScript{\@tracklang@dialect}}% + \ifx\@tracklang@tmp\@TrackLangEnvScript % \end{macrocode} -% Region matches. +% Script matches. +% \begin{macrocode} + \def\@tracklang@currentmatch{1}% + \else +% \end{macrocode} +% Script doesn't match. If no script has been provided, does this +% dialect's script match the default for this language? % \begin{macrocode} - \edef\@tracklang@tmp{% - \GetTrackedDialectSubLang{\@tracklang@dialect}}% - \ifx\@tracklang@tmp\@TrackLangEnvSubLang + \ifx\@TrackLangEnvScript\empty + \ifx\@tracklang@tmp\@tracklang@defscript +% \end{macrocode} +% Default script matches. +% \begin{macrocode} + \def\@tracklang@currentmatch{1}% + \fi + \fi + \fi +% \end{macrocode} +% Does the sub-language match? +% \begin{macrocode} + \edef\@tracklang@tmp{% + \GetTrackedDialectSubLang{\@tracklang@dialect}}% + \ifx\@tracklang@tmp\@TrackLangEnvSubLang % \end{macrocode} % Sub-language matches. % \begin{macrocode} - \edef\@tracklang@tmp{% - \GetTrackedDialectVariant{\@tracklang@dialect}}% - \ifx\@tracklang@tmp\@TrackLangEnvVariant + \edef\@tracklang@currentmatch{\@tracklang@currentmatch 1}% + \else +% \end{macrocode} +% Sub-language doesn't match. +% \begin{macrocode} + \edef\@tracklang@currentmatch{\@tracklang@currentmatch 0}% + \fi +% \end{macrocode} +% Does the variant match? +% \begin{macrocode} + \edef\@tracklang@tmp{% + \GetTrackedDialectVariant{\@tracklang@dialect}}% + \ifx\@tracklang@tmp\@TrackLangEnvVariant % \end{macrocode} % Variant matches. % \begin{macrocode} - \edef\@tracklang@tmp{% - \GetTrackedDialectScript{\@tracklang@dialect}}% - \ifx\@tracklang@tmp\@TrackLangEnvScript + \edef\@tracklang@currentmatch{\@tracklang@currentmatch 1}% + \else % \end{macrocode} -% Script matches. Found it. +% Variant doesn't match. % \begin{macrocode} - \let#2\@tracklang@dialect - \else + \edef\@tracklang@currentmatch{\@tracklang@currentmatch 0}% + \fi % \end{macrocode} -% Script doesn't match. If no script has been provided, does this -% dialect's script match the default for this language? +% Does the region match? % \begin{macrocode} - \ifx\@TrackLangEnvScript\empty - \ifx\@tracklang@tmp\@tracklang@defscript + \edef\@tracklang@tmp{% + \TrackedIsoCodeFromLanguage{3166-1}{\@tracklang@dialect}}% + \ifx\@tracklang@tmp\@TrackLangEnvTerritory % \end{macrocode} -% Default script matches. Found it. +% Region matches. % \begin{macrocode} - \let#2\@tracklang@dialect - \fi - \fi - \fi - \fi + \edef\@tracklang@currentmatch{\@tracklang@currentmatch 1}% + \else +% \end{macrocode} +% Region doesn't match. +% \begin{macrocode} + \edef\@tracklang@currentmatch{\@tracklang@currentmatch 0}% + \fi +% \end{macrocode} +% Do all four match? +% \begin{macrocode} + \ifx\@tracklang@currentmatch\@tracklang@fullmatch +% \end{macrocode} +% Found it. +% \begin{macrocode} + \let#2\@tracklang@dialect + \else +% \end{macrocode} +% Not a complete match. Is this the best match so far? +% \begin{macrocode} + \ifnum\@tracklang@currentmatch>\@tracklang@bestmatch\relax + \let\TrackedDialectClosestSubMatch\@tracklang@dialect + \let\@tracklang@bestmatch\@tracklang@currentmatch \fi \fi - }% - }% + }% + }% } % \end{macrocode} %\end{macro} % +%\begin{macro}{\@tracklang@fullmatch} +%\changes{1.3.6}{2018-05-13}{new} +%(Used to identify a full match for script, sub-language, variant +%and region.) +% \begin{macrocode} +\def\@tracklang@fullmatch{1111} +% \end{macrocode} +%\end{macro} % %\begin{macro}{\TrackLangFromEnv} %\changes{1.3}{2016-10-07}{new} @@ -9956,7 +10060,7 @@ and~\ref{tab:nonisoopts}} % Version info. % \begin{macrocode} \expandafter\def\csname ver@tracklang-region-codes.tex\endcsname{% - 2018/02/21 v1.3.5 (NLCT) Track Languages Regions}% + 2018/05/13 v1.3.6 (NLCT) Track Languages Regions}% % \end{macrocode} % %\begin{macro}{\TrackLangRegionMap} @@ -10345,7 +10449,7 @@ and~\ref{tab:nonisoopts}} %\changes{1.3}{2016-10-07}{added tracklang-scripts.sty} % \begin{macrocode} \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{tracklang-scripts}[2018/02/21 v1.3.5 (NLCT) Track +\ProvidesPackage{tracklang-scripts}[2018/05/13 v1.3.6 (NLCT) Track Language Scripts (LaTeX)] \RequirePackage{tracklang} \input{tracklang-scripts} @@ -10387,7 +10491,7 @@ Language Scripts (LaTeX)] % Version info. % \begin{macrocode} \expandafter\def\csname ver@tracklang-scripts.tex\endcsname{% - 2018/02/21 v1.3.5 (NLCT) Track Languages Scripts (Generic)}% + 2018/05/13 v1.3.6 (NLCT) Track Languages Scripts (Generic)}% % \end{macrocode} % %\begin{macro}{\TrackLangScriptsMap} diff --git a/Master/texmf-dist/source/latex/tracklang/tracklang.ins b/Master/texmf-dist/source/latex/tracklang/tracklang.ins index e2937f28d02..f5a8158e68b 100644 --- a/Master/texmf-dist/source/latex/tracklang/tracklang.ins +++ b/Master/texmf-dist/source/latex/tracklang/tracklang.ins @@ -1,4 +1,4 @@ -% tracklang.ins generated using makedtx version 1.2 2018/2/21 13:08 +% tracklang.ins generated using makedtx version 1.2 2018/5/13 13:19 \input docstrip \preamble |