-
Notifications
You must be signed in to change notification settings - Fork 11
/
babel.hva
195 lines (195 loc) · 8.26 KB
/
babel.hva
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
\ProvidesPackage{babel}
\RequirePackage{keyval}
%%%%
%%%% A simple command that takes language (say l) and
%%%% a) checks for existence and includes l.hva
%%%% b) calls the command \l@babel (in l.hva)
%%%% c) sets current language to l
%
\newcommand{\InitiateOption}[1]{%
\@ifundefined{bbl@#1@loaded}
{\let\csname bbl@#1@loaded\endcsname\relax%
\newenvironment{#1}{\begin{foreign@language@block}{#1}}{\end{foreign@language@block}}%
\newenvironment{#1*}{\begin{foreign@language@block}{#1}}{\end{foreign@language@block}}%
\@iffileexists{#1.hva}
{\input{#1.hva}\def\bbl@main@language{#1}}
{\hva@warn{Hevea babel '#1' not found, loading 'english' instead}%
\input{english.hva}\def\bbl@main@language{english}}}
{}}
%%%Default option (parses main=<lang>)
\define@key{babel}{main}{\def\bbl@realmain@language{#1}\InitiateOption{#1}}
\newcommand{\DefaultOption}[1]{\@setkeys{babel}{#1}}
\DeclareOption{@defopt}{\DefaultOption}%
%
%%%% Processing information for each optional argument
%
\DeclareOption{english}{\InitiateOption{english}}%
\DeclareOption{USenglish}{\InitiateOption{english}}%
\DeclareOption{french}{\InitiateOption{french}}%
\DeclareOption{frenchb}{\InitiateOption{french}}%
\DeclareOption{francais}{\InitiateOption{french}}%
\DeclareOption{german}{\InitiateOption{german}}%
\DeclareOption{greek}{\InitiateOption{greek}}%
\DeclareOption{ngerman}{\InitiateOption{german}}%
\DeclareOption{austrian}{\InitiateOption{austrian}}%
\DeclareOption{czech}{\InitiateOption{czech}}%
\DeclareOption{american}{\InitiateOption{english}}
\DeclareOption{croatian}{\InitiateOption{croatian}}%
\DeclareOption{catalan}{\InitiateOption{catalan}}%
\DeclareOption{brazil}{\InitiateOption{brazil}}%
\DeclareOption{danish}{\InitiateOption{danish}}%
\DeclareOption{dutch}{\InitiateOption{dutch}}%
\DeclareOption{esperanto}{\InitiateOption{esperanto}}%
\DeclareOption{finnish}{\InitiateOption{finnish}}%
\DeclareOption{galician}{\InitiateOption{galician}}%
\DeclareOption{italian}{\InitiateOption{italian}}%
\DeclareOption{magyar}{\InitiateOption{magyar}}%
\DeclareOption{norsk}{\InitiateOption{norsk}}%
\DeclareOption{nynorsk}{\InitiateOption{nynorsk}}%
\DeclareOption{polish}{\InitiateOption{polish}}%
\DeclareOption{portuguese}{\InitiateOption{portuguese}}%
\DeclareOption{romanian}{\InitiateOption{romanian}}%
\DeclareOption{russian}{\InitiateOption{russian}}%
\DeclareOption{slovak}{\InitiateOption{slovak}}%
\DeclareOption{slovene}{\InitiateOption{slovene}}%
\DeclareOption{spanish}{\InitiateOption{spanish}}%
\DeclareOption{swedish}{\InitiateOption{swedish}}%
\DeclareOption{turkish}{\InitiateOption{turkish}}%
%
%%%% Processing babel options postponed for later
%
%\ProcessOptions*
%
%%%% One variable for each supported language, to keep track of and to
%%%% change the current language. Might as well have used english itself
%%%% instead of \english@language!!!
%
\newcommand\english@language{english}%
\newcommand\french@language{french}%
\newcommand\german@language{german}%
\newcommand\ngerman@language{ngerman}%
\newcommand\greek@language{greek}%
\newcommand\american@language{american}%
\newcommand\austrian@language{austrian}%
\newcommand\brazil@language{brazil}%
\newcommand\catalan@language{catalan}%
\newcommand\croatian@language{croatian}%
\newcommand\czech@language{czech}%
\newcommand\danish@language{danish}%
\newcommand\dutch@language{dutch}%
\newcommand\esperanto@language{esperanto}%
\newcommand\finnish@language{finnish}%
\newcommand\galician@language{galician}%
\newcommand\italian@language{italian}%
\newcommand\magyar@language{magyar}%
\newcommand\norsk@language{norsk}%
\newcommand\nynorsk@language{nynorsk}%
\newcommand\polish@language{polish}%
\newcommand\portuguese@language{portuguese}%
\newcommand\romanian@language{romanian}%
\newcommand\russian@language{russian}%
\newcommand\slovak@language{slovak}%
\newcommand\slovene@language{slovene}%
\newcommand\spanish@language{spanish}%
\newcommand\swedish@language{swedish}%
\newcommand\turkish@language{turkish}%
%
%%%% Initializing \current@language before loading babel language packages.
%
\let\current@language\english@language
%
%%%% Support for the 'babel' command to select languages.
%
%Save definition of double quote (altered by german)
\let\@hevea@saved@dquote\@hevea@dquote
\newcommand{\selectlanguage}[1]{%
\def\language@packages{#1}%
\let\@hevea@dquote\@hevea@saved@dquote%Restore inocuous definition
\ifthenelse{\equal{#1}{german}} {%
\let\current@language\german@language \german@babel } {%
\ifthenelse{\equal{#1}{greek}} {%
\let\current@language\greek@language \greek@babel } {%
\ifthenelse{\equal{#1}{ngerman}} {%
\let\current@language\ngerman@language \german@babel } {%
\ifthenelse{\equal{#1}{english}} {%
\let\current@language\english@language \english@babel } {%
\ifthenelse{\equal{#1}{french}} {%
\let\current@language\french@language \french@babel } {%
\ifthenelse{\equal{#1}{american}} {%
\let\current@language\american@language \american@babel } {%
\ifthenelse{\equal{#1}{austrian}} {%
\let\current@language\austrian@language \austrian@babel } {%
\ifthenelse{\equal{#1}{brazil}} {%
\let\current@language\brazil@language \brazil@babel } {%
\ifthenelse{\equal{#1}{catalan}} {%
\let\current@language\catalan@language \catalan@babel } {%
\ifthenelse{\equal{#1}{croatian}} {%
\let\current@language\croatian@language \croatian@babel } {%
\ifthenelse{\equal{#1}{czech}} {%
\let\current@language\czech@language \czech@babel } {%
\ifthenelse{\equal{#1}{danish}} {%
\let\current@language\danish@language \danish@babel } {%
\ifthenelse{\equal{#1}{dutch}} {%
\let\current@language\dutch@language \dutch@babel } {%
\ifthenelse{\equal{#1}{esperanto}} {%
\let\current@language\esperanto@language \esperanto@babel } {%
\ifthenelse{\equal{#1}{finnish}} {%
\let\current@language\finnish@language \finnish@babel } {%
\ifthenelse{\equal{#1}{galician}} {%
\let\current@language\galician@language \galician@babel } {%
\ifthenelse{\equal{#1}{italian}} {%
\let\current@language\italian@language \italian@babel } {%
\ifthenelse{\equal{#1}{magyar}} {%
\let\current@language\magyar@language \magyar@babel } {%
\ifthenelse{\equal{#1}{norsk}} {%
\let\current@language\norsk@language \norsk@babel } {%
\ifthenelse{\equal{#1}{nynorsk}} {%
\let\current@language\nynorsk@language \nynorsk@babel } {%
\ifthenelse{\equal{#1}{polish}} {%
\let\current@languagepolish\@language \polish@babel } {%
\ifthenelse{\equal{#1}{portuguese}} {%
\let\current@language\portuguese@language \portuguese@babel } {%
\ifthenelse{\equal{#1}{romanian}} {%
\let\current@language\romanian@language \romanian@babel } {%
\ifthenelse{\equal{#1}{russian}} {%
\let\current@language\russian@language \russian@babel } {%
\ifthenelse{\equal{#1}{slovak}} {%
\let\current@language\slovak@language \slovak@babel } {%
\ifthenelse{\equal{#1}{slovene}} {%
\let\current@language\slovene@language \slovene@babel } {%
\ifthenelse{\equal{#1}{spanish}} {%
\let\current@language\spanish@language \spanish@babel } {%
\ifthenelse{\equal{#1}{swedish}} {%
\let\current@language\swedish@language \swedish@babel } {%
\ifthenelse{\equal{#1}{turkish}} {%
\let\current@language\turkish@language \turkish@babel } {%
}}}}}}}}}}}}}}}}}}}}}}}}}}}}}%
}%
%
\newenvironment{foreign@language@block}[1]%
{\let\outer@language=\current@language%
\@open{div}{class="foreignlanguage" lang="\map@lang@code{#1}"}%
\selectlanguage{#1}}%
{\@close{div}\selectlanguage{\outer@language}}
\newenvironment{foreign@language@inline}[1]%
{\let\outer@language=\current@language%
\@open{span}{class="foreignlanguage" lang="\map@lang@code{#1}"}%
\selectlanguage{#1}}%
{\@close{span}\selectlanguage{\outer@language}}
\newcommand{\foreignlanguage}[2]{%
\begin{foreign@language@inline}{#1}#2\end{foreign@language@inline}
}
\newenvironment{hyphenrules}[1]{\@span{lang="\map@lang@code{#1}"}}{}
%
%%%% Support for the 'babel' command for querying the current language.
%
\newcommand{\iflanguage}[3]{%
\ifthenelse{\equal{#1}{\current@language}}{#2}{#3}%
}%
%
%%%% Processing the optional arguments of the '\usepackage{babel}' command
%%%% For each option (language l), checks for l.hva and 'includes' it.
%
\ProcessOptions*%
\ifu\bbl@realmain@language\else\let\bbl@main@language\bbl@realmain@language\fi
\selectlanguage{\bbl@main@language}