Debian Codegraph @

texmf-dist/doc/latex/msg/msgtest.tex

raw
1 % This is a second test file for the "msg" package;
2 % the first one being the msg.dtx file itself.
3 %
4 % If you want to test your own language messages file,
5 % you can add your own \testlanguagefile at the end of this
6 % test file.
7 %
8 \documentclass[10pt]{article}
9 \usepackage{inputenc}% Load usual input encoding.
10 \let\kbencoding\undefined% Don't use now any output encoding.
11 \usepackage[T1]{fontenc}
12 \usepackage[norsk,german,frenchb,english]{babel}
13 \usepackage{shortvrb}
14 \usepackage{msg}
15 % \usepackage[tracefiles]{msg}% should also be tested with "tracefiles"
16 % \usepackage{msg,french}% should also be tested with your language.
17 % As LaTeX don't save the input encoding
18 % the "msg" package will do it.
19 \inputencoding{latin1}% To have a _global_ latin1 encoding
20 \begin{document}
21 \MakeShortVerb{|}
22
23 \title{The "msg" package test file}
24 \author{}\date{}
25 \maketitle
26
27 The following examples are going from the ``msg'' documentation itself.
28
29 \section*{Examples \& tests}
30 |\issuemsg1(msg)| will give at the console: \\
31 \centerline{\tt\getmsg1(msg)} but
32 |\issuemsg01(msg)| will give: \retrievemsg01(msg){\tt\themsg}.
33
34 While defining |\def\test#1{`\issuemsg4(msg)[#1]'}| the following call
35 |\emph{\test{SPECIAL}}| will print: \def\test#1{`\getmsg4(msg)[#1]'}\\
36 \centerline{\emph{\test{SPECIAL}}} showing that the argument
37 was inserted inside the message at the exact area, replacing |#1|.
38
39 In a French document, the same codes will issue:\\
40 \bgroup\selectlanguage{french}
41 \centerline{\tt\getmsg1(msg)}
42 \centerline{\retrievemsg01(msg){\tt\themsg}}
43 \centerline{\emph{\test{SPECIAL}}}
44 \egroup
45
46 \retrievemsg1(msg)
47 |\retrievemsg1(msg)| will set |\themsg| with the value of
48 the corresponding message ; nothing is issued at the console
49 nor in the log, except if the |<|\emph{id}|>| is not found in
50 the message file.
51
52 \noindent|\show\themsg| will explain:
53
54 \noindent|> \themsg=macro:|
55
56 \noindent|->|\texttt{\themsg}
57
58 \noindent In a French document, the same code will issue:
59
60 \bgroup\selectlanguage{french}
61 \retrievemsg1(msg)
62 \noindent|> \themsg=macro:|
63
64 \noindent|->|\texttt{\themsg}
65 \egroup
66
67 In case the message file is empty or do not contain neither the message
68 ``id'' nor any |\msg{*}| macro then we will obtain:
69 \bgroup\makeatletter
70 \catcode`*=\active\let*\relax%^^A for expansion when \read case.
71 \let\@msg@code@ast=\active%^^A to simulate a missing \msg{*}.
72 \retrievemsg999(msg)
73
74 \noindent|> \themsg=macro:|
75
76 \noindent|->|\texttt{\themsg}
77 \egroup
78
79 It may also arrive that we don't find that former message (|#6|) at all
80 then we will issue the usual \LaTeX\ |\PackageError| macro.
81
82 We use message \# 5 of |msg-msg.tex| file as following:
83
84 \noindent
85 \def\foo#1{\retrievemsg5(msg)[#1]\themsg\the\inputlineno\ \themsgi}
86 |\def\foo#1{\retrievemsg5(msg)[#1]\themsg\the\inputlineno\ \themsgi}|
87
88 \medskip\noindent
89 then |\emph{The \foo{test}}| will generate:
90
91 \centerline{The \emph{\foo{test}}}
92
93 \noindent
94 In a French document, the code |\emph{La \foo{test}}| will issue:
95
96 \bgroup\selectlanguage{french}
97 \centerline{\emph{La \foo{test}}}
98 \egroup
99
100 \medskip
101 We will now use the message \# 8 of |msg-msg.tex| file in order
102 to show the customization set in that file.
103
104 \medskip\noindent
105 |\getmsg8(msg)| will generate:\\
106 \getmsg8(msg)
107
108 The following |\texttt{\getmsg9(msg)}| using
109 |\MessageBreak| will give at the console:\\%
110 {\catcode`^^J=\active\let^^J\\%^^A We try to simulate the output console.
111 \def\@msgalspace{\hbox{\space}}%^^A In order to simule \obeyspaces
112 \def\space{\@sptoken}%^^A we used \space in \msgheader argument.
113 \def\MessageBreak{^^J\expandafter\@msgalign\msg@header\void%
114 \hbox{\space}}%^^A Please explain this tt behaviour...
115 \texttt{\getmsg9(msg)}\\%
116 }
117 (same message issued to the console\issuemsg9(msg)).%^^A Issue it really.
118
119 \noindent
120 And in a French document, the same calls will issue:\\
121 \bgroup\selectlanguage{french}%
122 \getmsg8(msg)\\%
123 \catcode`<=12\catcode`>=12\relax%^^A To remove ltxdoc active chars.
124 \catcode`^^J=\active\let^^J\\%^^A We try to simulate the output console.
125 \def\@msgalspace{\hbox{\space}}%^^A In order to simule \obeyspaces
126 \def\space{\@sptoken}%^^A We try to simulate the output console.
127 \def\MessageBreak{^^J\expandafter\@msgalign\msg@header\void%
128 \hbox{\space}}%^^A Please explain this tt behaviour...
129 \texttt{\getmsg9(msg)}
130
131 \egroup
132
133 Below is a test of an emphasized message (|\texttt{\getmsg{10}(msg)}|):
134
135 {\catcode`^^J=\active\let^^J\\%^^A We try to simulate the output console.
136 \def\msg{\@ifstar{\def\@msgskip{\\}\@msg}{\def\@msgskip{}\@msg}}%
137 \def\@msgalspace{\hbox{\space}}%^^A In order to simule \obeyspaces
138 \def\space{\@sptoken}%^^A we used \space in \msgheader argument.
139 \def\MessageBreak{^^J\expandafter\@msgalign\msg@header\void%
140 \hbox{\space}}%^^A Please explain this tt behaviour...
141 \noindent\texttt{\getmsg{10}(msg)}%
142 }
143 (same message issued to the console\issuemsg{10}(msg)).
144
145 Notice that the "msg" \emph{id} can be any string, not necessarily
146 a string of digits. Here is an expample :
147
148 \begin{verbatim}
149 \newcommand{\ID}{12}
150 \texttt{\getmsg{\ID}(msg)}
151 \end{verbatim}
152
153 \noindent
154 will generate the following: \\
155 \newcommand{\ID}{12}\texttt{\getmsg{\ID}(msg)}
156
157 \section*{Test the message encoding}
158
159 Temporary we reset the input encoding to \texttt{ascii} by
160 calling |\inputencoding{ascci}|
161 \bgroup
162 \inputencoding{ascii}
163 and switch to Norsk
164 \selectlanguage{norsk}%
165 to typeset the message \# 12 (|\getmsg{12}(msg}|):\\
166 ``\getmsg{12}(msg)''
167 \egroup
168
169 \section*{Message list for all messages files}
170
171 \long\def\testlanguagefile#1{%
172 {\selectlanguage{#1}% Don't forget to add it to \usepackage[...]{babel}
173 \parindent=0pt\tt
174 \textsf{Message list for the ``#1'' messages file:}\\[0.5\baselineskip]
175 \getmsg1(msg)\hfuzz\maxdimen\\
176 \getmsg2(msg)\hfuzz\maxdimen\\
177 \getmsg3(msg)\hfuzz\maxdimen\\
178 \getmsg4(msg)\hfuzz\maxdimen\\
179 \getmsg5(msg)\hfuzz\maxdimen\\
180 \getmsg6(msg)\hfuzz\maxdimen\\
181 \getmsg7(msg)\hfuzz\maxdimen\\
182 \getmsg8(msg)\hfuzz\maxdimen\\
183 \getmsg9(msg)\hfuzz\maxdimen\\
184 \getmsg{10}(msg)\hfuzz\maxdimen\\
185 \getmsg{11}(msg)\hfuzz\maxdimen\\
186 \getmsg{12}(msg)\hfuzz\maxdimen\\
187 \getmsg{*}(msg)\par\bigskip
188
189 \typeout{Message list for the ``#1'' messages file^^J}
190 \issueallmsg(msg)%
191 }}%
192
193 All messages for each language are now listed
194 in the document and on the console.
195
196 \testlanguagefile{english}
197 \testlanguagefile{french}
198 \testlanguagefile{norsk}
199 \testlanguagefile{german}
200
201 \section*{and now?}
202
203 You could try it on any of your document class or package...
204 good testing.
205 \end{document}