mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-11-14 15:18:44 +00:00
239 lines
4.5 KiB
Perl
239 lines
4.5 KiB
Perl
|
#
|
|||
|
# Lang.pm
|
|||
|
#
|
|||
|
# $Id: Lang.pm,v 1.1.1.1 2001/05/24 15:57:41 sano Exp $
|
|||
|
#
|
|||
|
# Language support.
|
|||
|
#
|
|||
|
# <20> 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<EFBFBD>ais french
|
|||
|
es espa<EFBFBD>ol spanish
|
|||
|
da dansk danish
|
|||
|
no norsk norwegian
|
|||
|
se svenska swedish
|
|||
|
pt portuges portuguese
|
|||
|
ca catal<EFBFBD> catalan
|
|||
|
it italiano italian
|
|||
|
ro rom<EFBFBD>n<EFBFBD> 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<75>ck",
|
|||
|
"es" => "P<>gina anterior",
|
|||
|
"fr" => "Page pr<70>c<EFBFBD>dente",
|
|||
|
"da" => "Forrige",
|
|||
|
"no" => "Forrige",
|
|||
|
"se" => "F<>reg<65>ende",
|
|||
|
"pt" => "P<>gina anterior",
|
|||
|
"ca" => "P<>gina anterior",
|
|||
|
"it" => "Indietro",
|
|||
|
"ro" => "<22>napoi",
|
|||
|
"ja" => "<22><><EFBFBD>Υڡ<CEA5><DAA1><EFBFBD>",
|
|||
|
"pl" => "Poprzedni",
|
|||
|
"ko" => "<22><><EFBFBD><EFBFBD>",
|
|||
|
"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<65>ent",
|
|||
|
"it" => "Avanti",
|
|||
|
"ro" => "<22>nainte",
|
|||
|
"ja" => "<22><><EFBFBD>Υڡ<CEA5><DAA1><EFBFBD>",
|
|||
|
"pl" => "Nastny",
|
|||
|
"ko" => "<22><><EFBFBD><EFBFBD>",
|
|||
|
"fi" => "Seuraava"
|
|||
|
},
|
|||
|
"Contents" => {
|
|||
|
"nl" => "Inhoud",
|
|||
|
"de" => "Inhalt",
|
|||
|
"es" => "<22>ndice general",
|
|||
|
"fr" => "Table des mati<74>res",
|
|||
|
"da" => "Indhold",
|
|||
|
"no" => "Innhold",
|
|||
|
"se" => "Inneh<65>llsf<73>rteckning",
|
|||
|
"pt" => "<22>ndice",
|
|||
|
"ca" => "<22>ndex",
|
|||
|
"it" => "Indice",
|
|||
|
"ro" => "Cuprins",
|
|||
|
"ja" => "<22>ܼ<EFBFBD><DCBC><EFBFBD>",
|
|||
|
"pl" => "Spis Trei",
|
|||
|
"ko" => "<22><><EFBFBD><EFBFBD>",
|
|||
|
"fi" => "Sis<69>llys"
|
|||
|
},
|
|||
|
"Table of Contents" => {
|
|||
|
"nl" => "Inhoudsopgave",
|
|||
|
"de" => "Inhaltsverzeichnis",
|
|||
|
"es" => "<22>ndice general",
|
|||
|
"fr" => "Table des mati<74>res",
|
|||
|
"da" => "Indholdsfortegnelse",
|
|||
|
"no" => "Innholdsfortegnelse",
|
|||
|
"se" => "Inneh<65>llsf<73>rteckning",
|
|||
|
"pt" => "<22>ndice geral",
|
|||
|
"ca" => "<22>ndex general",
|
|||
|
"it" => "Indice Generale",
|
|||
|
"ro" => "Cuprins",
|
|||
|
"ja" => "<22>ܼ<EFBFBD>",
|
|||
|
"pl" => "Spis Trei",
|
|||
|
"ko" => "<22><><EFBFBD><EFBFBD>",
|
|||
|
"fi" => "Sis<69>llysluettelo"
|
|||
|
}
|
|||
|
};
|
|||
|
|
|||
|
=back
|
|||
|
|
|||
|
=head1 AUTHOR
|
|||
|
|
|||
|
Cees de Groot, C<E<lt>cg@pobox.comE<gt>>
|
|||
|
|
|||
|
=cut
|
|||
|
|
|||
|
1;
|