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
|
#
# Lang.pm
#
# $Id: Lang.pm,v 1.1.1.1 2001/05/24 15:57:41 sano Exp $
#
# Language support.
#
# © Copyright 1997, Cees de Groot
#
package LinuxDocTools::Lang;
use strict;
use vars qw($VERSION @ISA @EXPORT @Languages $translations);
require 5.0004;
use Exporter;
use LinuxDocTools::Vars;
$VERSION = sprintf("%d.%02d", q$Revision: 1.1.1.1 $ =~ /(\d+)\.(\d+)/);
@ISA = qw(Exporter);
@EXPORT = qw(Any2ISO ISO2Native ISO2English Xlat);
=head1 NAME
LinuxDocTools::Lang - language name and translation functions
=head1 SYNOPSIS
$isoname = Any2ISO ('deutsch');
$native = ISO2Native ('de');
$engname = ISO2English ('nederlands');
$global->{language} = 'nl';
$dutch = Xlat ('Table of Contents');
=head1 DESCRIPTION
B<LinuxDocTools::Lang> gives a simple interface to various forms of language
names, and provides a translation service. Languages can be specified in
three different ways: by their native name, by their english name, and
by their 2-letter ISO code. For example, you can specify the German
language as C<deutsch>, as C<german> or as C<de>.
=head1 FUNCTIONS
=over 4
=cut
@Languages = qw(
en english english
de deutsch german
nl nederlands dutch
fr français french
es español spanish
da dansk danish
no norsk norwegian
se svenska swedish
pt portuges portuguese
ca català catalan
it italiano italian
ro românã romanian
ja japanese japanese
pl polski polish
ko korean korean
fi suomi finnish
);
=item Any2ISO
Maps any of the three forms of languages to the ISO name. So either of
these invocations:
Any2ISO ('dutch');
Any2ISO ('nederlands');
Any2ISO ('nl');
will return the string C<"nl">.
=cut
sub Any2ISO
{
my $lang = shift (@_);
my $i = 0;
foreach my $l (@Languages)
{
($l eq $lang) && last;
$i++;
}
return $Languages[(int $i / 3) * 3];
}
=item ISO2Native
Maps the ISO code to the native name of the language.
=cut
sub ISO2Native
{
my $iso = shift (@_);
my $i = 0;
foreach my $l (@Languages)
{
($l eq $iso) && last;
$i++;
}
return $Languages[$i + 1];
}
=item ISO2English
Maps the ISO code to the english name of the language.
=cut
sub ISO2English
{
my $iso = shift (@_);
my $i = 0;
foreach my $l (@Languages)
{
($l eq $iso) && last;
$i++;
}
return $Languages[$i + 2];
}
=item Xlat
Translates its (English) argument to the language specified by the
current value of C<$gobal-E<gt>{language}>. The module, in its source
file, contains a data structure, indexed by the English strings, that
has all available translations.
=cut
sub Xlat
{
my ($txt) = @_;
return $txt if ($global->{language} eq "en");
return $translations->{$txt}{$global->{language}};
};
#
# By the time this grows big, we'll make up something else.
#
$translations = {
"Previous" => {
"nl" => "Terug",
"de" => "Zurück",
"es" => "Página anterior",
"fr" => "Page précédente",
"da" => "Forrige",
"no" => "Forrige",
"se" => "Föregående",
"pt" => "Página anterior",
"ca" => "Pàgina anterior",
"it" => "Indietro",
"ro" => "Înapoi",
"ja" => "Á°¤Î¥Ú¡¼¥¸",
"pl" => "Poprzedni",
"ko" => "ÀÌÀü",
"fi" => "Edellinen"
},
"Next" => {
"nl" => "Verder",
"de" => "Weiter",
"es" => "Página siguiente",
"fr" => "Page suivante",
"da" => "Næste",
"no" => "Neste",
"se" => "Nästa",
"pt" => "Página seguinte",
"ca" => "Pàgina següent",
"it" => "Avanti",
"ro" => "Înainte",
"ja" => "¼¡¤Î¥Ú¡¼¥¸",
"pl" => "Nastny",
"ko" => "´ÙÀ½",
"fi" => "Seuraava"
},
"Contents" => {
"nl" => "Inhoud",
"de" => "Inhalt",
"es" => "Índice general",
"fr" => "Table des matières",
"da" => "Indhold",
"no" => "Innhold",
"se" => "Innehållsförteckning",
"pt" => "Índice",
"ca" => "Índex",
"it" => "Indice",
"ro" => "Cuprins",
"ja" => "Ìܼ¡¤Ø",
"pl" => "Spis Trei",
"ko" => "Â÷·Ê",
"fi" => "Sisällys"
},
"Table of Contents" => {
"nl" => "Inhoudsopgave",
"de" => "Inhaltsverzeichnis",
"es" => "Índice general",
"fr" => "Table des matières",
"da" => "Indholdsfortegnelse",
"no" => "Innholdsfortegnelse",
"se" => "Innehållsförteckning",
"pt" => "Índice geral",
"ca" => "Índex general",
"it" => "Indice Generale",
"ro" => "Cuprins",
"ja" => "Ìܼ¡",
"pl" => "Spis Trei",
"ko" => "Â÷·Ê",
"fi" => "Sisällysluettelo"
}
};
=back
=head1 AUTHOR
Cees de Groot, C<E<lt>cg@pobox.comE<gt>>
=cut
1;
|