summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/babel-contrib/piedmontese/piedmontese.dtx
blob: 781004cd998de5c4edbf11eb8c407ca127416605 (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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
% \iffalse
% !TEX encoding = UTF-8 Unicode
%
% file piedmontese.dtx file. By running this file through (pdf)LaTeX
% you get the documentation concerning the babel option for the language
% piedmontese. The extraction of the code apparently is done simultaneously
% with the production of the documentation.
%
%<*internal>
\begingroup
\input docstrip.tex
\keepsilent
\preamble
  ______________________________________________________
  The piedmontese file for babel
  Copyright (C) 2013 Claudio Beccari 
  All rights reserved

  License information appended

\endpreamble
\postamble
Copyright 2013 Claudio Beccari

Distributable under the LaTeX Project Public License,
version 1.3c or higher (your choice). The latest version of
this license is at: http://www.latex-project.org/lppl.txt

This work is "author-maintained"

This work consists of this file piedmontese.dtx,
and the derived files piedmontese.ldf and piedmontese.pdf.

\endpostamble
\askforoverwritefalse
\generate{\file{piedmontese.ldf}{\from{piedmontese.dtx}{code}}}
%
\def\tmpa{plain}
\ifx\tmpa\fmtname\endgroup\expandafter\bye\fi
\endgroup
%</internal>
% \fi
% \iffalse
% Tell the \LaTeX\ system who we are and write en entry
% in the transcript.
%<*dtx>
\ProvidesFile{piedmontese.dtx}
%</dtx>
%<code>\ProvidesLanguage{piedmontese}
%<code>\ProvidesFile{piedmontese}    
     [2013/02/12 v.1.0 Piedmontese support for the babel system]
%<*filedriver>
\documentclass{ltxdoc}
\newcommand*{\TeXhax}{\TeX hax}
\newcommand*{\babel}{\textsf{babel}}
\newcommand*{\langvar}{$\langle \mathit lang \rangle$}
\newcommand*{\note}[1]{}
\newcommand*{\Lopt}[1]{\textsf{#1}}
\newcommand*{\file}[1]{\texttt{#1}}
\begin{document}
 \DocInput{piedmontese.dtx}
\end{document}
%</filedriver>
%\fi
% \GetFileInfo{piedmontese.dtx}
%
% \section{The Piedmontese language}
%
%    The file \file{\filename}\footnote{The file described in this
%    section has version number \fileversion\ and was last revised on
%    \filedate.} defines all the language definition macros for the
%    Piedmontese language\footnote{Language ISO 639 coded with letter identification \texttt{pms}. This file was created by Claudio Beccari; see the source file for more information.}.
%
% \StopEventually{}
% 
%    The macro |\LdfInit| takes care of preventing that this file is
%    loaded more than once, checking the category code of the
%    \texttt{@} sign, etc. |\CurrentOption| is actually the name of 
%    language that was specified as an option in the call to \babel.
% \iffalse
%<*code>
% \fi
%    \begin{macrocode}
\LdfInit{\CurrentOption}{captions\CurrentOption}
%    \end{macrocode}
%
%    When this file is read as an option to the |\usepackage|
%    command that loads |babel|, \texttt{piedmontese} could be an
%    `unknown' language, or better, a language who's patterns have
%    not been loaded into the format file; in this case we have to
%    make it known. So we check for the existence of |\l@piedmontese|
%    to see whether we have to do something here. If the Piedmontese
%    patterns have not (yet) been loaded in the format file, we prefer
%    to declare |piedmontese| a dialect of |italian| rather than
%    a dialect of |english|, although we resort to the latter language
%    if also the Italian patterns have not been loaded into the format
%    file: this unfortunately happens when a basic \TeX\ system
%    installation is being used.
%
%    \begin{macrocode}
\LdfInit\CurrentOption{captions\CurrentOption}
\ifx\l@piedmontese\@undefined
    \@nopatterns{piedmontese}
    \ifx\l@italian\@undefined
        \@nopatterns{italian}
        \adddialect\l@piedmontese\l@english
    \else
        \adddialect\l@piedmontese\l@italian
    \fi
\fi 
%    \end{macrocode}
% \begin{macro}{\captionspiedmontese}
%    The macro |\captionspiedmontese| defines all strings used in the
%    four standard documentclasses provided with \LaTeX.
%    \begin{macrocode}
\@namedef{captions\CurrentOption}{%
    \def\prefacename{Prefassion}%
    \def\refname{Riferiment}%
    \def\abstractname{Somari}%
    \def\bibname{Bibliograf\`ia}%
    \def\chaptername{Cap\`itol}%
    \def\appendixname{Gionta}%
    \def\contentsname{T\`aula}%
    \def\listfigurename{Lista dle figure}%
    \def\listtablename{Lista dle tabele}%
    \def\indexname{T\`aula anal\`itica}%
    \def\figurename{Figura}%
    \def\tablename{Tabela}%
    \def\partname{Part}%
    \def\enclname{Gionta/e}%
    \def\ccname{Con c\`opia a}%
    \def\headtoname{P\"er}%
    \def\pagename{P\`agina}%
    \def\seename{v\"ed}%
    \def\alsoname{v\"ed anche}%
    \def\proofname{Dimostrassion}%
    \def\glossaryname{Glossari}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\datepiedmontese}
%    The macro |\datepiedmontese| redefines the command |\today| to
%    produce Piedmontese dates. The proposition corresponding to
%    `of' has three spellings in Piedmontese, one general (\"ed),  one to
%    be used in front of words starting with a group of consonants (d\"e),
%    and a third one, that derives from the latter by vocalic elision (d')
%    to be used in front of words starting with a vowel.
%    \begin{macrocode}
\@namedef{date\CurrentOption}{%
    \def\today{\number\day\space \space\ifcase\month\or
      \"ed gen\'e\or \"ed fevr\'e\or \"ed mars\or d'avril\or 
      \"ed maj\or \"ed giugn\or \"ed luj\or d'agost\or 
      d\"e st\`ember\or d'ot\'ober\or \"ed nov\`ember\or 
      d\"e dz\`ember\fi\space dal\space\number\year}}
%    \end{macrocode}
% \end{macro}
%
%  \begin{macro}{\piedmontesehyphenmins}
%    This macro is used to store the correct values of the hyphenation
%    parameters |\lefthyphenmin| and |\righthyphenmin|.
%    \begin{macrocode}
\providehyphenmins{\CurrentOption}{\tw@\tw@}
%    \end{macrocode}
%  \end{macro}
%
% \begin{macro}{\extraspiedmontese}
% \begin{macro}{\noextraspiedmontese}
%    The next step consists of defining commands to switch to (and
%    from) the Piedmontese language.
%
%    The macro |\extraspiedmontese| will perform all the extra
%    definitions needed for the Piedmontese language. The macro
%    |\noextraspiedmontese| is used to cancel the actions of
%    |\extraspiedmontese|. In particular we set pretty high
%    default values for widow and club lines and very high
%    demerits to avoid that the last line starts with the
%    second half of a hyphenated word. We also assign a non zero
%    value |\lccode| to the apostrophe that in Piedmontese is being
%    used for marking a vocalic elision and for apocope; by giving it a non 
%    zero value, the hyphenation algorithm treats the phrase formed
%    by the article or articulated preposition and the following
%    term as a single word and the patterns for Piedmontese take care
%    of avoiding line breaks right after the apostrophe.
%
%    \begin{macrocode}
\expandafter\addto\csname extras\CurrentOption\endcsname{%
  \babel@savevariable\clubpenalty
  \babel@savevariable\widowpenalty
  \babel@savevariable\@clubpenalty
  \clubpenalty3000\widowpenalty3000\@clubpenalty\clubpenalty}%
\expandafter\addto\csname extras\CurrentOption\endcsname{%
  \babel@savevariable\finalhyphendemerits
  \finalhyphendemerits50000000}%
\expandafter\addto\csname extras\CurrentOption\endcsname{%
  \lccode`'=`'}%
\expandafter\addto\csname noextras\CurrentOption\endcsname{%
  \lccode`'=0}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% The double straight quote |"| is made active for the current language.
% Its purpose is primarily to produce a diacritic hyphen; meanwhile 
% it is convenient to let it perform some other little tasks, such as
% to insert an etymologic line break, to simplify the |\slash| command, 
% and to ease the introduction of the double raised open quotes, that are
% cumbersome to insert with the Italian keyboard.
%
% The main activation of the |"| sign is done through the babel command
% |\declare@shorthand| that checks if the |"| has been used in math or
% in text mode; if in text mode, a service macro |\pms@next| is defined
% that upon execution lets a future token be aliased by the implicit token
% c.s. |\pms@temp|, while the actual work is demanded to |\pms@cwm|.
%    \begin{macrocode}
\initiate@active@char{"}%
\expandafter\addto\csname extras\CurrentOption\endcsname{%
\bbl@activate{"}\languageshorthands{piedmontese}}%
\declare@shorthand{piedmontese}{"}{%
\ifmmode
    \def\pms@next{''}%
\else
    \def\pms@next{\futurelet\pms@temp\pms@cwm}%
\fi
\pms@next
}%
%    \end{macrocode}
%
% After defining another service macro |\pms@@cwm| for introducing a
% discretionary break that may be inserted in the middle of a word,
% allowing another break point, but allowing hyphenation in both letter
% strings that sit at either side of this break point. The the |\pms@cwm|
% macro is defined to perform the necessary actions depending on the
% nature of the token memorized into the temporary c.s. |\pms@temp|.
% The |\@gobble| macro must be repeated at each test, otherwise it
% gobbles the |\fi| of the outer test. An |\expandafter| construct might
% reduce this repetition.
%    \begin{macrocode}
\DeclareRobustCommand*{\pms@cwm}{\let\pms@@next\relax
\ifcat\noexpand\pms@temp a%
    \def\pms@@next{\pms@@cwm}%
\else
    \ifx\pms@temp/%
        \def\pms@@next{\bbl@allowhyphens/\bbl@allowhyphens\@gobble}%
    \else
        \ifx\pms@temp-%
           \def\pms@@next{\bbl@allowhyphens-\bbl@allowhyphens\@gobble}%
        \else
            \ifx\pms@temp"%
                \def\pms@@next{``\expandafter\@gobble\string}%
            \fi
        \fi
    \fi
\fi
\pms@@next}%
%    \end{macrocode}
% \begin{macro}{\noextraspiedmontese}
% This done, we are ready to prepare the switch back to another language"
%    \begin{macrocode}
\expandafter\addto\csname noextras\CurrentOption\endcsname{%
\bbl@deactivate{"}}
%    \end{macrocode}
% \end{macro}
%
%    The macro |\ldf@finish| takes care of looking for a
%    configuration file, setting the main language to be switched on
%    at |\begin{document}| and resetting the category code of
%    \texttt{@} to its original value.
%    \begin{macrocode}
\ldf@finish\CurrentOption
%    \end{macrocode}
% \iffalse
%</code>
% \fi
% \CheckSum{226}
% \Finale
%\endinput