% 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}
