| 1 |
% \iffalse meta-comments |
| 2 |
% msg.dtx original file name. This is a 8bits file. |
| 3 |
% |
| 4 |
% Copyright (C) 2004 LPPL - Bernard Gaulle. |
| 5 |
% |
| 6 |
% This file may be distributed and/or modified under the conditions of |
| 7 |
% the LaTeX Project Public License as of http://www.latex-project.org/lppl.txt |
| 8 |
% |
| 9 |
% This file has the LPPL maintenance status "maintained". |
| 10 |
% The current maintainer is Bernard.Gaulle at idris.fr |
| 11 |
% \fi |
| 12 |
% \CheckSum{1333} |
| 13 |
% \iffalse |
| 14 |
% \begin{macrocode} |
| 15 |
%<*README> |
| 16 |
%% To unpack this package: latex msg.ins |
| 17 |
%% To prepare for TeX Live: make TL |
| 18 |
%% |
| 19 |
%% HERE IS THE MSG PACKAGE FOR LaTeX |
| 20 |
%% |
| 21 |
%% A LaTeX package to localize any package or document class. |
| 22 |
%% |
| 23 |
%% A LaTeX package able to issue messages in the language provided as option |
| 24 |
%% of \documentclass or in use in the document (\languagename). All messages |
| 25 |
%% are identified with a unique "id" and stored in a MessagesFile whose name |
| 26 |
%% is related to the package and optionnaly to the language. |
| 27 |
%% |
| 28 |
%% MessagesFile, name: [<language>]_<package>-msg.tex |
| 29 |
%% contents: \msg{<id>}{<message>} % defines the message "id". |
| 30 |
%% \msg*{<id>}{<message>} % star form for msg emphasis. |
| 31 |
%% \msg{*}{<error message>} % bad "id" default message. |
| 32 |
%% Messages can have 3 more parts defined asis: |
| 33 |
%% \msg{<id>}{<msg>}[ % defines the msg first part. |
| 34 |
%% \msgparti{<msg_part>} % defines the msg second part. |
| 35 |
%% \msgpartii{<msg_part>} % defines the msg third part. |
| 36 |
%% \msgpartiii{<msg_part>}] % defines the msg fourth part. |
| 37 |
%% Any message part can include a |#1| parameter provided from any |
| 38 |
%% of the macros below. |
| 39 |
%% Error messages have just a help more part as follows: |
| 40 |
%% \msg{<id>}{<msg>}[ % defines the msg first part. |
| 41 |
%% \help{<help_part>}] % defines the help part. |
| 42 |
%% All messages should be fully expandable. |
| 43 |
%% Custolization: |
| 44 |
%% \msgheader{<head part of messages>} |
| 45 |
%% \msgtrailer{<final part of messages>} |
| 46 |
%% \msgencoding{<encoding of messages>}% as for inputenc. |
| 47 |
%% Check "msg-msg.tex" file for msg's own messages file. |
| 48 |
%% |
| 49 |
%% Document usage: \documentclass[any_option]{any_class} |
| 50 |
%% call: \usepackage[options,language]{msg} |
| 51 |
%% |
| 52 |
%% to issue the message "id": \issuemsg{<id>}(<package>)[#1] |
| 53 |
%% One can use any message macro (defaultly \typeout) with: |
| 54 |
%% \issuemsg[msg_macro]{<id>}(<package>)[#1] |
| 55 |
%% Multi-parts message can't be issued through \issuemsg. |
| 56 |
%% One can specify the macro name to issue message as an option |
| 57 |
%% of \usepackage: \message, \wlog, \typeout, \kbtypyeout or |
| 58 |
%% \ClassWarning, \ClassError, \PackageWarning, \PackageError, ... |
| 59 |
%% |
| 60 |
%% to retrieve the message "id" in \themsg (without typesetting): |
| 61 |
%% \retrievemsg{<id>}(<package>)[#1] |
| 62 |
%% Multi-parts message will have defined also \themsgi, |
| 63 |
%% \themsgii and \themsgiii. |
| 64 |
%% to get the message "id": \getmsg{<id>}(<package>)[#1] |
| 65 |
%% |
| 66 |
%% Usually, the requested message "id" is retrieved from |
| 67 |
%% [<language>]_<package>-msg.tex but if there is no active language |
| 68 |
%% or if file don't exist then message is searched in the |
| 69 |
%% <package>-msg.tex file. |
| 70 |
%% |
| 71 |
%% For testing a messages file, you can code: |
| 72 |
%% \issueallmsg[msg_macro](<package>) |
| 73 |
%% and all messages from the file will be retrieved and issued. |
| 74 |
%% |
| 75 |
%% For tracing all accessed files you should load the "msg" package with |
| 76 |
%% the option: tracefiles. |
| 77 |
%% |
| 78 |
%% In case of trouble you can ask the "msg" package not to load |
| 79 |
%% any message file, just load the "msg" package with the |
| 80 |
%% option: noop, and then you just obtain a message containing |
| 81 |
%% the "msgid". |
| 82 |
%% |
| 83 |
%% Please look at the documentations for more details. |
| 84 |
%% |
| 85 |
%</README> |
| 86 |
% \end{macrocode} |
| 87 |
% \fi |
| 88 |
% \catcode`\<=\active\def<{$\langle$} |
| 89 |
% \catcode`\>=\active\def>{$\rangle$} |
| 90 |
% \def\msgname{``\textsf{msg}''} |
| 91 |
% \title{\vspace*{-1cm}The \LaTeXe\ \msgname\ package\\ |
| 92 |
% for package localization\thanks{This file has version |
| 93 |
% \fileversion\ last revised \filedate}\\[0.25\baselineskip] |
| 94 |
% \ifguide\textit{Package writer's guide} |
| 95 |
% \else\textit{Comprehensive documentation} |
| 96 |
% \fi} |
| 97 |
% \author{Bernard \textsc{Gaulle}} |
| 98 |
% \date{As of \filedate |
| 99 |
% \vfill{\small\tableofcontents}} |
| 100 |
% \maketitle |
| 101 |
% |
| 102 |
% \section{Introduction} |
| 103 |
% |
| 104 |
% Since a \LaTeX\ package issues various messages, mostly in English (but, |
| 105 |
% unfortunately, often in an English-like language), it is usefull |
| 106 |
% to provide a feature to localize any \LaTeXe\ package or document class. |
| 107 |
% The \msgname\ package is designed for that. |
| 108 |
% Messages are in dedicated files and retrieved when needed.\\ |
| 109 |
% |
| 110 |
% Packages writers (as well as document class writers) just have to create |
| 111 |
% their native messages file and ask for any message when needed. |
| 112 |
% |
| 113 |
% \ifguide\else |
| 114 |
% \section{The documentation driver} |
| 115 |
% |
| 116 |
% This code will generate the documentation. Since it is the first piece of |
| 117 |
% code in the file, the documentation can be obtained by simply processing |
| 118 |
% this file with \LaTeXe. |
| 119 |
% |
| 120 |
% We just load the \msgname\ package for self testing purposes (which needs |
| 121 |
% we keep track of the |doc|'s |\MakePercent| macros later used). |
| 122 |
% \fi |
| 123 |
% \begin{macrocode} |
| 124 |
%<*driver> |
| 125 |
\documentclass[10pt]{ltxdoc} |
| 126 |
\makeatletter |
| 127 |
\let\msg@MPC\MakePercentComment |
| 128 |
\let\msg@MPI\MakePercentIgnore |
| 129 |
\makeatother |
| 130 |
\usepackage[T1]{fontenc} |
| 131 |
\usepackage{lmodern}% You can remove it if you don't have that font. |
| 132 |
\usepackage{makeidx} |
| 133 |
\usepackage[tracefiles]{msg} |
| 134 |
% \usepackage{msg}% should also be tested without "tracefiles" |
| 135 |
\begin{document} |
| 136 |
\let\hard\relax\let\endhard\relax\let\ifguide\iffalse |
| 137 |
\DocInput{msg.dtx} |
| 138 |
\end{document} |
| 139 |
%</driver> |
| 140 |
% \end{macrocode} |
| 141 |
% |
| 142 |
% \ifguide\else |
| 143 |
% A package writer's guide can also be typeset using the file |
| 144 |
% |msgguide.tex|. |
| 145 |
% \fi |
| 146 |
% |
| 147 |
% \ifguide\else |
| 148 |
% \section{Initialization} |
| 149 |
% |
| 150 |
% Check if the msg package is already loaded and if yes end input. |
| 151 |
% Set the ``catcode'' for |@| if not already done. |
| 152 |
% Assume defaultly that the output macro (|\issuemsgio|) |
| 153 |
% will be |\typeout| if not already initiated. Force the \texttt{inputenc} |
| 154 |
% package to be loaded, if not already done and even from a Babel option |
| 155 |
% since it could issue messages via our \msgname\ package. |
| 156 |
% Check also if the english ``msg'' file \texttt{msg-msg.tex} is not installed |
| 157 |
% to detect the original bug of TeXLive 2005 and then stop typesetting. |
| 158 |
% \fi |
| 159 |
% |
| 160 |
% \begin{macrocode} |
| 161 |
%<*code> |
| 162 |
\iffalse checksum part |
| 163 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 164 |
%% |
| 165 |
%% checksum = "32817 1583 6882 65979" |
| 166 |
%% |
| 167 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 168 |
\fi |
| 169 |
\def\fileversion{V0.51}\def\filedate{2019/01/01}% |
| 170 |
\ifx\issuemsg\undefined\else\expandafter\endinput\fi% |
| 171 |
\ifnum\catcode`\@=11\else\expandafter\catcode`\@=11\fi% |
| 172 |
\ifx\kbencoding\undefined% If we don't have any keyboard reencoding |
| 173 |
\ifx\LdfInit\@undefined% we need at least inputenc package. |
| 174 |
\RequirePackage{inputenc}% Usually, load that package. |
| 175 |
\else% But with Babel, dont use \usepackage or such, |
| 176 |
\let\@msg@tempa\@currname% Save current package name. |
| 177 |
\xdef\@currname{inputenc}% set package req. |
| 178 |
\@@input inputenc.sty% and input it now. |
| 179 |
\makeatletter% |
| 180 |
\let\@currname\@msg@tempa% Reset original package name. |
| 181 |
\fi% |
| 182 |
\let\@previeg\empty% We have no encoding at this time. |
| 183 |
\fi% |
| 184 |
\IfFileExists{msg-msg.tex}{}{% |
| 185 |
\message{msg: ERROR, file msg-msg.tex is missing}\stop% |
| 186 |
}% |
| 187 |
% \end{macrocode} |
| 188 |
% \begin{macro}{\issuemsgio} |
| 189 |
% \begin{macrocode} |
| 190 |
\ifx\issuemsgio\undefined\let\issuemsgio\typeout\fi% |
| 191 |
% \end{macrocode}\label{msgio} |
| 192 |
% \end{macro} |
| 193 |
% |
| 194 |
% \ifguide\else |
| 195 |
% Verify that |\languagename| which is |
| 196 |
% set by \texttt{babel} or \texttt{mlp} or \texttt{frenchpro} |
| 197 |
% or \texttt{frenchle} or \ldots |
| 198 |
% is not a virtual language such as |
| 199 |
% |dummy| or |nohyphenation| and then keep it as |
| 200 |
% the \msgname\ package's language name. |
| 201 |
% \fi |
| 202 |
% |
| 203 |
% \begin{macrocode} |
| 204 |
\def\@msg@tempa{dummy}% |
| 205 |
\def\@msg@tempb{nohyphenation}% |
| 206 |
\def\@msg@tempc{english}% Default language for msg package. |
| 207 |
\ifx\languagename\@msg@tempa\else% |
| 208 |
\ifx\languagename\@msg@tempb\else% |
| 209 |
\ifx\languagename\@msg@tempc\let\msg@languagename\undefined\else |
| 210 |
\ifx\languagename\undefined\let\msg@languagename\undefined% |
| 211 |
\else\edef\msg@languagename{\languagename}% Set it for now. |
| 212 |
\fi% |
| 213 |
\fi% |
| 214 |
\fi% |
| 215 |
\fi% |
| 216 |
% \end{macrocode} |
| 217 |
% \ifguide\else |
| 218 |
% \begin{macro}{\packagewarningheader}|#1| |
| 219 |
% This code is designed to localize text of macro |\PackageWarning| which |
| 220 |
% we, now, redefine. |
| 221 |
% |
| 222 |
% \begin{macrocode} |
| 223 |
\def\packagewarningheader#1{Package #1 Warning: }% |
| 224 |
% |
| 225 |
\renewcommand{\PackageWarning}[2]{\GenericWarning{(#1)% |
| 226 |
\@spaces\@spaces\@spaces\@spaces}% |
| 227 |
{\packagewarningheader{#1}#2}% |
| 228 |
} |
| 229 |
% \end{macrocode} |
| 230 |
% \end{macro}\label{pw} |
| 231 |
% |
| 232 |
% Few other internal \LaTeX\ macros might be localized here... but preferably |
| 233 |
% within the kernel. |
| 234 |
% \fi |
| 235 |
% |
| 236 |
% \begin{macrocode} |
| 237 |
\edef\@msg@code@ast{\the\catcode`\*}% Save the current catcode of ``*''. |
| 238 |
% \end{macrocode} |
| 239 |
% |
| 240 |
% \section{Macros to be used in a \LaTeX\ package} |
| 241 |
% |
| 242 |
% Basically, three macro commands can be coded for package localization:\\ |
| 243 |
% |\issuemsg|, |\getmsg| and |\retrievemsg|. |
| 244 |
% Another macro, |\issuemsgx| is given for specific cases, we will see |
| 245 |
% that later, page \pageref{encodings}. |
| 246 |
% |
| 247 |
% \subsection*{Output a message} |
| 248 |
% |
| 249 |
% Here is the main macro which will issue a message ``id'' via the |
| 250 |
% command |\issuemsgio| defaultly set to |\typeout| |
| 251 |
% \ifguide.\else(cf page~\pageref{msgio}).\fi |
| 252 |
% \begin{macro}{\issuemsg}|[#1]#2(#3)[#4]| |
| 253 |
% \begin{macro}{\issuemsgx}|[#1]#2(#3)[#4]| |
| 254 |
% \begin{macrocode} |
| 255 |
\def\issuemsg{\@ifnextchar[{\i@suemsg}{\i@suemsg[\issuemsgio]}%] |
| 256 |
}% |
| 257 |
\def\issuemsgx{\@ifnextchar[{\i@suemsgx}{\i@suemsgx[\issuemsgio]}%] |
| 258 |
}% |
| 259 |
% \end{macrocode} |
| 260 |
% \end{macro} |
| 261 |
% \end{macro} |
| 262 |
% One can provide another command to issue the message |
| 263 |
% by the way of the first optional argument. The second argument is the |
| 264 |
% message ``id''; the third is the name of the package (or document |
| 265 |
% class\footnote{Each time we are talking about a \LaTeX\ package, please |
| 266 |
% consider it applies also to any \LaTeX\ document class.}) |
| 267 |
% which provides that message through a |
| 268 |
% message file whose name is |[language_]package-msg.tex|. Lastly an optional |
| 269 |
% parameter can be set to ``|#1|\footnote{You can put here |
| 270 |
% any replacement text instead of this \texttt{\#1} parameter. Be careful, |
| 271 |
% this parameter or replacement text will be, usually, expanded; so |
| 272 |
% protect any string which should not with a \texttt{\textbackslash string} |
| 273 |
% prefix.}'' to forward an argument |
| 274 |
% directly inside the message content. I thought the syntax would be too |
| 275 |
% much complicated to offer much more parameters through that mean. |
| 276 |
% We will see later that the message can also be split in four parts, |
| 277 |
% allowing anyone to display the message differently but not as |
| 278 |
% |\issuemsg| does. |
| 279 |
% |
| 280 |
% \begin{center} |
| 281 |
% \fbox{{\texttt{\textbackslash issuemsg[<\emph{message\_macro}>]\{<\emph{id}>\}(<\emph{package}>)[\#1]}}} |
| 282 |
% \end{center} |
| 283 |
% |
| 284 |
% The message macro could be the usual |\typeout| or any other output macro |
| 285 |
% with one argument such as |\message| or |\wlog|. |
| 286 |
% You can also code a macro with two arguments, such as |\ClassWarning|, |
| 287 |
% |\ClassWarningNoLine|, |\PackageWarning|, |\PackageWarningNoLine|, |
| 288 |
% |\ClassInfo| or |\PackageInfo| which have just a name as first argument, |
| 289 |
% like this: |
| 290 |
% |
| 291 |
% \begin{center} |
| 292 |
% \fbox{{\texttt{\textbackslash issuemsg[<\emph{message\_macro\{arg1\}}>]\{<\emph{id}>\}(<\emph{package}>)[\#1]}}} |
| 293 |
% \end{center} |
| 294 |
% That way the first argument is not localized (usually this is a class or |
| 295 |
% package name) and the second argument is provided by the message file |
| 296 |
% entry and so localized. |
| 297 |
% |
| 298 |
% You can also use special error macros with 3 arguments as explained below. |
| 299 |
% |
| 300 |
% \subsection*{Willing to issue a |
| 301 |
% {\mdseries\texttt{\textbackslash PackageError}}?} |
| 302 |
% \label{willingPE} |
| 303 |
% |
| 304 |
% The \msgname\ package is designed for basic macro messages which have |
| 305 |
% just only one text argument to localize. |
| 306 |
% The |\PackageError| is one exception; it has |
| 307 |
% 3 arguments: the first one (name of package in error: |
| 308 |
% |<|\texttt{\emph{package1}}|>|) which is given as the following: |
| 309 |
% |
| 310 |
% \begin{center} |
| 311 |
% \fbox{{\texttt{\textbackslash issuemsg[\textbackslash PackageError\{<\emph{package1}>\}]\{<\emph{id}>\}(<\emph{package2}>)[\#1]}}} |
| 312 |
% \end{center} |
| 313 |
% |
| 314 |
% \noindent the other two arguments will be retrieved from the message file |
| 315 |
% of \texttt{<\emph{package2}>} and localized. |
| 316 |
% |
| 317 |
% The same coding can be used for |\ClassError|: |
| 318 |
% |
| 319 |
% \begin{center} |
| 320 |
% \fbox{{\texttt{\textbackslash issuemsg[\textbackslash ClassError\{<\emph{class1}>\}]\{<\emph{id}>\}(<\emph{class2}>)[\#1]}}} |
| 321 |
% \end{center} |
| 322 |
% |
| 323 |
% \subsection*{Examples \& tests\\ |
| 324 |
% (using the message files listed page \pageref{msgfiles})} |
| 325 |
% |\issuemsg1(msg)| will give at the console: \\ |
| 326 |
% \centerline{\tt\getmsg1(msg)} but |
| 327 |
% |\issuemsg01(msg)| will give: \retrievemsg01(msg){\tt\themsg}. |
| 328 |
% |
| 329 |
% While defining |\def\test#1{`\issuemsg4(msg)[#1]'}| the following call |
| 330 |
% |\emph{\test{SPECIAL}}| will print: \def\test#1{`\getmsg4(msg)[#1]'}\\ |
| 331 |
% \centerline{\emph{\test{SPECIAL}}} showing that the argument |
| 332 |
% was inserted inside the message at the exact area, replacing |#1|. |
| 333 |
% |
| 334 |
% In a French document, the same codes will issue:\\ |
| 335 |
% \bgroup\makeatletter\@msgINfrench\def\msg@languagename{french} |
| 336 |
% \centerline{\tt\getmsg1(msg)} |
| 337 |
% \centerline{\retrievemsg01(msg){\tt\themsg}} |
| 338 |
% \centerline{\emph{\test{SPECIAL}}} |
| 339 |
% \egroup |
| 340 |
% |
| 341 |
% \begin{macrocode} |
| 342 |
\let\@msgalspace\space% |
| 343 |
\def\@msgalign#1{\ifx\empty#1\else\expandafter\@msgalign@% |
| 344 |
\expandafter#1\fi}% |
| 345 |
\def\@msgalign@#1{\ifx\void#1\else\expandafter\@msgalign@@% |
| 346 |
\expandafter#1\fi}% |
| 347 |
\def\@msgalign@@#1{\ifx\protect#1\expandafter\@msgalign@@@% |
| 348 |
\else\expandafter\@msgalign@@@@% |
| 349 |
\fi}% |
| 350 |
\def\@msgalign@@@{\@msgalign}% |
| 351 |
\def\@msgalign@@@@{\@msgalspace\@msgalign}% |
| 352 |
\let\msg@cmd\relax% |
| 353 |
\def\i@suemsg{\let\msg@cmd\issuemsg\i@suemsgx}% |
| 354 |
\def\i@suemsgx[#1]#2(#3){\@ifnextchar[{\i@@uemsg[#1]#2(#3)}%] |
| 355 |
{\i@@uemsg[#1]#2(#3)[]}% |
| 356 |
}% |
| 357 |
\let\if@msg@pkg@error\iffalse% Defaultly, not an error macro message. |
| 358 |
\def\i@@uemsg[#1]#2(#3)[#4]{% |
| 359 |
\def\@argmsg{#4}% |
| 360 |
\def\@msg@iocmd{#1}% |
| 361 |
\def\@msg@txt{% |
| 362 |
\themsg\themsgi\themsgii\themsgiii% |
| 363 |
}% |
| 364 |
\let\@msg@MBori\MessageBreak% |
| 365 |
\ifx\MessageBreak\relax% |
| 366 |
\def\MessageBreak{^^J\expandafter\@msgalign\msg@header\void}% |
| 367 |
\fi% |
| 368 |
% \end{macrocode} |
| 369 |
% |
| 370 |
% \ifguide\else |
| 371 |
% Here, we check for error macros and, if any, set the flag for |
| 372 |
% further processing. |
| 373 |
% \fi |
| 374 |
% |
| 375 |
% \begin{macrocode} |
| 376 |
\let\@msg@txt@\empty% |
| 377 |
\def\@msg@tempb##1##2/{\let\@msg@tempb=##1}% |
| 378 |
\def\@msg@tempa{\let\if@msg@pkg@error\iftrue}% |
| 379 |
\@msg@tempb#1/% \PackageError is a special case with |
| 380 |
\ifx\@msg@tempb\PackageError% package name and msg+help. |
| 381 |
\@msg@tempa% Keep it in mind for \@msgparts. |
| 382 |
\fi% |
| 383 |
% \end{macrocode} |
| 384 |
% |
| 385 |
% \ifguide\else |
| 386 |
% Now we test if the output macro name provided is well defined ; if not |
| 387 |
% we retrieve our own message \#1 in place of requested one, otherwise |
| 388 |
% we call the |\retrievemsg| macro and output the message text parts. |
| 389 |
% \fi |
| 390 |
% |
| 391 |
% \begin{macrocode} |
| 392 |
\ifx\@msg@tempb\ClassError% The same for \ClassError. |
| 393 |
\@msg@tempa% |
| 394 |
\fi% |
| 395 |
\ifx\undefined#1\retrievemsg2(msg)% |
| 396 |
\PackageWarning{msg}\@msg@txt% |
| 397 |
\else\retrievemsg#2(#3)[#4]% |
| 398 |
\ifx\kbencoding\undefined% Expand text now if |
| 399 |
\edef\@msg@txt{\@msg@txt}% output encoding is |
| 400 |
\edef\@msg@txt@{\@msg@txt@}% not available. |
| 401 |
\fi% |
| 402 |
\@relaxORgobble\@msg@iocmd{\@msg@txt}{\@msg@txt@}% |
| 403 |
%%% \csname @originalkbe\endcsname% Get back encoding if necessary. |
| 404 |
\fi% |
| 405 |
\let\MessageBreak\@msg@MBori% |
| 406 |
}% |
| 407 |
% \end{macrocode} |
| 408 |
% |
| 409 |
% \subsection*{Get a message for typesetting} |
| 410 |
% |
| 411 |
% Sometimes we only want to get the message and typeset it. The syntax is |
| 412 |
% the same as |\issuemsg| except there is no first optional argument for |
| 413 |
% providing the macro name to issue the message since it is not issued at all. |
| 414 |
% |
| 415 |
% \begin{center} |
| 416 |
% \fbox{{\texttt{\textbackslash getmsg\{<\emph{id}>\}(<\emph{package}>)[\#1]}}} |
| 417 |
% \end{center} |
| 418 |
% \subsection*{Examples \& tests} |
| 419 |
% |`\textsl{\getmsg1(msg)}'| will insert at this point |
| 420 |
% for typesetting the message: `\textsl{\getmsg1(msg)}'; |
| 421 |
% nothing is issued at the console nor in the |
| 422 |
% log, except if the |<|\emph{id}|>| is not found in the message file. |
| 423 |
% |
| 424 |
% In a French document, the same code will issue: |
| 425 |
% |
| 426 |
% \bgroup\makeatletter\def\msg@languagename{french} |
| 427 |
% \centerline{`\textsl{\getmsg1(msg)}'} |
| 428 |
% \egroup |
| 429 |
% |
| 430 |
% \ifguide\else |
| 431 |
% Here is the very simple code for |\getmsg|; just a |\retrievemsg| and |
| 432 |
% the expansion of the message when correctly retrieved. |
| 433 |
% \fi |
| 434 |
% |
| 435 |
% \begin{macro}{\getmsg}|#1(#2)[#3]| |
| 436 |
% \begin{macrocode} |
| 437 |
\def\getmsg#1(#2){\@ifnextchar[{\g@tmsg#1(#2)}{\g@tmsg#1(#2)[]}%] |
| 438 |
}% |
| 439 |
\def\g@tmsg#1(#2)[#3]{\retrievemsg{#1}(#2)[#3]\@relaxORgobble% |
| 440 |
\themsg}% |
| 441 |
% \end{macrocode} |
| 442 |
% \end{macro} |
| 443 |
% |
| 444 |
% \subsection*{The message file input routine}\label{readingprocess} |
| 445 |
% |
| 446 |
% To avoid having superfluous file names listed in the \texttt{log} |
| 447 |
% each time we request a message from a file, defaultly we read the |
| 448 |
% file with the \TeX\ |\read| command\ifguide.\else, as the following. |
| 449 |
% This code will not be used when the option |tracefiles| is given (in |
| 450 |
% which case we will input the message file with an usual |\input| macro). |
| 451 |
% \fi |
| 452 |
% \label{readcode} |
| 453 |
% |
| 454 |
% \begin{macrocode} |
| 455 |
\newif\if@msg@more% |
| 456 |
\def\@msglineparse#1#2\void{\def\@msg@tempa{\msg}% |
| 457 |
\def\@msg@tempb{#1}% |
| 458 |
\ifx\@msg@tempa\@msg@tempb% |
| 459 |
\@msg@tempf% Execute the previous line. |
| 460 |
\def\@msg@tempf{}% Start a new one. |
| 461 |
\if@msg@more% Continue line feed. |
| 462 |
\def\@msg@tempf{\protect#1#2}% |
| 463 |
\fi% |
| 464 |
\else% |
| 465 |
\let\msgheaderOLD\msgheader% |
| 466 |
\let\msgtrailerOLD\msgtrailer% |
| 467 |
\let\msgencodingOLD\msgencoding% |
| 468 |
\let\spaceOLD\space% |
| 469 |
\let\UTFviii@two@octetsOLD\UTFviii@two@octets% |
| 470 |
\let\UTFviii@three@octetsOLD\UTFviii@three@octets% |
| 471 |
\let\UTFviii@four@octetsOLD\UTFviii@four@octets% |
| 472 |
\let\UTFviii@two@octets\string% If utf8 was loaded then |
| 473 |
\let\UTFviii@three@octets\string% nullify it until |
| 474 |
\let\UTFviii@four@octets\string% necessary. |
| 475 |
\def\msgheader{\protect\msgheader}% |
| 476 |
\def\msgtrailer{\protect\msgtrailer}% |
| 477 |
\def\msgencoding{\protect\msgencoding}% |
| 478 |
\def\space{\noexpand\space}% |
| 479 |
\def\help{\protect\helpi}% |
| 480 |
\protected@edef\@msg@tempf{\@msg@tempf\@msgline}% |
| 481 |
\let\UTFviii@two@octets\UTFviii@two@octetsOLD% |
| 482 |
\let\UTFviii@three@octets\UTFviii@three@octetsOLD% |
| 483 |
\let\UTFviii@four@octets\UTFviii@four@octetsOLD% |
| 484 |
\let\space\spaceOLD% |
| 485 |
\let\msgheader\msgheaderOLD% |
| 486 |
\let\msgtrailer\msgtrailerOLD% |
| 487 |
\let\msgencoding\msgencodingOLD% |
| 488 |
\let\spaceOLD\undefined% |
| 489 |
\let\msgheaderOLD\undefined% |
| 490 |
\let\msgtrailerOLD\undefined% |
| 491 |
\let\msgencodingOLD\undefined% |
| 492 |
\fi% |
| 493 |
}% |
| 494 |
% \end{macrocode} |
| 495 |
% |
| 496 |
% NOTICE: all messages read until the requested one (included) are expanded |
| 497 |
% (before parsing) in the following macro. Thus, each (|\msg|) macro call |
| 498 |
% should contain significant value or |\protect| a macro. The same reason |
| 499 |
% applies to |\msgheader| and |\msgtrailer| we will discuss later (cf |
| 500 |
% p~\pageref{msgtrailerdef}). |
| 501 |
% |
| 502 |
% \begin{macrocode} |
| 503 |
\let\endinputORI\endinput% Save \endinput for any use in an alone \msgencoding |
| 504 |
\newread\@inputmsg% We'll need it at least for the banner message. |
| 505 |
\def\@@input@msg@filename{% Doing nearly like \@@input\msg@filename |
| 506 |
\openin\@inputmsg=\msg@filename\@msg@moretrue% |
| 507 |
\let\msgparti\relax% |
| 508 |
\let\msgpartii\relax% |
| 509 |
\let\msgpartiii\relax% |
| 510 |
\def\@msg@tempf{}% |
| 511 |
\let\endinputORI\endinput% |
| 512 |
\let\endinput\undefined% To avoid redef info msg. |
| 513 |
\DeclareRobustCommand*{\endinput}{\@msg@morefalse% |
| 514 |
}% |
| 515 |
\let\reserved@a\@gobble% Clean remaining code. |
| 516 |
\loop\catcode`\#=\active% |
| 517 |
\endlinechar=-1% |
| 518 |
\read\@inputmsg to \@msgline% |
| 519 |
\endlinechar`\^^M% |
| 520 |
\catcode`\#=6% |
| 521 |
\ifx\@msgline\empty\else% |
| 522 |
\expandafter\@msglineparse\@msgline\void% |
| 523 |
\fi% |
| 524 |
\ifeof\@inputmsg\@msg@morefalse\fi% |
| 525 |
\if@msg@more\repeat% |
| 526 |
\closein\@inputmsg\@msg@tempf% |
| 527 |
\catcode`\#=6% |
| 528 |
\let\endinput\endinputORI% |
| 529 |
}% |
| 530 |
\def\@msginput@usual{\let\endinputORI\endinput\@@input\msg@filename}% |
| 531 |
% \end{macrocode} |
| 532 |
% |
| 533 |
% |
| 534 |
% \subsection*{Just retrieve \texttt{\textbackslash themsg}} |
| 535 |
% |
| 536 |
% |
| 537 |
% One can also want to retrieve the message from the file and save |
| 538 |
% it in a macro for later use. |
| 539 |
% In fact, if this is a one-part message it will be saved |
| 540 |
% in |\themsg|, otherwise this will be the first part message and other parts |
| 541 |
% will be saved in |\themsgi|, |\themsgii| and |\themsgiii|. |
| 542 |
% \ifguide\else |
| 543 |
% This will be achieved via the |\retrievemsg| macro defined as the |
| 544 |
% following: |
| 545 |
% \fi |
| 546 |
% |
| 547 |
% \begin{macro}{\retrievemsg}|#1(#2)[#3]| |
| 548 |
% \begin{macrocode} |
| 549 |
\def\retrievemsg#1(#2){\catcode`\*=\@msg@code@ast% |
| 550 |
\@ifnextchar[{\r@trievemsg#1(#2)}%] |
| 551 |
{\r@trievemsg#1(#2)[]}% |
| 552 |
}% |
| 553 |
% \end{macrocode} |
| 554 |
% \end{macro} |
| 555 |
% \begin{macrocode} |
| 556 |
\let\msg@empty\empty% |
| 557 |
\let\if@msgnext\iffalse% Set no request for all messages. |
| 558 |
% \end{macrocode} |
| 559 |
% \begin{macro}{\themsg} |
| 560 |
% \begin{macro}{\themsgi} |
| 561 |
% \begin{macro}{\themsgii} |
| 562 |
% \begin{macro}{\themsgiii} |
| 563 |
% \begin{macro}{\msgid}\end{macro} |
| 564 |
% \begin{macrocode} |
| 565 |
\def\r@trievemsg#1(#2)[#3]{\def\@argmsg{#3}% |
| 566 |
\let\msg@header\empty\let\msg@trailer\empty% |
| 567 |
\xdef\msgid{#1}% |
| 568 |
\def\@msg@pkg{#2}% Prevent from empty file: |
| 569 |
\let\themsg\msg@empty% |
| 570 |
\if@msgnext\let\help\helpi\fi% |
| 571 |
\let\themsgi\empty% |
| 572 |
\let\themsgii\empty% |
| 573 |
\let\themsgiii\empty% |
| 574 |
% \end{macrocode} |
| 575 |
% \end{macro}\end{macro}\end{macro}\end{macro} |
| 576 |
% \begin{macrocode} |
| 577 |
\let\@relaxORgobble\relax% |
| 578 |
\edef\@msg@tempd{\@[email protected]}% |
| 579 |
\ifx\msg@languagename\undefined% |
| 580 |
\ifx\languagename\undefined\else% Get current language. |
| 581 |
\let\msg@input@lang\languagename% |
| 582 |
\fi% If no current language, use msg's language. |
| 583 |
\else\let\msg@input@lang\msg@languagename% |
| 584 |
\fi% |
| 585 |
\csname msg@MPC\endcsname% req. when ltxdoc |
| 586 |
\ifx\msg@input@lang\undefined% |
| 587 |
\let\msg@filename\@msg@tempd% |
| 588 |
\else% |
| 589 |
\edef\@msg@tempc{\msg@input@lang\string_\@msg@tempd}% |
| 590 |
\IfFileExists\@msg@tempc{\let\msg@filename\@msg@tempc}% |
| 591 |
{\let\msg@filename\@msg@tempd}% |
| 592 |
\fi% |
| 593 |
\edef\msg@inputlineno{the\inputlineno}% |
| 594 |
\makeatletter% |
| 595 |
\let\@msg@gobble@space\relax% Case \msgheader in 1st line. |
| 596 |
\let\reserved@a\@gobble% Avoid runaway. |
| 597 |
\bgroup\@@input@msg@filename\relax\egroup% |
| 598 |
\let\msg@cmd\relax% |
| 599 |
\csname msg@MPI\endcsname% req. when ltxdoc |
| 600 |
\ifx\themsg\empty% Unusual end of file reached. |
| 601 |
\def\@msg@tempa{\let\msg@empty\relax% to avoid loop. |
| 602 |
\r@trievemsg6(msg)[]% |
| 603 |
}% |
| 604 |
\expandafter\@msg@tempa% |
| 605 |
\fi% |
| 606 |
\ifx\themsg\msg@empty% |
| 607 |
\PackageError{msg}% |
| 608 |
{\string\msg{*} not found in \msg@filename}% |
| 609 |
{please reinstall the msg package}% |
| 610 |
\fi% |
| 611 |
\let\if@msg@pkg@error\iffalse% Reset for next msg request. |
| 612 |
\catcode`\*=\@msg@code@ast% Reset catcode too. |
| 613 |
}% |
| 614 |
% \end{macrocode} |
| 615 |
% |
| 616 |
% The |\retrievemsg| command is the heart of all macros to obtain the |
| 617 |
% wanted message. It will input the message file, depending on the |
| 618 |
% language to use, searching for the message ``id''. If this is a valid |
| 619 |
% language (i.e. defined in the \texttt{language.dat} |
| 620 |
% file in use) and the corresponding |
| 621 |
% language file exists it is inputed otherwise it is the package default |
| 622 |
% message file which is inputed (which should be usually in English). |
| 623 |
% In case the message ``id'' is still not found in that file and no |
| 624 |
% ``|*|'' message ``id'' exists we will try to access message number 6 |
| 625 |
% of the \msgname\ package. And again, if still not found we terminate |
| 626 |
% the process with a final package error; this is the only English message |
| 627 |
% hard coded in the \msgname\ package. Localization might occur but |
| 628 |
% should be also hard coded; not really usefull since it is not |
| 629 |
% addressed to the end user but to a package or class writer. |
| 630 |
% |
| 631 |
% \begin{center} |
| 632 |
% \fbox{{\texttt{\textbackslash retrievemsg\{<\emph{id}>\}(<\emph{package}>)[\#1]}}} |
| 633 |
% \end{center} |
| 634 |
% \subsection*{Examples \& tests} |
| 635 |
% \retrievemsg1(msg) |
| 636 |
% |\retrievemsg1(msg)| will set |\themsg| with the value of |
| 637 |
% the corresponding message ; nothing is issued at the console |
| 638 |
% nor in the log, except if the |<|\emph{id}|>| is not found in |
| 639 |
% the message file. |
| 640 |
% |
| 641 |
% \noindent|\show\themsg| will explain: |
| 642 |
% |
| 643 |
% \noindent|> \themsg=macro:| |
| 644 |
% |
| 645 |
% \noindent|->|\texttt{\themsg} |
| 646 |
% |
| 647 |
% \noindent In a French document, the same code will issue: |
| 648 |
% |
| 649 |
% \bgroup\makeatletter\def\msg@languagename{french} |
| 650 |
% \retrievemsg1(msg) |
| 651 |
% \noindent|> \themsg=macro:| |
| 652 |
% |
| 653 |
% \noindent|->|\texttt{\themsg} |
| 654 |
% \egroup |
| 655 |
% |
| 656 |
% In case the message file is empty or do not contain neither the message |
| 657 |
% ``id'' nor any |\msg{*}| macro then we will obtain: |
| 658 |
% \bgroup\makeatletter |
| 659 |
% \catcode`*=\active\let*\relax%^^A for expansion when \read case. |
| 660 |
% \let\@msg@code@ast=\active%^^A to simulate a missing \msg{*}. |
| 661 |
% \retrievemsg999(msg) |
| 662 |
% |
| 663 |
% \noindent|> \themsg=macro:| |
| 664 |
% |
| 665 |
% \noindent|->|\texttt{\themsg} |
| 666 |
% \egroup |
| 667 |
% |
| 668 |
% It may also arrive that we don't find that former message (|#6|) at all |
| 669 |
% then we will issue the usual \LaTeX\ |\PackageError| macro. |
| 670 |
% |
| 671 |
% \section{The message files} |
| 672 |
% |
| 673 |
% The default (English) message files should have the name |
| 674 |
% \texttt{\emph{package}-msg.tex} and localized ones should be |
| 675 |
% \texttt{\emph{language}\_\emph{package}-msg.tex}. |
| 676 |
% I would have prefered the file names begin with a dot which is |
| 677 |
% a hidden file in unix and thus avoid visual pollution inside packages |
| 678 |
% directories but, unfortunately, writing them with |doctrip| is |
| 679 |
% generally forbiden due to `|openout_any = p|' in |texmf.cnf| |
| 680 |
% configuration file. |
| 681 |
% |
| 682 |
% These files contain only the messages which could be requested |
| 683 |
% by the associated \texttt{\emph{package}}. It is important to say now |
| 684 |
% that when a message is split on multiple lines, each line must end |
| 685 |
% with "\verb*X %X" to avoid to loose the ending space when any is |
| 686 |
% required; this is due to the special |\read|ing process shown |
| 687 |
% \ifguide.\else |
| 688 |
% page \pageref{readingprocess}. |
| 689 |
% |
| 690 |
% \subsection*{About the \TeX\ Directory Structure} |
| 691 |
% |
| 692 |
% Notice that a specfic area where to place these files could be |
| 693 |
% defined in the TDS. |
| 694 |
% |
| 695 |
% \bigskip\noindent |
| 696 |
% WARNING regarding the TDS: currently file names in the TDS should not |
| 697 |
% exceed 8 characters to be 8.3 file system compliant. |
| 698 |
% Thus file names used by the \msgname\ package have |
| 699 |
% a great chance to be not TDS compliant. The files would not be used |
| 700 |
% also on ISO-9660 CD-ROMs. But, as said Karl Berry: "I rather |
| 701 |
% doubt TeX Live itself would be usable on an 8.3 filesystem these days". |
| 702 |
% \bigskip |
| 703 |
% \fi |
| 704 |
% |
| 705 |
% \subsection*{Message files contents} |
| 706 |
% |
| 707 |
% A typical file content is the following |msg-msg.tex| file, used by |
| 708 |
% the \msgname\ package itself: |
| 709 |
% |
| 710 |
%</code>\hard |
| 711 |
% \begin{macrocode} |
| 712 |
%<*english> |
| 713 |
% File: msg-msg.tex |
| 714 |
% Here are the English messages for the \msgname\ package. |
| 715 |
% |
| 716 |
% The following line is just for testing purpose: |
| 717 |
\msgencoding{}\msgheader{}\msgtrailer{} |
| 718 |
\msg{1}{\filedate\space \fileversion\space package to issue localized % |
| 719 |
messages, now loaded.}{} |
| 720 |
\msg{2}{invalid optional parameter provided:}{} |
| 721 |
\msg{3}{invalid language requested: ``\CurrentOption''}{} |
| 722 |
\msg{4}{This is to test the #1 feature}{} |
| 723 |
\msg{5}{``msg'' package line number }{\msgparti{issues % |
| 724 |
\#\msgid\ #1 message}} |
| 725 |
\msg{6}{msg package: UNUSUAL end of file reached when % |
| 726 |
\MessageBreak % |
| 727 |
loading \msg@filename\space file!}{} |
| 728 |
\msg{7}{\string\msg\space syntax error}{\help{last % special test case |
| 729 |
argument is missing.}} |
| 730 |
\msgheader{MESSAGE\space\msgid:\space``}\msgtrailer{''} |
| 731 |
\msg{8}{here is a customized message}{}% |
| 732 |
\msg{9}{here is a customized message % |
| 733 |
\MessageBreak which continuation is aligned}{} |
| 734 |
\msgheader{Message\space\msgid\space(msg):\space}\msgtrailer{} |
| 735 |
\msg*{10}{****** I emphasize: this is a WARNING! ****** % |
| 736 |
\MessageBreak ****** Be careful.^^J}{} |
| 737 |
\msgheader{}\msgtrailer{} |
| 738 |
\msg{11}{The msg package is in use with ``tracefiles'' option.}{} |
| 739 |
\msg{12}{A risk of infinite loop arose; % |
| 740 |
\MessageBreak % |
| 741 |
please check the message file: \msg@filename}% |
| 742 |
{\help{Look at rules to apply in messages files.}} |
| 743 |
\msg{*}{erroneous message id ``\msgid''}{} |
| 744 |
%</english> |
| 745 |
% \end{macrocode}\endhard |
| 746 |
% |
| 747 |
% If necessary, one can link |english_msg-msg| to that file, but since English |
| 748 |
% is always the default language for \LaTeX\ this is useless. |
| 749 |
% |
| 750 |
% The same messages, localized for French, are located in |
| 751 |
% \label{msgfiles} |
| 752 |
% the following messages file (|french_msg-msg.tex|): |
| 753 |
%\hard |
| 754 |
% \begin{macrocode} |
| 755 |
%<*french> |
| 756 |
% Fichier french_msg-msg.tex |
| 757 |
% Ici on trouve les messages en francais pour l'extension \msgname\ . |
| 758 |
% |
| 759 |
\msgencoding{}\msgheader{}\msgtrailer{} |
| 760 |
\msg{1}{\filedate\space chargement de l'extension de % |
| 761 |
localisation (\fileversion).}{} |
| 762 |
\msg{2}{le param\`etre optionnel est invalide}{} |
| 763 |
\msg{3}{le langage demand\'e (\CurrentOption) n'existe pas}{} |
| 764 |
\msg{4}{Ceci est pour tester le dispositif #1}{} |
| 765 |
\msg{5}{ligne }{\msgparti{de l'extension ``msg'' g\'en\`ere le % |
| 766 |
message de #1 \#\msgid}} |
| 767 |
\msg{6}{extension msg \string: fin ANORMALE de fichier rencontr\'ee % |
| 768 |
\MessageBreak % |
| 769 |
en chargeant le fichier \msg@filename\space\string!}{} |
| 770 |
\msg{7}{erreur de syntaxe \`a l'appel de \string\msg}% cas special de test |
| 771 |
{\help{il manque le dernier argument.}} |
| 772 |
\msgheader{MESSAGE\space\msgid\space\string:\space % |
| 773 |
\string<\string<\space} |
| 774 |
\msgtrailer{\space\string>\string>} |
| 775 |
\msg{8}{ceci est un message personnalis\'e}{} |
| 776 |
\msg{9}{ceci est un message personnalis\'e % |
| 777 |
\MessageBreak et align\'e}{} |
| 778 |
\msgheader{Message\space\msgid\space(msg)\space\string: % |
| 779 |
\space}\msgtrailer{} |
| 780 |
\msg*{10}{****** Je mets en valeur \string: % |
| 781 |
ceci est un AVERTISSEMENT ! ****** % |
| 782 |
\MessageBreak ****** Soyez prudent.^^J}{} |
| 783 |
\msgheader{}\msgtrailer{} |
| 784 |
\msg{11}{L'extension msg est en service avec l'option % |
| 785 |
\string<\string< tracefiles \string>\string>.}{} |
| 786 |
\msg{12}{Un risque de boucle infinie a \'et\'e rencontr\'e \string; % |
| 787 |
\MessageBreak % |
| 788 |
v\'erifier le fichier des message \string: \msg@filename}% |
| 789 |
{\help{Voir les r\`egles \`a appliquer dans les fichiers de messages.}} |
| 790 |
\msg{*}{le message id ``\msgid'' n'est pas r\'epertori\'e}{} |
| 791 |
%</french> |
| 792 |
% \end{macrocode}\endhard |
| 793 |
% |
| 794 |
%<*code> |
| 795 |
% \bigskip |
| 796 |
% |
| 797 |
% Notice that you can have messages which call any internal macro name |
| 798 |
% since the |\catcode| for |@| is assigned to letter when the message |
| 799 |
% file is read in. |
| 800 |
% |
| 801 |
% \ifguide\else |
| 802 |
% As you see, these files mostly contain |\msg| calls with three |
| 803 |
% arguments, so it's time now to look at this code. |
| 804 |
% |
| 805 |
% Notice that we don't use the real filenames in the above |
| 806 |
% |<*...>| tags since they contain an underscore character which |
| 807 |
% is not protected at this level when using the \textsl{ltxdoc} |
| 808 |
% document class. |
| 809 |
% \fi |
| 810 |
% |
| 811 |
% \section{The macros to use in message files} |
| 812 |
% |
| 813 |
% The simpliest way to code a message is: |
| 814 |
% \begin{center} |
| 815 |
% \fbox{\texttt{\textbackslash msg\{<\emph{id}>\}\{<\emph{message}>\}\{\}}} |
| 816 |
% |
| 817 |
% \end{center} |
| 818 |
% |
| 819 |
% The last message in the file should have \texttt{<\emph{id}>} equal |
| 820 |
% to \texttt* to say that, when reached, no valid \texttt{<\emph{id}>} |
| 821 |
% was found in the file and |
| 822 |
% the \msgname\ package should issue (or get or retrieve) that |
| 823 |
% error \texttt{\emph{message}}, which could be |
| 824 |
% e.g. |\msg{*}{erroneous message id ``\msgid''}|. |
| 825 |
% |
| 826 |
% \begin{macrocode} |
| 827 |
\catcode`\#=\active\def\set@argmsg{\def#1{\@argmsg}}% |
| 828 |
\catcode`\#=6% |
| 829 |
% \end{macrocode} |
| 830 |
% \begin{macro}{\msg}|#1#2#3| |
| 831 |
% \begin{macrocode} |
| 832 |
\def\msg{\let\@msg@gobble@space\@gobble% Should apply after firs call. |
| 833 |
\@ifstar{\def\@msgskip{^^J}\@msg}{\def\@msgskip{}\@msg}}% |
| 834 |
% \end{macrocode} |
| 835 |
% \end{macro} |
| 836 |
% \begin{macrocode} |
| 837 |
\long\def\@msg#1{\def\@msg@tempc{#1}\catcode`\#=\active% |
| 838 |
\def\@msg@tempd##1##2\void{\def\@msg@tempd{##2}% |
| 839 |
\let\@msg@tempe\empty% |
| 840 |
\ifx\@msg@tempd\empty% |
| 841 |
\def\@msg@tempe{##1}% |
| 842 |
\fi}% |
| 843 |
\@msg@tempd#1\void\relax% \@msg@tempe is the first #1 token. |
| 844 |
\let\themsgi\empty% We need to clean any |
| 845 |
\let\themsgii\empty% previous read |
| 846 |
\let\themsgiii\empty% message parts. |
| 847 |
\set@argmsg\@msg@% |
| 848 |
}% |
| 849 |
\def\@gobble@help#1#2{\@msgparts}% Case 2 lines \msg with \read |
| 850 |
\long\def\@msg@#1{\def\@msg@tempd{% but not \input. |
| 851 |
\ifx\@msginput@usual\@@input@msg@filename% |
| 852 |
\def\space{\noexpand\space}% |
| 853 |
\protected@edef\msg@header{\msg@header}% |
| 854 |
\protected@edef\msg@trailer{\msg@trailer}% |
| 855 |
\else% |
| 856 |
\edef\msg@header{\msg@header}% |
| 857 |
\edef\msg@trailer{\msg@trailer}% |
| 858 |
\fi% |
| 859 |
\edef\space{ }% |
| 860 |
\protected@xdef\themsg{% |
| 861 |
\@msgskip\msg@header#1\msg@trailer}% |
| 862 |
\def\space{ }% |
| 863 |
}% |
| 864 |
\catcode`\#=6\let\@msg@tempb\relax% |
| 865 |
\def\@msg@tempb{\@ne\tw@\thr@@\sixt@@n\@cclv}% |
| 866 |
\ifx\msgid\@msg@tempb% Check for any next message request. |
| 867 |
\global\let\msgid\@msg@tempc% |
| 868 |
\else% |
| 869 |
\ifx\msgid\@msg@tempc% Check for the previous id. |
| 870 |
\if@msgnext\def\msgid{\@ne\tw@\thr@@\sixt@@n\@cclv}% |
| 871 |
\fi% |
| 872 |
\fi% |
| 873 |
\fi% |
| 874 |
\ifx\msgid\@msg@tempc% Check for the "id". |
| 875 |
\let\@msgparts@ORnot\@msgparts@% |
| 876 |
\def\@msg@tempb{\endinput}% |
| 877 |
\if@msg@pkg@error% |
| 878 |
% \end{macrocode} |
| 879 |
% \begin{macro}{\help}|#1| |
| 880 |
% \begin{macrocode} |
| 881 |
\let\help\@firstofone% |
| 882 |
% \end{macrocode} |
| 883 |
% \end{macro} |
| 884 |
% \begin{macrocode} |
| 885 |
\def\@msgparts@ORnot{\endinput\def\@msg@txt@}% |
| 886 |
\fi% |
| 887 |
\def\@msg@tempf{}% |
| 888 |
\expandafter\@msg@tempd% |
| 889 |
\else\expandafter% |
| 890 |
\ifx\@msg@tempe*\let\@msgparts@ORnot\@msgparts@% |
| 891 |
\def\@msg@tempb{\endinput\@msg@tempd% |
| 892 |
\PackageWarningNoLine{msg}{\themsg% |
| 893 |
\themsgi\themsgii\themsgiii}% |
| 894 |
\global\let\@relaxORgobble\@gobble}% |
| 895 |
\else\let\@msgparts@ORnot\@gobble% |
| 896 |
\fi% |
| 897 |
\fi% |
| 898 |
\catcode`\#=\active |
| 899 |
\@ifnextchar\protect{\expandafter\@gobble@help}{\@msgparts}% |
| 900 |
}% |
| 901 |
% \end{macrocode} |
| 902 |
% |
| 903 |
% When the |\msg{*}| is reached the \msgname\ package will issue a |
| 904 |
% |\PackageWarning| with that message, but no line number is sent |
| 905 |
% because the message file is still not closed and the current line |
| 906 |
% number is that from the message file. The message is also forwarded |
| 907 |
% to the \TeX\ mouth even when an |\issuemsg| was requested. |
| 908 |
% |
| 909 |
% \subsection*{To build a \texttt{\textbackslash PackageError} |
| 910 |
% or \texttt{\textbackslash ClassError} message} |
| 911 |
% \label{buildPE} |
| 912 |
% |
| 913 |
% A |\PackageError| has a message part and a help part; these are |
| 914 |
% given as the following: |
| 915 |
% |
| 916 |
% \begin{minipage}[t]{0.9\textwidth} |
| 917 |
% \hrule\medskip |
| 918 |
% \begin{center} |
| 919 |
% \begin{tabbing} |
| 920 |
% |\msg{<|\emph{id}|>}{<|\emph{message-part}|>}|\=\kill^^A] |
| 921 |
% |\msg{<|\emph{id}|>}{<|\emph{message-part}|>}| |
| 922 |
% \> |{\help{<|\emph{help-part}|>}}| |
| 923 |
% \end{tabbing} |
| 924 |
% \end{center} |
| 925 |
% \medskip |
| 926 |
% \hrule\medskip |
| 927 |
% \end{minipage} |
| 928 |
% |
| 929 |
% \noindent in that special case you can't build a multi-parts message as |
| 930 |
% explained in the following section. |
| 931 |
% |
| 932 |
% \subsection*{To build a multi-parts message} |
| 933 |
% |
| 934 |
% When given, the optional argument provides 3 additional message parts. |
| 935 |
% Here is the syntax : |
| 936 |
% |
| 937 |
% \begin{minipage}[t]{0.9\textwidth} |
| 938 |
% \hrule\medskip |
| 939 |
% \begin{center} |
| 940 |
% \begin{tabbing} |
| 941 |
% |\msg{<|\emph{id}|>}{<|\emph{message-part1}|>}{|\=\kill^^A] |
| 942 |
% |\msg{<|\emph{id}|>}{<|\emph{message-part1}|>}{| |
| 943 |
% \> |\msgparti{<|\emph{message-part2}|>}|\\ |
| 944 |
% \> |\msgpartii{<|\emph{message-part3}|>}|\\ |
| 945 |
% \> |\msgpartiii{<|\emph{message-part4}|>}}| |
| 946 |
% \end{tabbing} |
| 947 |
% \end{center} |
| 948 |
% (Any |\msgparti*| can be omitted) |
| 949 |
% \medskip |
| 950 |
% \hrule\medskip |
| 951 |
% \end{minipage} |
| 952 |
% |
| 953 |
% When retrieved, |\themsg| will contain \emph{message-part1}, |
| 954 |
% |\themsgi| the \emph{message-part2}, |
| 955 |
% |\themsgii| the \emph{message-part3} and |
| 956 |
% |\themsgiii| the \emph{message-part4}. |
| 957 |
% One can build the wanted message with the mix of these four parts and other |
| 958 |
% materials. When requested via |\getmsg| or |\issuemsg| the four |
| 959 |
% parts are sticked in the usual order. |
| 960 |
% |
| 961 |
% \ifguide\else |
| 962 |
% These macros are defined when the last |\msg| argument is read in. |
| 963 |
% \fi |
| 964 |
% |
| 965 |
% \begin{macrocode} |
| 966 |
\long\def\@msgparts#1{\def\@msg@tempc{\catcode`\#=6% |
| 967 |
\def\@msg@tempb{\issuemsg[% |
| 968 |
\PackageError{\@msg@pkg}]{7}(msg)% |
| 969 |
\endinput}% |
| 970 |
\expandafter\@msg@tempb% |
| 971 |
}% |
| 972 |
\ifx\msg#1% When #1 is \msg it's sure the previous \msg |
| 973 |
\@msg@tempc% didn't provided the correct arguments. |
| 974 |
\else% |
| 975 |
\ifx\msgheader#1\@msg@tempc% ditto for \msgheader |
| 976 |
\else% |
| 977 |
\ifx\msgtrailer#1\@msg@tempc% ditto for \msgtrailer |
| 978 |
\else% |
| 979 |
\ifx\msgencoding#1\@msg@tempc% ditto for \msgencoding |
| 980 |
\else% |
| 981 |
\@msgparts@ORnot{#1}% |
| 982 |
\fi% |
| 983 |
\fi% |
| 984 |
\fi% |
| 985 |
\fi% |
| 986 |
\@ifnextchar\space{\@gobble}{}% Gobble any superfluous blank. |
| 987 |
}% |
| 988 |
% \end{macrocode} |
| 989 |
% \begin{macro}{\msgparti}|#1| |
| 990 |
% \begin{macro}{\msgpartii}|#1| |
| 991 |
% \begin{macro}{\msgpartiii}|#1| |
| 992 |
% \begin{macrocode} |
| 993 |
% |
| 994 |
\long\def\@msgparts@#1{\long\def\msgparti##1{\xdef\themsgi{##1}}% |
| 995 |
\long\def\help##1{\xdef\themsgi{\space help=##1}}% |
| 996 |
\long\def\helpi##1{\xdef\themsgi{\space help=##1}}% |
| 997 |
\long\def\msgpartii##1{\xdef\themsgii{##1}}% |
| 998 |
\long\def\msgpartiii##1{\xdef\themsgiii{##1}}% |
| 999 |
#1\catcode`\#=6\expandafter\@msg@tempb% |
| 1000 |
}% |
| 1001 |
% \end{macrocode} |
| 1002 |
% \end{macro}\end{macro}\end{macro} |
| 1003 |
% |
| 1004 |
% \section*{Input encoding discussion}\label{encodings} |
| 1005 |
% |
| 1006 |
% It is assumed that, defaultly, |\issuemsg| will finally provide a message |
| 1007 |
% to the console (without any encoding). |
| 1008 |
% The macro |\getmsg| is designed for typesetting (usually with an |
| 1009 |
% input encoding). Since |
| 1010 |
% |\retrievemsg|'s target is unknown, display or typesetting, we let |
| 1011 |
% the package or class maker to decide which input encoding has to be |
| 1012 |
% set up. |
| 1013 |
% |
| 1014 |
% If you want to issue a message but not to the console, you should |
| 1015 |
% probably use the macro |\issuemsgx| in place of |\issuemsg|. |
| 1016 |
% |
| 1017 |
% \subsection*{For messages issued to the console} |
| 1018 |
% |
| 1019 |
% If your messages can be coded in 7bits, no problem except that you |
| 1020 |
% probably need to avoid macros like |\aa|, |\oe|, |\ae|, etc. which |
| 1021 |
% can't output as expected on the console or log file. |
| 1022 |
% If your messages use 8bits characters, these 8bits characters will |
| 1023 |
% be output asis (until the \LaTeX\ team introduces a real output |
| 1024 |
% encoding for the console\footnote{The \msgname\ package is already designed |
| 1025 |
% for any output encoding; this is the \texttt{\textbackslash kbencoding} |
| 1026 |
% macro call which can do that (as currently done by my experimental |
| 1027 |
% \texttt{keyboard} package).}). |
| 1028 |
% |
| 1029 |
% \subsection*{For messages to be typeset} |
| 1030 |
% |
| 1031 |
% If any of your messages use at least one 8bits character, you need to |
| 1032 |
% specify which input encoding you are using: |
| 1033 |
% \begin{center} |
| 1034 |
% \fbox{\texttt{\textbackslash msgencoding\{<\emph{input encoding}>\}}} |
| 1035 |
% |
| 1036 |
% \end{center} |
| 1037 |
% you just have to give the name of the input encoding, exactly like |
| 1038 |
% with |\inputencoding| for the \texttt{inputenc} package. |
| 1039 |
% This is usually the first command in the messages file. |
| 1040 |
% |
| 1041 |
% \begin{macro}{\msgencoding}|#1| |
| 1042 |
% \begin{macrocode} |
| 1043 |
\let\@msgencoding\@gobble% Nearly null macro until \AtBeginDocument, |
| 1044 |
\def\msgencoding#1{\ifx\empty#1\else% just disactive 8bits chars. |
| 1045 |
\let\iterateORI\iterate% |
| 1046 |
\def\@msg@encoding{#1}% |
| 1047 |
\ifx\msg@cmd\issuemsg% If there is not output encoding: |
| 1048 |
\ifx\kbencoding\undefined%\inputencoding{ascii}% |
| 1049 |
\def\@msgenc@loop##1##2{\@tempcnta`##1\relax% |
| 1050 |
\loop\catcode\@tempcnta=11% |
| 1051 |
\ifnum\@tempcnta<`##2\relax% |
| 1052 |
\advance\@tempcnta\@ne% |
| 1053 |
\repeat}% |
| 1054 |
\@msgenc@loop\^^A\^^H% |
| 1055 |
\@msgenc@loop\^^K\^^K% |
| 1056 |
\@msgenc@loop\^^N\^^_% |
| 1057 |
\@msgenc@loop\^^?\^^ff% 128-255 |
| 1058 |
%%% \global\let\@originalkbe\relax% |
| 1059 |
\else% |
| 1060 |
%%% \xdef\@originalkbe{\noexpand\kbencoding{\@kbencoding}}% |
| 1061 |
\let\languagename\msg@languagename% |
| 1062 |
\let\msgidORI\msgid% Save current msgid because |
| 1063 |
\kbencoding{#1}% it may issue any message. |
| 1064 |
\let\msgid\msgidORI% Now reset it. |
| 1065 |
\@msg@moretrue% Continue file reading. |
| 1066 |
\fi% |
| 1067 |
\else\let\@latex@infoORI\@latex@info% |
| 1068 |
\let\@latex@info\@gobble% |
| 1069 |
\let\endinputBACK\endinput% |
| 1070 |
\let\endinput\endinputORI% |
| 1071 |
\let\msgidORI\msgid% Save current msgid because |
| 1072 |
\@msgencoding{#1}% it may issue any message. |
| 1073 |
\let\msgid\msgidORI% Now reset it. |
| 1074 |
\let\endinput\endinputBACK% |
| 1075 |
\let\@latex@info\@latex@infoORI% |
| 1076 |
\fi\makeatletter% |
| 1077 |
\let\iterate\iterateORI% |
| 1078 |
\fi% |
| 1079 |
}% |
| 1080 |
\let\@msg@encoding\empty% Unknown current encoding. |
| 1081 |
\ifx\kbencoding\undefined% |
| 1082 |
\AtBeginDocument{\let\@msgencoding\inputencoding}% |
| 1083 |
\let\inputencodingORI\inputencoding% Save \inputencoding code |
| 1084 |
\def\inputencoding#1{\def\@ieg{#1}\let\exec@ieg\relax% Avoid |
| 1085 |
\ifx\@ieg\@previeg\else% to load twice |
| 1086 |
\def\@previeg{#1}% the same encoding file. |
| 1087 |
\def\exec@ieg{\inputencodingORI\@ieg}% |
| 1088 |
\fi% |
| 1089 |
\exec@ieg% |
| 1090 |
}% |
| 1091 |
\else% |
| 1092 |
\AtBeginDocument{\let\@msgencoding\kbencoding}% |
| 1093 |
\fi% |
| 1094 |
% \end{macrocode} |
| 1095 |
% \subsection*{Disadvantage using \texttt{\textbackslash msgencoding}} |
| 1096 |
% |
| 1097 |
% As the \texttt{inputenc} package is automatically loaded when |
| 1098 |
% |\msgencoding| is executed, there is a risk you try loading again |
| 1099 |
% \texttt{inputenc} in the preamble via |\usepackage|. This is the case |
| 1100 |
% if any message was already issued by the \msgname\ package and then |
| 1101 |
% an option clash will occur and force you to put the encoding option |
| 1102 |
% as a global option in |\documentclass|. |
| 1103 |
% |
| 1104 |
% Since \msgname\ is calling |inputenc| there will be real difficulties |
| 1105 |
% to localize the |inputenc| package itself. |
| 1106 |
% \end{macro} |
| 1107 |
% |
| 1108 |
% \section*{The messages file rules} |
| 1109 |
% |
| 1110 |
% Due to the \ifguide |reading| process \else |
| 1111 |
% previous |\read| (page \pageref{readcode}) code \fi |
| 1112 |
% you should apply the following rules in |
| 1113 |
% a message file: |
| 1114 |
% \begin{description} |
| 1115 |
% \item [Rule 1:] A line can be a comment (begining with \%). |
| 1116 |
% \item [Rule 2:] A line can begin with |\msg|,|\msgheader|,|\msgtrailer| |
| 1117 |
% or |\msgencoding|. |
| 1118 |
% \item [Rule 3:] A |\msg| line can be continued on the next line(s), assuming |
| 1119 |
% each one ends with \verb*X %X. |
| 1120 |
% \item [Rule 4:] The following macros: |\msgheader|, |\msgtrailer|, |
| 1121 |
% or |\msgencoding| are always executed. |
| 1122 |
% \item [Rule 5:] Spacing inside |\msgheader| and |\msgtrailer| should be |
| 1123 |
% made only by the use of the macro |\space|. |
| 1124 |
% \item [Rule 6:] Any of these three macros should be expandable at any time. |
| 1125 |
% \item [Rule 7:] No other macro command can begin a line. |
| 1126 |
% \item [Rule 8:] All 8bits characters used should in the range specified |
| 1127 |
% by the macro command |\msgencoding|. |
| 1128 |
% \end{description} |
| 1129 |
% That's all! |
| 1130 |
% |
| 1131 |
% \subsection*{To build messages with header and/or trailer} |
| 1132 |
% |
| 1133 |
% \begin{macro}{\msgheader}|#1|\label{msgtrailerdef} |
| 1134 |
% \begin{macro}{\msgtrailer}|#1|\end{macro}\end{macro} |
| 1135 |
% \begin{macrocode} |
| 1136 |
\def\msgheader#1{\let\reserved@a\relax% |
| 1137 |
\def\msg@header{#1}\protect\@msgHTsptoken}% |
| 1138 |
\def\msgtrailer#1{\let\reserved@a\relax% |
| 1139 |
\def\msg@trailer{#1}\protect\@msgHTsptoken}% |
| 1140 |
\def\@msgHTsptoken{\@ifnextchar\@sptoken{\@msg@gobble@space% |
| 1141 |
\let\@msg@gobble@space\@gobble}% |
| 1142 |
{\let\@msg@gobble@space\@gobble}% |
| 1143 |
}% |
| 1144 |
% \end{macrocode} |
| 1145 |
% |
| 1146 |
% Before any |\msg| call you can specify which header and/or trailer you |
| 1147 |
% want in the following message or messages. You just have to specify them: |
| 1148 |
% |
| 1149 |
% \begin{minipage}[t]{0.4\textwidth} |
| 1150 |
% \hrule\medskip |
| 1151 |
% \begin{center} |
| 1152 |
% |\msgheader{<|\emph{my\_header}|>}|\\ |
| 1153 |
% |\msgtrailer{<|\emph{my\_trailer}|>}| |
| 1154 |
% \end{center} |
| 1155 |
% \hrule\medskip |
| 1156 |
% \end{minipage} |
| 1157 |
% |
| 1158 |
% When a message needs to be continued on the next line you just |
| 1159 |
% have to insert |\MessageBreak| where you want the new line will |
| 1160 |
% start and then the \msgname\ package will try to align the following |
| 1161 |
% text by adding the same number of |\space|s as tokens in the |
| 1162 |
% expanded |\msgheader|. That feature only applies with |\issuemsg| and |
| 1163 |
% only to the |<|\emph{message-part1}|>| (the three other message parts |
| 1164 |
% can not have any header or trailer). |
| 1165 |
% |
| 1166 |
% \subsection*{To emphasize a message} |
| 1167 |
% |
| 1168 |
% When you want to emphasize a message you just have to code the star form of |
| 1169 |
% the |\msg| macro: |
| 1170 |
% |
| 1171 |
% \begin{minipage}[t]{0.9\textwidth} |
| 1172 |
% \hrule\medskip |
| 1173 |
% \begin{center} |
| 1174 |
% \begin{tabbing} |
| 1175 |
% |\msg*{<|\emph{id}|>}{<|\emph{message-part1}|>}|\=\kill^^A] |
| 1176 |
% |\msg*{<|\emph{id}|>}{<|\emph{message-part1}|>}| |
| 1177 |
% \> |{<|\emph{part2}|}>}| |
| 1178 |
% \end{tabbing} |
| 1179 |
% \end{center} |
| 1180 |
% \hrule\medskip |
| 1181 |
% \end{minipage} |
| 1182 |
% |
| 1183 |
% and then the message will be issued after a line skip on the console and log. |
| 1184 |
% If your message ends with |^^J| another line will be skiped after. |
| 1185 |
% Obviously this feature only works with |\issuemsg| but not with |
| 1186 |
% |\getmsg| or |\retrievemsg|. |
| 1187 |
% |
| 1188 |
% \subsection*{Examples \& tests} |
| 1189 |
% |
| 1190 |
% We use message \# 5 of |msg-msg.tex| file as following: |
| 1191 |
% |
| 1192 |
% \noindent |
| 1193 |
% \def\foo#1{\retrievemsg5(msg)[#1]\themsg\the\inputlineno\ \themsgi} |
| 1194 |
% |\def\foo#1{\retrievemsg5(msg)[#1]\themsg\the\inputlineno\ \themsgi}| |
| 1195 |
% |
| 1196 |
% \medskip\noindent |
| 1197 |
% then |\emph{The \foo{test}}| will generate: |
| 1198 |
% |
| 1199 |
% \centerline{The \emph{\foo{test}}} |
| 1200 |
% |
| 1201 |
% \noindent |
| 1202 |
% In a French document, the code |\emph{La \foo{test}}| will issue: |
| 1203 |
% |
| 1204 |
% \bgroup\makeatletter\def\msg@languagename{french} |
| 1205 |
% \centerline{\emph{La \foo{test}}} |
| 1206 |
% \egroup |
| 1207 |
% |
| 1208 |
% \medskip |
| 1209 |
% We will now use the message \# 8 of |msg-msg.tex| file in order |
| 1210 |
% to show the customization set in that file. |
| 1211 |
% |
| 1212 |
% \medskip\noindent |
| 1213 |
% |\getmsg8(msg)| will generate:\\ |
| 1214 |
% \getmsg8(msg) |
| 1215 |
% |
| 1216 |
% The following |\texttt{\getmsg9(msg)}| using |
| 1217 |
% |\MessageBreak| will give at the console:\\% |
| 1218 |
% {\catcode`^^J=\active\let^^J\\%^^A We try to simulate the output console. |
| 1219 |
% \def\@msgalspace{\hbox{\space}}%^^A In order to simule \obeyspaces |
| 1220 |
% \def\space{\@sptoken}%^^A we used \space in \msgheader argument. |
| 1221 |
% \def\MessageBreak{^^J\expandafter\@msgalign\msg@header\void% |
| 1222 |
% \hbox{\space}}%^^A Please explain this tt behaviour... |
| 1223 |
% \texttt{\getmsg9(msg)}\\% |
| 1224 |
% } |
| 1225 |
% (same message issued to the console\issuemsg9(msg)).%^^A Issue it really. |
| 1226 |
% |
| 1227 |
% \noindent |
| 1228 |
% And in a French document, the same calls will issue:\\ |
| 1229 |
% \bgroup\makeatletter\def\msg@languagename{french}% |
| 1230 |
% \getmsg8(msg)\\% |
| 1231 |
% \catcode`<=12\catcode`>=12\relax%^^A To remove ltxdoc active chars. |
| 1232 |
% \catcode`^^J=\active\let^^J\\%^^A We try to simulate the output console. |
| 1233 |
% \def\@msgalspace{\hbox{\space}}%^^A In order to simule \obeyspaces |
| 1234 |
% \def\space{\@sptoken}%^^A We try to simulate the output console. |
| 1235 |
% \def\MessageBreak{^^J\expandafter\@msgalign\msg@header\void% |
| 1236 |
% \hbox{\space}}%^^A Please explain this tt behaviour... |
| 1237 |
% \texttt{\getmsg9(msg)} |
| 1238 |
% |
| 1239 |
% \egroup |
| 1240 |
% |
| 1241 |
% Below is a test of an emphasized message (|\texttt{\getmsg{10}(msg)}|): |
| 1242 |
% |
| 1243 |
% {\catcode`^^J=\active\let^^J\\%^^A We try to simulate the output console. |
| 1244 |
% \def\msg{\@ifstar{\def\@msgskip{\\}\@msg}{\def\@msgskip{}\@msg}}% |
| 1245 |
% \def\@msgalspace{\hbox{\space}}%^^A In order to simule \obeyspaces |
| 1246 |
% \def\space{\@sptoken}%^^A we used \space in \msgheader argument. |
| 1247 |
% \def\MessageBreak{^^J\expandafter\@msgalign\msg@header\void% |
| 1248 |
% \hbox{\space}}%^^A Please explain this tt behaviour... |
| 1249 |
% \noindent\texttt{\getmsg{10}(msg)}% |
| 1250 |
% } |
| 1251 |
% (same message issued to the console\issuemsg{10}(msg)). |
| 1252 |
% |
| 1253 |
% \section{Testing a message file} |
| 1254 |
% |
| 1255 |
% |
| 1256 |
% When you are building a messages file few typing errors can occur; so |
| 1257 |
% there is a need to test that file. You can do this by using the |
| 1258 |
% following macro call: |
| 1259 |
% |
| 1260 |
% \begin{center} |
| 1261 |
% \fbox{{\texttt{\textbackslash issueallmsg[<\emph{message\_macro}>](<\emph{package}>)}}} |
| 1262 |
% \end{center} |
| 1263 |
% |
| 1264 |
% All messages will be retrieved and issued as requested (with the message |
| 1265 |
% macro) but not, perhaps, with the exact macro call which will be used in the |
| 1266 |
% \LaTeXe\ package or document class. Specially, the |\help| macro call |
| 1267 |
% does nothing and |\msgpart|s are listed in the order found in the file. |
| 1268 |
% You should also notice that all macros used inside the |
| 1269 |
% messages should be expandable. This macro is allways executed with |
| 1270 |
% the \texttt{tracefiles}\footnote{I never found the right code |
| 1271 |
% to avoid a loop with |
| 1272 |
% \texttt{tracefiles} option...} option. |
| 1273 |
% |
| 1274 |
% Here is an example using the \msgname\ file |
| 1275 |
% (|\issueallmsg[\wlog](msg)|)% |
| 1276 |
% \wlog{^^J **************** Testing the file *************}% |
| 1277 |
% \issueallmsg[\wlog](msg) |
| 1278 |
% \wlog{^^J **************** The End of test *************}% |
| 1279 |
% please check the log file to find the output. |
| 1280 |
% |
| 1281 |
% \begin{macro}{\issueallmsg}|[#1](#2)|\label{issueallmsg} |
| 1282 |
% \begin{macrocode} |
| 1283 |
\def\issueallmsg{\bgroup\let\@@input@msg@filename\@msginput@usual% |
| 1284 |
\let\msg@cmd\issuemsg% |
| 1285 |
\@ifnextchar[{\i@sueallmsg}{\i@sueallmsg[\issuemsgio]}%] |
| 1286 |
}% |
| 1287 |
\def\i@sueallmsg[#1]{\let\@msg@iocmdn#1\i@@ueallmsg}% |
| 1288 |
\def\i@@ueallmsg(#1){\def\next{\i@@@eallmsg(#1)}% |
| 1289 |
\long\def\help##1{\xdef\themsgi{\space help=##1}}% |
| 1290 |
\let\if@msgnext\iftrue% begin/continue loop. |
| 1291 |
\def\msgid{\@ne\tw@\thr@@\sixt@@n\@cclv}% Set next one wanted. |
| 1292 |
\let\prev@msgid\msgid% Save previous id. |
| 1293 |
\i@@@eallmsg(#1)% Go for looping. |
| 1294 |
\let\if@msgnext\iffalse% |
| 1295 |
}% |
| 1296 |
\def\i@@@eallmsg(#1){\def\@tempa{\i@@uemsg[\@msg@iocmdn]}% |
| 1297 |
\let\themsg\empty% |
| 1298 |
\expandafter\@tempa\expandafter{\msgid}(#1)[]% Get it. |
| 1299 |
\def\@tempa{\let\if@msgnext\iffalse}% |
| 1300 |
\ifx\prev@msgid\msgid% |
| 1301 |
\@tempa% |
| 1302 |
\let\@@input@msg@filename\@msginput@usual% |
| 1303 |
\issuemsg[\PackageError{msg}]{12}(msg)% |
| 1304 |
\expandafter\stop% |
| 1305 |
\fi% |
| 1306 |
\let\prev@msgid\msgid% Save previous id. |
| 1307 |
\def\@tempa{*}% Check if last one. |
| 1308 |
\ifx\msgid\@tempa% |
| 1309 |
\let\next\egroup% This is the end. |
| 1310 |
\fi% |
| 1311 |
\let\msg@cmd\issuemsg% |
| 1312 |
\next% |
| 1313 |
}% |
| 1314 |
% \end{macrocode} |
| 1315 |
% \end{macro} |
| 1316 |
% \section{Output options} |
| 1317 |
% |
| 1318 |
% \begin{center} |
| 1319 |
% \fbox{\texttt{\textbackslash usepackage[<\emph{output-options}>]\{msg\}}}% |
| 1320 |
% \end{center} |
| 1321 |
% |
| 1322 |
% The output options provide to the \msgname\ package with a running |
| 1323 |
% macro name to issue any message, in replacement of the default |
| 1324 |
% |\issuemsgio| macro initialized at the begining (cf page~\pageref{msgio}). |
| 1325 |
% Currently the following macro names are defined as options: |
| 1326 |
% |
| 1327 |
% \begin{center} |
| 1328 |
% \def|{$\mid$} |
| 1329 |
% \fbox{\texttt{\textbackslash usepackage[message|wlog|typeout|kbtypeout]\{msg\}}}% |
| 1330 |
% \end{center} |
| 1331 |
% |
| 1332 |
% \begin{macrocode} |
| 1333 |
\ifx\intern@lc@llfrom\undefined% Options aren't declared for internal/kernel calls |
| 1334 |
\DeclareOption{message}{\let\issuemsgio\message}% TeX cs. |
| 1335 |
\DeclareOption{wlog}{\let\issuemsgio\wlog}% Plain TeX cs. |
| 1336 |
\DeclareOption{typeout}{\let\issuemsgio\typeout}% LaTeX cs. |
| 1337 |
\DeclareOption{kbtypeout}{\let\issuemsgio\kbtypeout}% Keyboard cs. |
| 1338 |
\fi% |
| 1339 |
% \end{macrocode} |
| 1340 |
% |
| 1341 |
% These options are related to basic messages macros but this |
| 1342 |
% is not an exhaustive list of macros which can be called by |
| 1343 |
% |\issuemsg|. Specially, |\PackageError| can also be used, |
| 1344 |
% as already discussed p.~\pageref{willingPE} and p.~\pageref{buildPE}. |
| 1345 |
% The last one macro name is coming from a package of mine |
| 1346 |
% (\textsf{keyboard}) doing input encoding and output decoding. |
| 1347 |
% |
| 1348 |
% \section{A tracing option} |
| 1349 |
% |
| 1350 |
% \begin{center} |
| 1351 |
% \fbox{\texttt{\textbackslash usepackage[<\emph{tracefiles}>]\{msg\}}}% |
| 1352 |
% \end{center} |
| 1353 |
% |
| 1354 |
% The \texttt{tracefiles} option changes the processing for reading |
| 1355 |
% messages files. Defaultly these files are not read with the usual |
| 1356 |
% |\input| macro and so the files are not listed in the \texttt{log} |
| 1357 |
% file. When giving the \texttt{tracefiles} option messages files |
| 1358 |
% are read with a |\input| macro like and then the full path names |
| 1359 |
% are listed. |
| 1360 |
% |
| 1361 |
% \begin{macrocode} |
| 1362 |
\ifx\intern@lc@llfrom\undefined% Options aren't declared for internal/kernel calls |
| 1363 |
\DeclareOption{tracefiles}{\let\@@input@msg@filename\@msginput@usual}% |
| 1364 |
\fi% |
| 1365 |
% \end{macrocode} |
| 1366 |
% |
| 1367 |
% \section{A special option} |
| 1368 |
% |
| 1369 |
% \begin{center} |
| 1370 |
% \fbox{\texttt{\textbackslash usepackage[<\emph{noop}>]\{msg\}}}% |
| 1371 |
% \end{center} |
| 1372 |
% |
| 1373 |
% The \texttt{noop} option changes the processing: don't read the |
| 1374 |
% messages files and just provides the "msgid" as text message with |
| 1375 |
% the following header: |0<msg noop>|. |
| 1376 |
% |
| 1377 |
% \begin{macrocode} |
| 1378 |
\ifx\intern@lc@llfrom\undefined% Options aren't declared for internal/kernel calls |
| 1379 |
\DeclareOption{noop}{\def\@@input@msg@filename{\xdef\themsg{0}% |
| 1380 |
\xdef\themsgi{\string<msg noop\string>\space\msgid}% |
| 1381 |
}% |
| 1382 |
}% |
| 1383 |
\fi% |
| 1384 |
% \end{macrocode} |
| 1385 |
% |
| 1386 |
% \section{Language options} |
| 1387 |
% |
| 1388 |
% \begin{center} |
| 1389 |
% \fbox{\texttt{\textbackslash usepackage[<\emph{output-options}>,<\emph{language-name}>]\{msg\}}}% |
| 1390 |
% \end{center} |
| 1391 |
% |
| 1392 |
% Defaultly messages are issued from the message file dedicated to the |
| 1393 |
% document running language. One can force the \msgname\ package to use |
| 1394 |
% a specific language (assuming it was defined in the \texttt{language.dat} |
| 1395 |
% file in use), just give it as the last option. |
| 1396 |
% |
| 1397 |
% \begin{macro}{\nativelanguage}|#1|\end{macro} |
| 1398 |
% \begin{macrocode} |
| 1399 |
\edef\nativelanguage{french}% This is my native language. |
| 1400 |
% \end{macrocode} |
| 1401 |
% This optional macro is usefull to understand and/or translate |
| 1402 |
% correctly the message files. Each package writer can define it |
| 1403 |
% as i currently do for the \msgname\ package here. To obtain messages |
| 1404 |
% in writer's native language, just call the \msgname\ package with |
| 1405 |
% the option `|native|': |
| 1406 |
% |
| 1407 |
% \begin{center} |
| 1408 |
% \fbox{\texttt{\textbackslash usepackage[<\emph{output-options}>,native]\{msg\}}}% |
| 1409 |
% \end{center} |
| 1410 |
% |
| 1411 |
% \ifguide\else |
| 1412 |
% The previous line of code declares |french| as an option for the \msgname\ |
| 1413 |
% package itself. Going this way we redefine |\packagewarning| we set at |
| 1414 |
% the begining page~\pageref{pw} and translate |\on@line| in French. |
| 1415 |
% I don't suggest to do the same for all other languages... this is just |
| 1416 |
% a native language privilege. |
| 1417 |
% \fi |
| 1418 |
% |
| 1419 |
% \begin{macrocode} |
| 1420 |
\let\on@lineORI\on@line% |
| 1421 |
\let\pwhORI\packagewarningheader% |
| 1422 |
\ifx\intern@lc@llfrom\undefined% Options aren't declared for internal/kernel calls |
| 1423 |
\DeclareOption{french}{% Mostly a testing option |
| 1424 |
% or have msg's messages in French. |
| 1425 |
\@msgINfrench}% |
| 1426 |
\fi% |
| 1427 |
\def\@msgINfrench{% |
| 1428 |
\def\on@line{ (voir le source, ligne \the\inputlineno)}% |
| 1429 |
\def\packagewarningheader##1{Extension ##1 : ATTENTION, }% |
| 1430 |
\def\msg@languagename{french}}% |
| 1431 |
% \end{macrocode} |
| 1432 |
% |
| 1433 |
% \ifguide\else |
| 1434 |
% It may occur that the |\languagename| is already set (e.g. in the |
| 1435 |
% \LaTeX\ format), so we test it; if French is set the \msgname\ package will |
| 1436 |
% then speak that language. |
| 1437 |
% |
| 1438 |
% \begin{macrocode} |
| 1439 |
\edef\@msg@tempa{french}\ifx\languagename\@msg@tempa\@msgINfrench\fi% |
| 1440 |
% \end{macrocode} |
| 1441 |
% Here is the code to process the last option: |
| 1442 |
% \fi |
| 1443 |
% \begin{macrocode} |
| 1444 |
% Last option will be the msg's language if defined (within the |
| 1445 |
% \texttt{language.dat} file in use). |
| 1446 |
\ifx\intern@lc@llfrom\undefined% Options aren't declared for internal/kernel calls |
| 1447 |
\DeclareOption*{% Once a language is provided we should |
| 1448 |
\let\on@line\on@lineORI% reset to default. |
| 1449 |
\let\packagewarningheader\pwhORI% |
| 1450 |
\def\@msg@tempa{native}% |
| 1451 |
\ifx\@msg@tempa\CurrentOption% |
| 1452 |
\let\msg@languagename\nativelanguage% |
| 1453 |
\else% |
| 1454 |
\expandafter% |
| 1455 |
\ifx\csname l@\CurrentOption\endcsname\relax% |
| 1456 |
\def\@msg@tempa{\retrievemsg3(msg)\PackageWarningNoLine{msg}% |
| 1457 |
{\themsg\themsgi\themsgii\themsgiii}}% |
| 1458 |
\else\def\@msg@tempa{\edef\msg@languagename{\CurrentOption}}% |
| 1459 |
\fi\@msg@tempa% |
| 1460 |
\fi% |
| 1461 |
}% |
| 1462 |
\fi% |
| 1463 |
% |
| 1464 |
% \end{macrocode} |
| 1465 |
% The last option, if undeclared as an option, is assumed to be |
| 1466 |
% a language name. If that language is unknown (i.e. undefined |
| 1467 |
% in the \texttt{language.dat} file in use) we issue a warning |
| 1468 |
% with message number 3, |
| 1469 |
% otherwise that language name will be now the prefix for all |
| 1470 |
% the message files names searchs. It overides any previously set |
| 1471 |
% (in format, package, ...) language name for use by the \msgname\ package. |
| 1472 |
% |
| 1473 |
% Notice that, when set (and forced) as option, the \msgname\ language |
| 1474 |
% name can't be changed any way inside the document (no language |
| 1475 |
% change can modify that). |
| 1476 |
% |
| 1477 |
% \ifguide\else |
| 1478 |
% \section{Finally} |
| 1479 |
% |
| 1480 |
% It's time now to process the options, get the \msgname\ package's banner |
| 1481 |
% and issue it as well in the log file. |
| 1482 |
% |
| 1483 |
% That's all for the code. |
| 1484 |
% \fi |
| 1485 |
% |
| 1486 |
% \begin{macrocode} |
| 1487 |
\ifx\intern@lc@llfrom\undefined% No process of options for internal/kernel calls |
| 1488 |
\ProcessOptions% Process options |
| 1489 |
\fi% |
| 1490 |
% Retrieve msg: \filedate\ msg package (\fileversion) loaded. |
| 1491 |
\bgroup% Protect from any setting. |
| 1492 |
\retrievemsg1(msg)% |
| 1493 |
\csname msg@MPC\endcsname% required when ltxdoc |
| 1494 |
\ProvidesPackage{msg}[\themsg]% Issue that message in log file with |
| 1495 |
\def\@msg@tempa{\retrievemsg{11}(msg)\wlog{\themsg}}% options messages. |
| 1496 |
\ifx\@@input@msg@filename\@msginput@usual\expandafter\@msg@tempa\fi% |
| 1497 |
\egroup% |
| 1498 |
%</code> |
| 1499 |
% \end{macrocode} |
| 1500 |
% \section{Migration scheme} |
| 1501 |
% |
| 1502 |
% If you want to migrate a document class ou package issuing messages |
| 1503 |
% in order it could be localized for any language, you just have |
| 1504 |
% to follow the following steps: |
| 1505 |
% |
| 1506 |
% \begin{enumerate} |
| 1507 |
% \item Chose the native language and create the related messages file. |
| 1508 |
% \item Chose the input encoding and define it in the messages file |
| 1509 |
% with the macro |\msgencoding|. |
| 1510 |
% \item Insert the final error message (|\msg(*){...}{}|). |
| 1511 |
% \item Isolate all messages in the code. |
| 1512 |
% \item Attach to each message a unique \textsl{id}. |
| 1513 |
% \item Comment each message argument(s) and put these arguments |
| 1514 |
% in the message file as: \\ |
| 1515 |
% |\msg{|\textsl{id}|}{|\textsl{argument1}|}{<|\textsl{argument2}|>}| |
| 1516 |
% \item Replace the message macro call (|\typeout| or |\wlog| or ...) |
| 1517 |
% by : \\ |
| 1518 |
% |\issuemsg[<|\textsl{message macro}|>]{|\textsl{id}|}(|\textsl{package}|)| |
| 1519 |
% \item Check the syntax carefully, specially, for error messages and |
| 1520 |
% when a parameter will be used. |
| 1521 |
% \item Test each message independtly and tune it considering the |
| 1522 |
% display option, the header and trailer facilities, etc. |
| 1523 |
% \item Test the messages file with |\issueallmsg|. |
| 1524 |
% \item Consider other translations of your native messages file. |
| 1525 |
% \item Release the new code along with its messages files. |
| 1526 |
% \end{enumerate} |
| 1527 |
% |
| 1528 |
% \section{Generated files} |
| 1529 |
% |
| 1530 |
% Currently the file |msg.ins| is the file to compile with (La)TeX |
| 1531 |
% to generate all the \msgname\ stuff. Here is |msg.ins| showing |
| 1532 |
% the |doctrip| generated files: |
| 1533 |
% |
| 1534 |
% \makeatletter% |
| 1535 |
% \def\verbatimfile#1{\begingroup\small\let\check@percent\relax\tt% |
| 1536 |
% \@verbatim\frenchspacing\@vobeyspaces% |
| 1537 |
% \@@input#1\endgroup}% |
| 1538 |
% \makeatother% |
| 1539 |
% \bigskip\hrule |
| 1540 |
% \verbatimfile{msg.ins}% |
| 1541 |
% |
| 1542 |
% \bigskip |
| 1543 |
% \hrule |
| 1544 |
% |
| 1545 |
% \section{Volunteers} |
| 1546 |
% |
| 1547 |
% Volunteers are welcome to translate the \msgname\ package message |
| 1548 |
% file (the English one or the native one in French) in their mother language. |
| 1549 |
% Lot of thanks to them! |
| 1550 |
% |
| 1551 |
% \section{Thanks} |
| 1552 |
% |
| 1553 |
% The following people contributed to that project and we really appreciate |
| 1554 |
% their effort for testing, translating, documenting, etc.: |
| 1555 |
% Hans~F.~Nordhaug, Harald~Harders. |
| 1556 |
% \vfill |
| 1557 |
% Enjoy! |
| 1558 |
% \vfill |
| 1559 |
% \centerline{$*$--$*$} |
| 1560 |
% \vfill |
| 1561 |
% \newpage |
| 1562 |
% \iffalse |
| 1563 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1564 |
%% \CharacterTable |
| 1565 |
%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z |
| 1566 |
%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z |
| 1567 |
%% Digits \0\1\2\3\4\5\6\7\8\9 |
| 1568 |
%% Exclamation \! Double quote \" Hash (number) \# |
| 1569 |
%% Dollar \$ Percent \% Ampersand \& |
| 1570 |
%% Acute accent \' Left paren \( Right paren \) |
| 1571 |
%% Asterisk \* Plus \+ Comma \, |
| 1572 |
%% Minus \- Point \. Solidus \/ |
| 1573 |
%% Colon \: Semicolon \; Less than \< |
| 1574 |
%% Equals \= Greater than \> Question mark \? |
| 1575 |
%% Commercial at \@ Left bracket \[ Backslash \\ |
| 1576 |
%% Right bracket \] Circumflex \^ Underscore \_ |
| 1577 |
%% Grave accent \` Left brace \{ Vertical bar \| |
| 1578 |
%% Right brace \} Tilde \~ |
| 1579 |
%% And any code from 128 to 255 |
| 1580 |
%% } |
| 1581 |
%% |
| 1582 |
% \fi |
| 1583 |
% \Finale%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |