summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/msg/msgtest.tex
blob: 085b74616dae84ea65dd5bbe5543c11e652d8fbb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
% This is a second test file for the "msg" package;
% the first one being the msg.dtx file itself.
%
% If you want to test your own language messages file,
% you can add your own \testlanguagefile at the end of this
% test file.
%
\documentclass[10pt]{article}
  \usepackage{inputenc}% Load usual input encoding.
  \let\kbencoding\undefined% Don't use now any output encoding.
  \usepackage[T1]{fontenc}
  \usepackage[norsk,german,frenchb,english]{babel}
  \usepackage{shortvrb}
  \usepackage{msg}
% \usepackage[tracefiles]{msg}% should also be tested with "tracefiles"
% \usepackage{msg,french}% should also be tested with your language.  
                        % As LaTeX don't save the input encoding
                        % the "msg" package will do it.
  \inputencoding{latin1}% To have a _global_ latin1 encoding
\begin{document} 
\MakeShortVerb{|}

\title{The "msg" package test file}
\author{}\date{}
\maketitle

The following examples are going from the ``msg'' documentation itself.

\section*{Examples \& tests}
 |\issuemsg1(msg)| will give at the console: \\ 
 \centerline{\tt\getmsg1(msg)} but
 |\issuemsg01(msg)| will give: \retrievemsg01(msg){\tt\themsg}.

 While defining |\def\test#1{`\issuemsg4(msg)[#1]'}| the following call 
 |\emph{\test{SPECIAL}}| will print: \def\test#1{`\getmsg4(msg)[#1]'}\\
 \centerline{\emph{\test{SPECIAL}}}  showing that the argument
 was inserted inside the message at the exact area, replacing |#1|.

 In a French document, the same codes will issue:\\
 \bgroup\selectlanguage{french}
 \centerline{\tt\getmsg1(msg)}
 \centerline{\retrievemsg01(msg){\tt\themsg}}
 \centerline{\emph{\test{SPECIAL}}}
 \egroup

  \retrievemsg1(msg)
 |\retrievemsg1(msg)| will set |\themsg| with the value of
 the corresponding message ; nothing is issued at the console 
 nor in the log, except if the |<|\emph{id}|>| is not found in 
 the message file. 

 \noindent|\show\themsg| will explain:

 \noindent|> \themsg=macro:|

 \noindent|->|\texttt{\themsg}
 
 \noindent In a French document, the same code will issue:

 \bgroup\selectlanguage{french}
  \retrievemsg1(msg)
 \noindent|> \themsg=macro:|

 \noindent|->|\texttt{\themsg}
 \egroup

 In case the message file is empty or do not contain neither the message 
 ``id'' nor any |\msg{*}| macro then we will obtain:
 \bgroup\makeatletter
 \catcode`*=\active\let*\relax%^^A for expansion when \read case.
 \let\@msg@code@ast=\active%^^A to simulate a missing \msg{*}.
 \retrievemsg999(msg)

 \noindent|> \themsg=macro:|

 \noindent|->|\texttt{\themsg}
 \egroup

 It may also arrive that we don't find that former message (|#6|) at all
 then we will issue the usual \LaTeX\ |\PackageError| macro.

 We use message \# 5 of |msg-msg.tex| file as following:

 \noindent
  \def\foo#1{\retrievemsg5(msg)[#1]\themsg\the\inputlineno\ \themsgi}
 |\def\foo#1{\retrievemsg5(msg)[#1]\themsg\the\inputlineno\ \themsgi}|

 \medskip\noindent
 then |\emph{The \foo{test}}| will generate: 

 \centerline{The \emph{\foo{test}}}

 \noindent
 In a French document, the code |\emph{La \foo{test}}| will issue:

 \bgroup\selectlanguage{french}
 \centerline{\emph{La \foo{test}}}
 \egroup

 \medskip
 We will now use the message \# 8  of |msg-msg.tex| file in order
 to show the customization set in that file.

 \medskip\noindent
 |\getmsg8(msg)| will generate:\\
 \getmsg8(msg)

 The following |\texttt{\getmsg9(msg)}| using 
 |\MessageBreak| will give at the console:\\%
 {\catcode`^^J=\active\let^^J\\%^^A We try to simulate the output console.
  \def\@msgalspace{\hbox{\space}}%^^A In order to simule \obeyspaces
  \def\space{\@sptoken}%^^A  we used \space in \msgheader argument.
  \def\MessageBreak{^^J\expandafter\@msgalign\msg@header\void%
                    \hbox{\space}}%^^A Please explain this tt behaviour...
  \texttt{\getmsg9(msg)}\\%
 }
 (same message issued to the console\issuemsg9(msg)).%^^A Issue it really.
 
 \noindent
 And in a French document, the same calls will issue:\\
  \bgroup\selectlanguage{french}%
  \getmsg8(msg)\\%
  \catcode`<=12\catcode`>=12\relax%^^A To remove ltxdoc active chars.
  \catcode`^^J=\active\let^^J\\%^^A We try to simulate the output console.
  \def\@msgalspace{\hbox{\space}}%^^A In order to simule \obeyspaces
  \def\space{\@sptoken}%^^A We try to simulate the output console.
  \def\MessageBreak{^^J\expandafter\@msgalign\msg@header\void%
                    \hbox{\space}}%^^A Please explain this tt behaviour...
  \texttt{\getmsg9(msg)}
 
 \egroup

 Below is a test of an emphasized message (|\texttt{\getmsg{10}(msg)}|):

 {\catcode`^^J=\active\let^^J\\%^^A We try to simulate the output console.
  \def\msg{\@ifstar{\def\@msgskip{\\}\@msg}{\def\@msgskip{}\@msg}}%
  \def\@msgalspace{\hbox{\space}}%^^A In order to simule \obeyspaces
  \def\space{\@sptoken}%^^A  we used \space in \msgheader argument.
  \def\MessageBreak{^^J\expandafter\@msgalign\msg@header\void%
                    \hbox{\space}}%^^A Please explain this tt behaviour...
 \noindent\texttt{\getmsg{10}(msg)}%
 }
 (same message issued to the console\issuemsg{10}(msg)).

 Notice that the "msg" \emph{id} can be any string, not necessarily
a string of digits. Here is an expample :

\begin{verbatim}
\newcommand{\ID}{12}
\texttt{\getmsg{\ID}(msg)}
\end{verbatim}

\noindent
will generate the following: \\ 
\newcommand{\ID}{12}\texttt{\getmsg{\ID}(msg)}

\section*{Test the message encoding}

Temporary we reset the input encoding to \texttt{ascii} by
calling |\inputencoding{ascci}|
\bgroup
\inputencoding{ascii}
and switch to Norsk 
\selectlanguage{norsk}%
to typeset the message \# 12 (|\getmsg{12}(msg}|):\\
``\getmsg{12}(msg)''
\egroup

\section*{Message list for all messages files}

\long\def\testlanguagefile#1{%
{\selectlanguage{#1}% Don't forget to add it to \usepackage[...]{babel}
\parindent=0pt\tt
\textsf{Message list for the ``#1'' messages file:}\\[0.5\baselineskip]
\getmsg1(msg)\hfuzz\maxdimen\\
\getmsg2(msg)\hfuzz\maxdimen\\
\getmsg3(msg)\hfuzz\maxdimen\\
\getmsg4(msg)\hfuzz\maxdimen\\
\getmsg5(msg)\hfuzz\maxdimen\\
\getmsg6(msg)\hfuzz\maxdimen\\
\getmsg7(msg)\hfuzz\maxdimen\\
\getmsg8(msg)\hfuzz\maxdimen\\
\getmsg9(msg)\hfuzz\maxdimen\\
\getmsg{10}(msg)\hfuzz\maxdimen\\
\getmsg{11}(msg)\hfuzz\maxdimen\\
\getmsg{12}(msg)\hfuzz\maxdimen\\
\getmsg{*}(msg)\par\bigskip

\typeout{Message list for the ``#1'' messages file^^J}
\issueallmsg(msg)%
}}%

All messages for each language are now listed
in the document and on the console.

\testlanguagefile{english}
\testlanguagefile{french}
\testlanguagefile{norsk}
\testlanguagefile{german}

\section*{and now?}

You could try it on any of your document class or package...
good testing.
\end{document}