| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
% File: iflang.dtx |
| 4 |
% Version: 2018/01/21 v1.7 |
| 5 |
% Info: Checks for the current language |
| 6 |
% |
| 7 |
% Copyright (C) |
| 8 |
% 2007 Heiko Oberdiek |
| 9 |
% 2016-2019 Oberdiek Package Support Group |
| 10 |
% https://github.com/ho-tex/oberdiek/issues |
| 11 |
% |
| 12 |
% This work may be distributed and/or modified under the |
| 13 |
% conditions of the LaTeX Project Public License, either |
| 14 |
% version 1.3c of this license or (at your option) any later |
| 15 |
% version. This version of this license is in |
| 16 |
% https://www.latex-project.org/lppl/lppl-1-3c.txt |
| 17 |
% and the latest version of this license is in |
| 18 |
% https://www.latex-project.org/lppl.txt |
| 19 |
% and version 1.3 or later is part of all distributions of |
| 20 |
% LaTeX version 2005/12/01 or later. |
| 21 |
% |
| 22 |
% This work has the LPPL maintenance status "maintained". |
| 23 |
% |
| 24 |
% The Current Maintainers of this work are |
| 25 |
% Heiko Oberdiek and the Oberdiek Package Support Group |
| 26 |
% https://github.com/ho-tex/oberdiek/issues |
| 27 |
% |
| 28 |
% The Base Interpreter refers to any `TeX-Format', |
| 29 |
% because some files are installed in TDS:tex/generic//. |
| 30 |
% |
| 31 |
% This work consists of the main source file iflang.dtx |
| 32 |
% and the derived files |
| 33 |
% iflang.sty, iflang.pdf, iflang.ins, iflang.drv, iflang-test1.tex, |
| 34 |
% iflang-test2.tex, iflang-test3.tex, iflang-test4.tex, |
| 35 |
% iflang-test5.tex. |
| 36 |
% |
| 37 |
% Distribution: |
| 38 |
% CTAN:macros/latex/contrib/oberdiek/iflang.dtx |
| 39 |
% CTAN:macros/latex/contrib/oberdiek/iflang.pdf |
| 40 |
% |
| 41 |
% Unpacking: |
| 42 |
% (a) If iflang.ins is present: |
| 43 |
% tex iflang.ins |
| 44 |
% (b) Without iflang.ins: |
| 45 |
% tex iflang.dtx |
| 46 |
% (c) If you insist on using LaTeX |
| 47 |
% latex \let\install=y\input{iflang.dtx} |
| 48 |
% (quote the arguments according to the demands of your shell) |
| 49 |
% |
| 50 |
% Documentation: |
| 51 |
% (a) If iflang.drv is present: |
| 52 |
% latex iflang.drv |
| 53 |
% (b) Without iflang.drv: |
| 54 |
% latex iflang.dtx; ... |
| 55 |
% The class ltxdoc loads the configuration file ltxdoc.cfg |
| 56 |
% if available. Here you can specify further options, e.g. |
| 57 |
% use A4 as paper format: |
| 58 |
% \PassOptionsToClass{a4paper}{article} |
| 59 |
% |
| 60 |
% Program calls to get the documentation (example): |
| 61 |
% pdflatex iflang.dtx |
| 62 |
% makeindex -s gind.ist iflang.idx |
| 63 |
% pdflatex iflang.dtx |
| 64 |
% makeindex -s gind.ist iflang.idx |
| 65 |
% pdflatex iflang.dtx |
| 66 |
% |
| 67 |
% Installation: |
| 68 |
% TDS:tex/generic/oberdiek/iflang.sty |
| 69 |
% TDS:doc/latex/oberdiek/iflang.pdf |
| 70 |
% TDS:source/latex/oberdiek/iflang.dtx |
| 71 |
% |
| 72 |
%<*ignore> |
| 73 |
\begingroup |
| 74 |
\catcode123=1 % |
| 75 |
\catcode125=2 % |
| 76 |
\def\x{LaTeX2e}% |
| 77 |
\expandafter\endgroup |
| 78 |
\ifcase 0\ifx\install y1\fi\expandafter |
| 79 |
\ifx\csname processbatchFile\endcsname\relax\else1\fi |
| 80 |
\ifx\fmtname\x\else 1\fi\relax |
| 81 |
\else\csname fi\endcsname |
| 82 |
%</ignore> |
| 83 |
%<*install> |
| 84 |
\input docstrip.tex |
| 85 |
\Msg{************************************************************************} |
| 86 |
\Msg{* Installation} |
| 87 |
\Msg{* Package: iflang 2018/01/21 v1.7 Checks for the current language (HO)} |
| 88 |
\Msg{************************************************************************} |
| 89 |
|
| 90 |
\keepsilent |
| 91 |
\askforoverwritefalse |
| 92 |
|
| 93 |
\let\MetaPrefix\relax |
| 94 |
\preamble |
| 95 |
|
| 96 |
This is a generated file. |
| 97 |
|
| 98 |
Project: iflang |
| 99 |
Version: 2018/01/21 v1.7 |
| 100 |
|
| 101 |
Copyright (C) |
| 102 |
2007 Heiko Oberdiek |
| 103 |
2016-2019 Oberdiek Package Support Group |
| 104 |
|
| 105 |
This work may be distributed and/or modified under the |
| 106 |
conditions of the LaTeX Project Public License, either |
| 107 |
version 1.3c of this license or (at your option) any later |
| 108 |
version. This version of this license is in |
| 109 |
https://www.latex-project.org/lppl/lppl-1-3c.txt |
| 110 |
and the latest version of this license is in |
| 111 |
https://www.latex-project.org/lppl.txt |
| 112 |
and version 1.3 or later is part of all distributions of |
| 113 |
LaTeX version 2005/12/01 or later. |
| 114 |
|
| 115 |
This work has the LPPL maintenance status "maintained". |
| 116 |
|
| 117 |
The Current Maintainers of this work are |
| 118 |
Heiko Oberdiek and the Oberdiek Package Support Group |
| 119 |
https://github.com/ho-tex/oberdiek/issues |
| 120 |
|
| 121 |
|
| 122 |
The Base Interpreter refers to any `TeX-Format', |
| 123 |
because some files are installed in TDS:tex/generic//. |
| 124 |
|
| 125 |
This work consists of the main source file iflang.dtx |
| 126 |
and the derived files |
| 127 |
iflang.sty, iflang.pdf, iflang.ins, iflang.drv, iflang-test1.tex, |
| 128 |
iflang-test2.tex, iflang-test3.tex, iflang-test4.tex, |
| 129 |
iflang-test5.tex. |
| 130 |
|
| 131 |
\endpreamble |
| 132 |
\let\MetaPrefix\DoubleperCent |
| 133 |
|
| 134 |
\generate{% |
| 135 |
\file{iflang.ins}{\from{iflang.dtx}{install}}% |
| 136 |
\file{iflang.drv}{\from{iflang.dtx}{driver}}% |
| 137 |
\usedir{tex/generic/oberdiek}% |
| 138 |
\file{iflang.sty}{\from{iflang.dtx}{package}}% |
| 139 |
% \usedir{doc/latex/oberdiek/test}% |
| 140 |
% \file{iflang-test1.tex}{\from{iflang.dtx}{test1}}% |
| 141 |
% \file{iflang-test2.tex}{\from{iflang.dtx}{test2}}% |
| 142 |
% \file{iflang-test3.tex}{\from{iflang.dtx}{test3}}% |
| 143 |
% \file{iflang-test4.tex}{\from{iflang.dtx}{test4}}% |
| 144 |
% \file{iflang-test5.tex}{\from{iflang.dtx}{test5}}% |
| 145 |
} |
| 146 |
|
| 147 |
\catcode32=13\relax% active space |
| 148 |
\let =\space% |
| 149 |
\Msg{************************************************************************} |
| 150 |
\Msg{*} |
| 151 |
\Msg{* To finish the installation you have to move the following} |
| 152 |
\Msg{* file into a directory searched by TeX:} |
| 153 |
\Msg{*} |
| 154 |
\Msg{* iflang.sty} |
| 155 |
\Msg{*} |
| 156 |
\Msg{* To produce the documentation run the file `iflang.drv'} |
| 157 |
\Msg{* through LaTeX.} |
| 158 |
\Msg{*} |
| 159 |
\Msg{* Happy TeXing!} |
| 160 |
\Msg{*} |
| 161 |
\Msg{************************************************************************} |
| 162 |
|
| 163 |
\endbatchfile |
| 164 |
%</install> |
| 165 |
%<*ignore> |
| 166 |
\fi |
| 167 |
%</ignore> |
| 168 |
%<*driver> |
| 169 |
\NeedsTeXFormat{LaTeX2e} |
| 170 |
\ProvidesFile{iflang.drv}% |
| 171 |
[2018/01/21 v1.7 Checks for the current language (HO)]% |
| 172 |
\documentclass{ltxdoc} |
| 173 |
\usepackage{holtxdoc}[2011/11/22] |
| 174 |
\begin{document} |
| 175 |
\DocInput{iflang.dtx}% |
| 176 |
\end{document} |
| 177 |
%</driver> |
| 178 |
% \fi |
| 179 |
% |
| 180 |
% |
| 181 |
% |
| 182 |
% \GetFileInfo{iflang.drv} |
| 183 |
% |
| 184 |
% \title{The \xpackage{iflang} package} |
| 185 |
% \date{2018/01/21 v1.7} |
| 186 |
% \author{Heiko Oberdiek\thanks |
| 187 |
% {Please report any issues at \url{https://github.com/ho-tex/oberdiek/issues}}} |
| 188 |
% |
| 189 |
% \maketitle |
| 190 |
% |
| 191 |
% \begin{abstract} |
| 192 |
% This package provides expandible checks for the current language |
| 193 |
% based on macro \cs{languagename} or hyphenation patterns. |
| 194 |
% \end{abstract} |
| 195 |
% |
| 196 |
% \tableofcontents |
| 197 |
% |
| 198 |
% \section{Documentation} |
| 199 |
% |
| 200 |
% Package \xpackage{babel} defines \cs{iflanguagename}. As first |
| 201 |
% argument it takes a language name and executes the second or |
| 202 |
% third argument depending on the current language. This |
| 203 |
% language test is based on hyphenation patterns. However, it |
| 204 |
% is possible that different languages or dialects share the |
| 205 |
% same patterns. In such cases \cs{iflanguagename} fails. |
| 206 |
% |
| 207 |
% However, package \xpackage{babel} and some other packages |
| 208 |
% such as \xpackage{german} or \xpackage{ngerman} store |
| 209 |
% the language name in the macro \cs{languagename} if |
| 210 |
% \cs{selectlanguage} is called. |
| 211 |
% |
| 212 |
% \begin{declcs}{IfLanguageName} \M{lang} \M{then} \M{else} |
| 213 |
% \end{declcs} |
| 214 |
% Macro \cs{IfLanguageName} compares language \meta{lang} with |
| 215 |
% the current setting of macro \cs{languagename}. If both |
| 216 |
% contains the same name then the \meta{then} part is called, |
| 217 |
% otherwise the \meta{else} part. |
| 218 |
% |
| 219 |
% The macro is expandable. Thus it can be safely used inside \cs{edef} |
| 220 |
% or \cs{csname}. If case of errors like an undefined \cs{languagename} |
| 221 |
% the \meta{else} part is executed. |
| 222 |
% |
| 223 |
% Note: Macro \cs{IfLanguageName} relies on the fact, that |
| 224 |
% \cs{languagename} is set correctly: |
| 225 |
% \begin{description} |
| 226 |
% \item[Package \xpackage{babel}:] |
| 227 |
% \mbox{}\\ |
| 228 |
% Full support of \cs{languagename} in its language switching commands. |
| 229 |
% \item[Format based on \xpackage{babel} (\xfile{language.dat}):] |
| 230 |
% \mbox{}\\ |
| 231 |
% If package \xpackage{babel} is not used (or not yet loaded), |
| 232 |
% then \xpackage{babel}'s |
| 233 |
% \xfile{hyphen.cfg} has set \cs{languagename} to the last |
| 234 |
% language in \xfile{language.dat}, but \cs{language} (current |
| 235 |
% patterns) is zero and points to the first language. |
| 236 |
% Thus the value of \cs{languagename} is basically garbage. |
| 237 |
% Package \xpackage{iflang} warns if \cs{languagename} and |
| 238 |
% \cs{language} do not fit. |
| 239 |
% This can be fixed by loading package \xpackage{babel} previously. |
| 240 |
% \item[Format based on \eTeX's \xfile{etex.src} (\xfile{language.def}):] |
| 241 |
% \mbox{}\\ |
| 242 |
% Unhappily it does not support |
| 243 |
% \cs{languagename}. Thus this package hooks into \cs{uselanguage} |
| 244 |
% to get \cs{languagename} defined and updated there. |
| 245 |
% At package loading time the changed \cs{uselanguage} has not |
| 246 |
% been called yet. Thus package \xpackage{iflang} tries |
| 247 |
% |USenglish|. This is the definite default language of \xfile{etex.src}. |
| 248 |
% If the current patterns suit this default language, an |
| 249 |
% undefined \cs{languagename} is set to this language. Otherwise |
| 250 |
% a \cs{languagename} remains undefined and a warning is given. |
| 251 |
% \end{description} |
| 252 |
% |
| 253 |
% \begin{declcs}{IfLanguagePatterns} \M{lang} \M{then} \M{else} |
| 254 |
% \end{declcs} |
| 255 |
% This macro behaves similar to \cs{IfLanguageName}. But the |
| 256 |
% language test is based on the current pattern in force (\cs{language}). |
| 257 |
% Also this macro is expandable, in case of errors the \meta{else} part |
| 258 |
% is called. |
| 259 |
% |
| 260 |
% The following naming convention for the pattern are supported: |
| 261 |
% \begin{description} |
| 262 |
% \item[\xpackage{babel}/\xfile{language.dat}]: |
| 263 |
% \cs{l@}\meta{language} |
| 264 |
% \item[\xpackage{etex.src}/\xfile{language.def}]: |
| 265 |
% \cs{lang@}\meta{language} |
| 266 |
% \end{description} |
| 267 |
% Package \xpackage{iflang} looks for \cs{et@xpatterns} (defined in |
| 268 |
% \xfile{etex.src}) to find out the naming convention in use. |
| 269 |
% |
| 270 |
% \StopEventually{ |
| 271 |
% } |
| 272 |
% |
| 273 |
% \section{Implementation} |
| 274 |
% |
| 275 |
% \begin{macrocode} |
| 276 |
%<*package> |
| 277 |
% \end{macrocode} |
| 278 |
% |
| 279 |
% \subsection{Reload check and package identification} |
| 280 |
% Reload check, especially if the package is not used with \LaTeX. |
| 281 |
% \begin{macrocode} |
| 282 |
\begingroup\catcode61\catcode48\catcode32=10\relax% |
| 283 |
\catcode13=5 % ^^M |
| 284 |
\endlinechar=13 % |
| 285 |
\catcode35=6 % # |
| 286 |
\catcode39=12 % ' |
| 287 |
\catcode44=12 % , |
| 288 |
\catcode45=12 % - |
| 289 |
\catcode46=12 % . |
| 290 |
\catcode58=12 % : |
| 291 |
\catcode64=11 % @ |
| 292 |
\catcode123=1 % { |
| 293 |
\catcode125=2 % } |
| 294 |
\expandafter\let\expandafter\x\csname [email protected]\endcsname |
| 295 |
\ifx\x\relax % plain-TeX, first loading |
| 296 |
\else |
| 297 |
\def\empty{}% |
| 298 |
\ifx\x\empty % LaTeX, first loading, |
| 299 |
% variable is initialized, but \ProvidesPackage not yet seen |
| 300 |
\else |
| 301 |
\expandafter\ifx\csname PackageInfo\endcsname\relax |
| 302 |
\def\x#1#2{% |
| 303 |
\immediate\write-1{Package #1 Info: #2.}% |
| 304 |
}% |
| 305 |
\else |
| 306 |
\def\x#1#2{\PackageInfo{#1}{#2, stopped}}% |
| 307 |
\fi |
| 308 |
\x{iflang}{The package is already loaded}% |
| 309 |
\aftergroup\endinput |
| 310 |
\fi |
| 311 |
\fi |
| 312 |
\endgroup% |
| 313 |
% \end{macrocode} |
| 314 |
% Package identification: |
| 315 |
% \begin{macrocode} |
| 316 |
\begingroup\catcode61\catcode48\catcode32=10\relax% |
| 317 |
\catcode13=5 % ^^M |
| 318 |
\endlinechar=13 % |
| 319 |
\catcode35=6 % # |
| 320 |
\catcode39=12 % ' |
| 321 |
\catcode40=12 % ( |
| 322 |
\catcode41=12 % ) |
| 323 |
\catcode44=12 % , |
| 324 |
\catcode45=12 % - |
| 325 |
\catcode46=12 % . |
| 326 |
\catcode47=12 % / |
| 327 |
\catcode58=12 % : |
| 328 |
\catcode64=11 % @ |
| 329 |
\catcode91=12 % [ |
| 330 |
\catcode93=12 % ] |
| 331 |
\catcode123=1 % { |
| 332 |
\catcode125=2 % } |
| 333 |
\expandafter\ifx\csname ProvidesPackage\endcsname\relax |
| 334 |
\def\x#1#2#3[#4]{\endgroup |
| 335 |
\immediate\write-1{Package: #3 #4}% |
| 336 |
\xdef#1{#4}% |
| 337 |
}% |
| 338 |
\else |
| 339 |
\def\x#1#2[#3]{\endgroup |
| 340 |
#2[{#3}]% |
| 341 |
\ifx#1\@undefined |
| 342 |
\xdef#1{#3}% |
| 343 |
\fi |
| 344 |
\ifx#1\relax |
| 345 |
\xdef#1{#3}% |
| 346 |
\fi |
| 347 |
}% |
| 348 |
\fi |
| 349 |
\expandafter\x\csname [email protected]\endcsname |
| 350 |
\ProvidesPackage{iflang}% |
| 351 |
[2018/01/21 v1.7 Checks for the current language (HO)]% |
| 352 |
% \end{macrocode} |
| 353 |
% |
| 354 |
% \begin{macrocode} |
| 355 |
\begingroup\catcode61\catcode48\catcode32=10\relax% |
| 356 |
\catcode13=5 % ^^M |
| 357 |
\endlinechar=13 % |
| 358 |
\catcode123=1 % { |
| 359 |
\catcode125=2 % } |
| 360 |
\catcode64=11 % @ |
| 361 |
\def\x{\endgroup |
| 362 |
\expandafter\edef\csname IfLang@AtEnd\endcsname{% |
| 363 |
\endlinechar=\the\endlinechar\relax |
| 364 |
\catcode13=\the\catcode13\relax |
| 365 |
\catcode32=\the\catcode32\relax |
| 366 |
\catcode35=\the\catcode35\relax |
| 367 |
\catcode61=\the\catcode61\relax |
| 368 |
\catcode64=\the\catcode64\relax |
| 369 |
\catcode123=\the\catcode123\relax |
| 370 |
\catcode125=\the\catcode125\relax |
| 371 |
}% |
| 372 |
}% |
| 373 |
\x\catcode61\catcode48\catcode32=10\relax% |
| 374 |
\catcode13=5 % ^^M |
| 375 |
\endlinechar=13 % |
| 376 |
\catcode35=6 % # |
| 377 |
\catcode64=11 % @ |
| 378 |
\catcode123=1 % { |
| 379 |
\catcode125=2 % } |
| 380 |
\def\TMP@EnsureCode#1#2{% |
| 381 |
\edef\IfLang@AtEnd{% |
| 382 |
\IfLang@AtEnd |
| 383 |
\catcode#1=\the\catcode#1\relax |
| 384 |
}% |
| 385 |
\catcode#1=#2\relax |
| 386 |
} |
| 387 |
\TMP@EnsureCode{39}{12}% ' |
| 388 |
\TMP@EnsureCode{40}{12}% ( |
| 389 |
\TMP@EnsureCode{41}{12}% ) |
| 390 |
\TMP@EnsureCode{44}{12}% , |
| 391 |
\TMP@EnsureCode{46}{12}% . |
| 392 |
\TMP@EnsureCode{47}{12}% / |
| 393 |
\TMP@EnsureCode{58}{12}% : |
| 394 |
\TMP@EnsureCode{91}{12}% [ |
| 395 |
\TMP@EnsureCode{93}{12}% ] |
| 396 |
\edef\IfLang@AtEnd{\IfLang@AtEnd\noexpand\endinput} |
| 397 |
% \end{macrocode} |
| 398 |
% |
| 399 |
% \subsection{Tools} |
| 400 |
% |
| 401 |
% \subsubsection{Provide some basic macros of \LaTeX} |
| 402 |
% |
| 403 |
% \begin{macro}{\@firstoftwo} |
| 404 |
% \begin{macrocode} |
| 405 |
\expandafter\ifx\csname @firstoftwo\endcsname\relax |
| 406 |
\long\def\@firstoftwo#1#2{#1}% |
| 407 |
\fi |
| 408 |
% \end{macrocode} |
| 409 |
% \end{macro} |
| 410 |
% \begin{macro}{\@secondoftwo} |
| 411 |
% \begin{macrocode} |
| 412 |
\expandafter\ifx\csname @secondoftwo\endcsname\relax |
| 413 |
\long\def\@secondoftwo#1#2{#2}% |
| 414 |
\fi |
| 415 |
% \end{macrocode} |
| 416 |
% \end{macro} |
| 417 |
% |
| 418 |
% \subsubsection{Expandible existence check for macros} |
| 419 |
% |
| 420 |
% \begin{macro}{\IfLang@IfDefined} |
| 421 |
% \begin{macrocode} |
| 422 |
\begingroup\expandafter\expandafter\expandafter\endgroup |
| 423 |
\expandafter\ifx\csname ifcsname\endcsname\relax |
| 424 |
\expandafter\@firstoftwo |
| 425 |
\else |
| 426 |
\expandafter\@secondoftwo |
| 427 |
\fi |
| 428 |
{% |
| 429 |
\def\IfLang@IfDefined#1{% |
| 430 |
\expandafter\ifx\csname#1\endcsname\relax |
| 431 |
\expandafter\@secondoftwo |
| 432 |
\else |
| 433 |
\expandafter\@firstoftwo |
| 434 |
\fi |
| 435 |
}% |
| 436 |
}{% |
| 437 |
\def\IfLang@IfDefined#1{% |
| 438 |
\ifnum\ifcsname#1\endcsname |
| 439 |
\expandafter\ifx\csname#1\endcsname\relax |
| 440 |
1% |
| 441 |
\else |
| 442 |
0% |
| 443 |
\fi |
| 444 |
\else |
| 445 |
1% |
| 446 |
\fi |
| 447 |
=0 % |
| 448 |
\expandafter\@firstoftwo |
| 449 |
\else |
| 450 |
\expandafter\@secondoftwo |
| 451 |
\fi |
| 452 |
}% |
| 453 |
} |
| 454 |
% \end{macrocode} |
| 455 |
% \end{macro} |
| 456 |
% |
| 457 |
% \subsubsection{Macros for messages} |
| 458 |
% |
| 459 |
% \begin{macrocode} |
| 460 |
\begingroup\expandafter\expandafter\expandafter\endgroup |
| 461 |
\expandafter\ifx\csname RequirePackage\endcsname\relax |
| 462 |
\input infwarerr.sty\relax |
| 463 |
\input pdftexcmds.sty\relax |
| 464 |
\else |
| 465 |
\RequirePackage{infwarerr}[2007/09/09]% |
| 466 |
\RequirePackage{pdftexcmds}[2016/05/16]% |
| 467 |
\fi |
| 468 |
% \end{macrocode} |
| 469 |
% |
| 470 |
% \subsubsection{Support for \xfile{etex.src}} |
| 471 |
% |
| 472 |
% \begin{macro}{\IfLang@prefix} |
| 473 |
% \begin{macrocode} |
| 474 |
\begingroup\expandafter\expandafter\expandafter\endgroup |
| 475 |
\expandafter\ifx\csname et@xpatterns\endcsname\relax |
| 476 |
\@PackageInfoNoLine{iflang}{% |
| 477 |
Naming convention for patterns: babel% |
| 478 |
}% |
| 479 |
\def\IfLang@prefix{l@}% |
| 480 |
\else |
| 481 |
\@PackageInfoNoLine{iflang}{% |
| 482 |
Naming convention for patterns: etex.src% |
| 483 |
}% |
| 484 |
\def\IfLang@prefix{lang@}% |
| 485 |
\let\IfLang@OrgUseLanguage\uselanguage |
| 486 |
\def\uselanguage#1{% |
| 487 |
\edef\languagename{#1}% |
| 488 |
\IfLang@OrgUseLanguage{#1}% |
| 489 |
}% |
| 490 |
% \end{macrocode} |
| 491 |
% \end{macro} |
| 492 |
% The first \cs{uselanguage} that is executed as last |
| 493 |
% line in \xfile{language.def} cannot patched this way. |
| 494 |
% However, \xfile{language.def} is very strict. It forces |
| 495 |
% the first added and used language to be |USenglish|. |
| 496 |
% Thus, if \cs{languagename} is not defined, we can |
| 497 |
% quite safely assume |USenglish|. As additional |
| 498 |
% safety precaution the actual used patterns are checked. |
| 499 |
% \begin{macrocode} |
| 500 |
\begingroup\expandafter\expandafter\expandafter\endgroup |
| 501 |
\expandafter\ifx\csname languagename\endcsname\relax |
| 502 |
\begingroup\expandafter\expandafter\expandafter\endgroup |
| 503 |
\expandafter\ifx\csname lang@USenglish\endcsname\relax |
| 504 |
\@PackageWarningNoLine{iflang}{% |
| 505 |
\string\lang@USenglish\space is missing% |
| 506 |
}% |
| 507 |
\else |
| 508 |
\ifnum\lang@USenglish=\language |
| 509 |
\def\languagename{USenglish}% |
| 510 |
\else |
| 511 |
\@PackageWarningNoLine{iflang}{% |
| 512 |
\string\languagename\space is not set,\MessageBreak |
| 513 |
current language is unknown% |
| 514 |
}% |
| 515 |
\fi |
| 516 |
\fi |
| 517 |
\fi |
| 518 |
\fi |
| 519 |
\begingroup\expandafter\expandafter\expandafter\endgroup |
| 520 |
\expandafter\ifx\csname languagename\endcsname\relax |
| 521 |
\@PackageInfoNoLine{iflang}{% |
| 522 |
\string\languagename\space is not set% |
| 523 |
}% |
| 524 |
\fi |
| 525 |
% \end{macrocode} |
| 526 |
% |
| 527 |
% \subsection{\cs{IfLanguagePatterns}} |
| 528 |
% |
| 529 |
% \begin{macro}{\IfLanguagePatterns} |
| 530 |
% \begin{macrocode} |
| 531 |
\def\IfLanguagePatterns#1{% |
| 532 |
\ifnum\IfLang@IfDefined{\IfLang@prefix#1}{% |
| 533 |
\ifnum\csname\IfLang@prefix#1\endcsname=\language |
| 534 |
0% |
| 535 |
\else |
| 536 |
1% |
| 537 |
\fi |
| 538 |
}{1}=0 % |
| 539 |
\expandafter\@firstoftwo |
| 540 |
\else |
| 541 |
\expandafter\@secondoftwo |
| 542 |
\fi |
| 543 |
} |
| 544 |
% \end{macrocode} |
| 545 |
% \end{macro} |
| 546 |
% |
| 547 |
% \subsection{\cs{IfLanguageName}} |
| 548 |
% |
| 549 |
% \begin{macrocode} |
| 550 |
\begingroup\expandafter\expandafter\expandafter\endgroup |
| 551 |
\expandafter\ifx\csname pdf@strcmp\endcsname\relax |
| 552 |
\expandafter\@firstoftwo |
| 553 |
\else |
| 554 |
\expandafter\@secondoftwo |
| 555 |
\fi |
| 556 |
{% |
| 557 |
% \end{macrocode} |
| 558 |
% We do not have \cs{pdf@strcmp} (and \cs{pdfstrcmp}). |
| 559 |
% Thus we must define |
| 560 |
% our own expandable string comparison. The following |
| 561 |
% implementation is based on a \TeX\ pearl from David Kastrup, presented |
| 562 |
% at the conference Bacho\TeX~2005: |
| 563 |
% \url{http://www.gust.org.pl/projects/pearls/2005p/david-kastrup/bachotex2005-david-kastrup-pearl1.pdf} |
| 564 |
% |
| 565 |
% The original code allows macros inside the second string. |
| 566 |
% Because also \cs{languagename} might consists of further |
| 567 |
% macros, we need a variant that allows macros in the first |
| 568 |
% string, too. |
| 569 |
% \begin{macrocode} |
| 570 |
\def\IfLang@StrNil{\relax}% |
| 571 |
\def\IfLang@StrEqual#1{% |
| 572 |
\number\IfLang@StrEqualStart{}{}#1\IfLang@StrNil |
| 573 |
}% |
| 574 |
\def\IfLang@StrEqualStart#1#2#3{% |
| 575 |
\ifx#3\IfLang@StrNil |
| 576 |
\IfLang@StrEqualStop |
| 577 |
\fi |
| 578 |
\ifcat\noexpand#3\relax |
| 579 |
\IfLang@StrExpand{#1}{#2}#3% |
| 580 |
\fi |
| 581 |
\IfLang@StrEqualStart{\if#3#1}{#2\fi}% |
| 582 |
}% |
| 583 |
\def\IfLang@StrEqualStop\fi#1\IfLang@StrEqualStart#2#3#4{% |
| 584 |
\fi |
| 585 |
#2#4\relax'#313 % |
| 586 |
}% |
| 587 |
\def\IfLang@StrExpand#1#2#3\fi\IfLang@StrEqualStart#4#5{% |
| 588 |
\fi |
| 589 |
\IfLang@@StrExpand{#1}{#2}#3% |
| 590 |
}% |
| 591 |
\def\IfLang@@StrExpand#1#2#3\IfLang@StrNil{% |
| 592 |
\expandafter\IfLang@@@StrExpand#3\IfLang@StrNil{#1}{#2}% |
| 593 |
}% |
| 594 |
\def\IfLang@@@StrExpand#1\IfLang@StrNil#2#3{% |
| 595 |
\IfLang@StrEqualStart{#2}{#3}#1\IfLang@StrNil |
| 596 |
}% |
| 597 |
% \end{macrocode} |
| 598 |
% \begin{macro}{\IfLanguageName} |
| 599 |
% \begin{macrocode} |
| 600 |
\def\IfLanguageName#1{% |
| 601 |
\ifnum\IfLang@IfDefined{languagename}{% |
| 602 |
\if\expandafter\IfLang@StrEqual\expandafter% |
| 603 |
{\languagename}{#1}% |
| 604 |
0% |
| 605 |
\else |
| 606 |
1% |
| 607 |
\fi |
| 608 |
}{1}=0 % |
| 609 |
\expandafter\@firstoftwo |
| 610 |
\else |
| 611 |
\expandafter\@secondoftwo |
| 612 |
\fi |
| 613 |
}% |
| 614 |
% \end{macrocode} |
| 615 |
% \end{macro} |
| 616 |
% \begin{macrocode} |
| 617 |
}{% |
| 618 |
% \end{macrocode} |
| 619 |
% \begin{macro}{\IfLanguageName} |
| 620 |
% \begin{macrocode} |
| 621 |
\def\IfLanguageName#1{% |
| 622 |
\ifnum\IfLang@IfDefined{languagename}{% |
| 623 |
\pdf@strcmp{#1}{\languagename}% |
| 624 |
}{1}=0 % |
| 625 |
\expandafter\@firstoftwo |
| 626 |
\else |
| 627 |
\expandafter\@secondoftwo |
| 628 |
\fi |
| 629 |
}% |
| 630 |
% \end{macrocode} |
| 631 |
% \end{macro} |
| 632 |
% \begin{macrocode} |
| 633 |
} |
| 634 |
% \end{macrocode} |
| 635 |
% |
| 636 |
% \subsection{Check plausibility of \cs{languagename}} |
| 637 |
% |
| 638 |
% \begin{macrocode} |
| 639 |
\begingroup\expandafter\expandafter\expandafter\endgroup |
| 640 |
\expandafter\ifx\csname languagename\endcsname\relax |
| 641 |
\else |
| 642 |
\IfLanguagePatterns{\languagename}{}{% |
| 643 |
\@PackageWarningNoLine{iflang}{% |
| 644 |
Mismatch between \string\language\space |
| 645 |
(patterns)\MessageBreak |
| 646 |
and setting of \string\languagename |
| 647 |
}% |
| 648 |
}% |
| 649 |
\fi |
| 650 |
% \end{macrocode} |
| 651 |
% |
| 652 |
% \begin{macrocode} |
| 653 |
\IfLang@AtEnd% |
| 654 |
%</package> |
| 655 |
% \end{macrocode} |
| 656 |
%% \section{Installation} |
| 657 |
% |
| 658 |
% \subsection{Download} |
| 659 |
% |
| 660 |
% \paragraph{Package.} This package is available on |
| 661 |
% CTAN\footnote{\CTANpkg{iflang}}: |
| 662 |
% \begin{description} |
| 663 |
% \item[\CTAN{macros/latex/contrib/oberdiek/iflang.dtx}] The source file. |
| 664 |
% \item[\CTAN{macros/latex/contrib/oberdiek/iflang.pdf}] Documentation. |
| 665 |
% \end{description} |
| 666 |
% |
| 667 |
% |
| 668 |
% \paragraph{Bundle.} All the packages of the bundle `oberdiek' |
| 669 |
% are also available in a TDS compliant ZIP archive. There |
| 670 |
% the packages are already unpacked and the documentation files |
| 671 |
% are generated. The files and directories obey the TDS standard. |
| 672 |
% \begin{description} |
| 673 |
% \item[\CTANinstall{install/macros/latex/contrib/oberdiek.tds.zip}] |
| 674 |
% \end{description} |
| 675 |
% \emph{TDS} refers to the standard ``A Directory Structure |
| 676 |
% for \TeX\ Files'' (\CTANpkg{tds}). Directories |
| 677 |
% with \xfile{texmf} in their name are usually organized this way. |
| 678 |
% |
| 679 |
% \subsection{Bundle installation} |
| 680 |
% |
| 681 |
% \paragraph{Unpacking.} Unpack the \xfile{oberdiek.tds.zip} in the |
| 682 |
% TDS tree (also known as \xfile{texmf} tree) of your choice. |
| 683 |
% Example (linux): |
| 684 |
% \begin{quote} |
| 685 |
% |unzip oberdiek.tds.zip -d ~/texmf| |
| 686 |
% \end{quote} |
| 687 |
% |
| 688 |
% \subsection{Package installation} |
| 689 |
% |
| 690 |
% \paragraph{Unpacking.} The \xfile{.dtx} file is a self-extracting |
| 691 |
% \docstrip\ archive. The files are extracted by running the |
| 692 |
% \xfile{.dtx} through \plainTeX: |
| 693 |
% \begin{quote} |
| 694 |
% \verb|tex iflang.dtx| |
| 695 |
% \end{quote} |
| 696 |
% |
| 697 |
% \paragraph{TDS.} Now the different files must be moved into |
| 698 |
% the different directories in your installation TDS tree |
| 699 |
% (also known as \xfile{texmf} tree): |
| 700 |
% \begin{quote} |
| 701 |
% \def\t{^^A |
| 702 |
% \begin{tabular}{@{}>{\ttfamily}l@{ $\rightarrow$ }>{\ttfamily}l@{}} |
| 703 |
% iflang.sty & tex/generic/oberdiek/iflang.sty\\ |
| 704 |
% iflang.pdf & doc/latex/oberdiek/iflang.pdf\\ |
| 705 |
% iflang.dtx & source/latex/oberdiek/iflang.dtx\\ |
| 706 |
% \end{tabular}^^A |
| 707 |
% }^^A |
| 708 |
% \sbox0{\t}^^A |
| 709 |
% \ifdim\wd0>\linewidth |
| 710 |
% \begingroup |
| 711 |
% \advance\linewidth by\leftmargin |
| 712 |
% \advance\linewidth by\rightmargin |
| 713 |
% \edef\x{\endgroup |
| 714 |
% \def\noexpand\lw{\the\linewidth}^^A |
| 715 |
% }\x |
| 716 |
% \def\lwbox{^^A |
| 717 |
% \leavevmode |
| 718 |
% \hbox to \linewidth{^^A |
| 719 |
% \kern-\leftmargin\relax |
| 720 |
% \hss |
| 721 |
% \usebox0 |
| 722 |
% \hss |
| 723 |
% \kern-\rightmargin\relax |
| 724 |
% }^^A |
| 725 |
% }^^A |
| 726 |
% \ifdim\wd0>\lw |
| 727 |
% \sbox0{\small\t}^^A |
| 728 |
% \ifdim\wd0>\linewidth |
| 729 |
% \ifdim\wd0>\lw |
| 730 |
% \sbox0{\footnotesize\t}^^A |
| 731 |
% \ifdim\wd0>\linewidth |
| 732 |
% \ifdim\wd0>\lw |
| 733 |
% \sbox0{\scriptsize\t}^^A |
| 734 |
% \ifdim\wd0>\linewidth |
| 735 |
% \ifdim\wd0>\lw |
| 736 |
% \sbox0{\tiny\t}^^A |
| 737 |
% \ifdim\wd0>\linewidth |
| 738 |
% \lwbox |
| 739 |
% \else |
| 740 |
% \usebox0 |
| 741 |
% \fi |
| 742 |
% \else |
| 743 |
% \lwbox |
| 744 |
% \fi |
| 745 |
% \else |
| 746 |
% \usebox0 |
| 747 |
% \fi |
| 748 |
% \else |
| 749 |
% \lwbox |
| 750 |
% \fi |
| 751 |
% \else |
| 752 |
% \usebox0 |
| 753 |
% \fi |
| 754 |
% \else |
| 755 |
% \lwbox |
| 756 |
% \fi |
| 757 |
% \else |
| 758 |
% \usebox0 |
| 759 |
% \fi |
| 760 |
% \else |
| 761 |
% \lwbox |
| 762 |
% \fi |
| 763 |
% \else |
| 764 |
% \usebox0 |
| 765 |
% \fi |
| 766 |
% \end{quote} |
| 767 |
% If you have a \xfile{docstrip.cfg} that configures and enables \docstrip's |
| 768 |
% TDS installing feature, then some files can already be in the right |
| 769 |
% place, see the documentation of \docstrip. |
| 770 |
% |
| 771 |
% \subsection{Refresh file name databases} |
| 772 |
% |
| 773 |
% If your \TeX~distribution |
| 774 |
% (\TeX\,Live, \mikTeX, \dots) relies on file name databases, you must refresh |
| 775 |
% these. For example, \TeX\,Live\ users run \verb|texhash| or |
| 776 |
% \verb|mktexlsr|. |
| 777 |
% |
| 778 |
% \subsection{Some details for the interested} |
| 779 |
% |
| 780 |
% \paragraph{Unpacking with \LaTeX.} |
| 781 |
% The \xfile{.dtx} chooses its action depending on the format: |
| 782 |
% \begin{description} |
| 783 |
% \item[\plainTeX:] Run \docstrip\ and extract the files. |
| 784 |
% \item[\LaTeX:] Generate the documentation. |
| 785 |
% \end{description} |
| 786 |
% If you insist on using \LaTeX\ for \docstrip\ (really, |
| 787 |
% \docstrip\ does not need \LaTeX), then inform the autodetect routine |
| 788 |
% about your intention: |
| 789 |
% \begin{quote} |
| 790 |
% \verb|latex \let\install=y\input{iflang.dtx}| |
| 791 |
% \end{quote} |
| 792 |
% Do not forget to quote the argument according to the demands |
| 793 |
% of your shell. |
| 794 |
% |
| 795 |
% \paragraph{Generating the documentation.} |
| 796 |
% You can use both the \xfile{.dtx} or the \xfile{.drv} to generate |
| 797 |
% the documentation. The process can be configured by the |
| 798 |
% configuration file \xfile{ltxdoc.cfg}. For instance, put this |
| 799 |
% line into this file, if you want to have A4 as paper format: |
| 800 |
% \begin{quote} |
| 801 |
% \verb|\PassOptionsToClass{a4paper}{article}| |
| 802 |
% \end{quote} |
| 803 |
% An example follows how to generate the |
| 804 |
% documentation with pdf\LaTeX: |
| 805 |
% \begin{quote} |
| 806 |
%\begin{verbatim} |
| 807 |
%pdflatex iflang.dtx |
| 808 |
%makeindex -s gind.ist iflang.idx |
| 809 |
%pdflatex iflang.dtx |
| 810 |
%makeindex -s gind.ist iflang.idx |
| 811 |
%pdflatex iflang.dtx |
| 812 |
%\end{verbatim} |
| 813 |
% \end{quote} |
| 814 |
% |
| 815 |
% \section{Acknowledgement} |
| 816 |
% I wish to thank: |
| 817 |
% \begin{description} |
| 818 |
% \item[Markus Kohm] Useful hints for version 1.2. |
| 819 |
% \end{description} |
| 820 |
% |
| 821 |
% \begin{History} |
| 822 |
% \begin{Version}{2007/04/10 v1.0} |
| 823 |
% \item |
| 824 |
% First public version. |
| 825 |
% \end{Version} |
| 826 |
% \begin{Version}{2007/04/11 v1.1} |
| 827 |
% \item |
| 828 |
% Line ends sanitized. |
| 829 |
% \end{Version} |
| 830 |
% \begin{Version}{2007/04/12 v1.2} |
| 831 |
% \item |
| 832 |
% Initialization of \cs{languagename} in case of \xfile{etex.src}. |
| 833 |
% \item |
| 834 |
% Some sanity tests added. |
| 835 |
% \item |
| 836 |
% Documentation improved. |
| 837 |
% \end{Version} |
| 838 |
% \begin{Version}{2007/04/26 v1.3} |
| 839 |
% \item |
| 840 |
% Use of package \xpackage{infwarerr}. |
| 841 |
% \end{Version} |
| 842 |
% \begin{Version}{2007/09/09 v1.4} |
| 843 |
% \item |
| 844 |
% Bug fix: \cs{IfLang@StrEqual} $\rightarrow$ \cs{IfLangStrEqual} |
| 845 |
% (Gabriele Balducci). |
| 846 |
% \item |
| 847 |
% Catcode section rewritten. |
| 848 |
% \end{Version} |
| 849 |
% \begin{Version}{2007/11/11 v1.5} |
| 850 |
% \item |
| 851 |
% Use of package \xpackage{pdftexcmds} for \LuaTeX\ support. |
| 852 |
% \end{Version} |
| 853 |
% \begin{Version}{2016/05/16 v1.6} |
| 854 |
% \item |
| 855 |
% Documentation updates. |
| 856 |
% \end{Version} |
| 857 |
% \begin{Version}{2018/01/21 v1.7} |
| 858 |
% \item |
| 859 |
% Fix test for \texttt{etex.src}. |
| 860 |
% \end{Version} |
| 861 |
% \end{History} |
| 862 |
% |
| 863 |
% \PrintIndex |
| 864 |
% |
| 865 |
% \Finale |
| 866 |
\endinput |