code:
#! /usr/local/bin/perl -w

# vim: tabstop=4
# vim: syntax=perl

use strict;

use Test;

BEGIN {
	plan tests => 7;
}

use Locale::Recode;

sub int2utf8;

my $local2ucs = {};
my $ucs2local = {};

while (<DATA>) {
	my ($code, $ucs, undef) = map { oct $_ } split /\s+/, $_;
	$local2ucs->{$code} = $ucs;
	$ucs2local->{$ucs} = $code unless $ucs == 0xfffd;
}

my $cd_int = Locale::Recode->new (from => 'TIS-620',
				  to => 'INTERNAL');
ok !$cd_int->getError;

my $cd_utf8 = Locale::Recode->new (from => 'TIS-620',
				   to => 'UTF-8');
ok !$cd_utf8->getError;

my $cd_rev = Locale::Recode->new (from => 'INTERNAL',
				  to => 'TIS-620');
ok !$cd_rev->getError;

# Convert into internal representation.
my $result_int = 1;
while (my ($code, $ucs) = each %$local2ucs) {
    my $outbuf = chr $code;
    my $result = $cd_int->recode ($outbuf);
    unless ($result && $outbuf->[0] == $ucs) {
    $result_int = 0;
    last;
    }
}
ok $result_int;

# Convert to UTF-8.
my $result_utf8 = 1;
while (my ($code, $ucs) = each %$local2ucs) {
    my $outbuf = chr $code;
    my $result = $cd_utf8->recode ($outbuf);
    unless ($result && $outbuf eq int2utf8 $ucs) {
        $result_utf8 = 0;
        last;
    }
}
ok $result_utf8;

# Convert from internal representation.
my $result_rev = 1;
while (my ($ucs, $code) = each %$ucs2local) {
    my $outbuf = [ $ucs ];
    my $result = $cd_rev->recode ($outbuf);
    unless ($result && $code == ord $outbuf) {
        $result_int = 0;
        last;
    }
}
ok $result_int;

# Check handling of unknown characters.
my $test_string1 = [ unpack 'c*', ' Supergirl ' ];
$test_string1->[0] = 0xad0be;
$test_string1->[-1] = 0xbeefbabe;
my $test_string2 = [ unpack 'c*', 'Supergirl' ];

my $unknown = "\x3f"; # Unknown character!

$cd_rev = Locale::Recode->new (from => 'INTERNAL',
		               to => 'TIS-620',
				)
&& $cd_rev->recode ($test_string1)
&& $cd_rev->recode ($test_string2)
&& ($test_string2 = $unknown . $test_string2 . $unknown);

ok $test_string1 eq $test_string2;

sub int2utf8
{
    my $ucs4 = shift;

    if ($ucs4 <= 0x7f) {
	return chr $ucs4;
    } elsif ($ucs4 <= 0x7ff) {
	return pack ("C2",
		     (0xc0 | (($ucs4 >> 6) & 0x1f)),
		     (0x80 | ($ucs4 & 0x3f)));
    } elsif ($ucs4 <= 0xffff) {
	return pack ("C3",
		     (0xe0 | (($ucs4 >> 12) & 0xf)),
		     (0x80 | (($ucs4 >> 6) & 0x3f)),
		     (0x80 | ($ucs4 & 0x3f)));
    } elsif ($ucs4 <= 0x1fffff) {
	return pack ("C4",
		     (0xf0 | (($ucs4 >> 18) & 0x7)),
		     (0x80 | (($ucs4 >> 12) & 0x3f)),
		     (0x80 | (($ucs4 >> 6) & 0x3f)),
		     (0x80 | ($ucs4 & 0x3f)));
    } elsif ($ucs4 <= 0x3ffffff) {
	return pack ("C5",
		     (0xf0 | (($ucs4 >> 24) & 0x3)),
		     (0x80 | (($ucs4 >> 18) & 0x3f)),
		     (0x80 | (($ucs4 >> 12) & 0x3f)),
		     (0x80 | (($ucs4 >> 6) & 0x3f)),
		     (0x80 | ($ucs4 & 0x3f)));
    } else {
	return pack ("C6",
		     (0xf0 | (($ucs4 >> 30) & 0x3)),
		     (0x80 | (($ucs4 >> 24) & 0x1)),
		     (0x80 | (($ucs4 >> 18) & 0x3f)),
		     (0x80 | (($ucs4 >> 12) & 0x3f)),
		     (0x80 | (($ucs4 >> 6) & 0x3f)),
		     (0x80 | ($ucs4 & 0x3f)));
    }
}

#Local Variables:
#mode: perl
#perl-indent-level: 4
#perl-continued-statement-offset: 4
#perl-continued-brace-offset: 0
#perl-brace-offset: -4
#perl-brace-imaginary-offset: 0
#perl-label-offset: -4
#tab-width: 4
#End:

__DATA__
0x00	0x0000
0x01	0x0001
0x02	0x0002
0x03	0x0003
0x04	0x0004
0x05	0x0005
0x06	0x0006
0x07	0x0007
0x08	0x0008
0x09	0x0009
0x0a	0x000a
0x0b	0x000b
0x0c	0x000c
0x0d	0x000d
0x0e	0x000e
0x0f	0x000f
0x10	0x0010
0x11	0x0011
0x12	0x0012
0x13	0x0013
0x14	0x0014
0x15	0x0015
0x16	0x0016
0x17	0x0017
0x18	0x0018
0x19	0x0019
0x1a	0x001a
0x1b	0x001b
0x1c	0x001c
0x1d	0x001d
0x1e	0x001e
0x1f	0x001f
0x20	0x0020
0x21	0x0021
0x22	0x0022
0x23	0x0023
0x24	0x0024
0x25	0x0025
0x26	0x0026
0x27	0x0027
0x28	0x0028
0x29	0x0029
0x2a	0x002a
0x2b	0x002b
0x2c	0x002c
0x2d	0x002d
0x2e	0x002e
0x2f	0x002f
0x30	0x0030
0x31	0x0031
0x32	0x0032
0x33	0x0033
0x34	0x0034
0x35	0x0035
0x36	0x0036
0x37	0x0037
0x38	0x0038
0x39	0x0039
0x3a	0x003a
0x3b	0x003b
0x3c	0x003c
0x3d	0x003d
0x3e	0x003e
0x3f	0x003f
0x40	0x0040
0x41	0x0041
0x42	0x0042
0x43	0x0043
0x44	0x0044
0x45	0x0045
0x46	0x0046
0x47	0x0047
0x48	0x0048
0x49	0x0049
0x4a	0x004a
0x4b	0x004b
0x4c	0x004c
0x4d	0x004d
0x4e	0x004e
0x4f	0x004f
0x50	0x0050
0x51	0x0051
0x52	0x0052
0x53	0x0053
0x54	0x0054
0x55	0x0055
0x56	0x0056
0x57	0x0057
0x58	0x0058
0x59	0x0059
0x5a	0x005a
0x5b	0x005b
0x5c	0x005c
0x5d	0x005d
0x5e	0x005e
0x5f	0x005f
0x60	0x0060
0x61	0x0061
0x62	0x0062
0x63	0x0063
0x64	0x0064
0x65	0x0065
0x66	0x0066
0x67	0x0067
0x68	0x0068
0x69	0x0069
0x6a	0x006a
0x6b	0x006b
0x6c	0x006c
0x6d	0x006d
0x6e	0x006e
0x6f	0x006f
0x70	0x0070
0x71	0x0071
0x72	0x0072
0x73	0x0073
0x74	0x0074
0x75	0x0075
0x76	0x0076
0x77	0x0077
0x78	0x0078
0x79	0x0079
0x7a	0x007a
0x7b	0x007b
0x7c	0x007c
0x7d	0x007d
0x7e	0x007e
0x7f	0x007f
0xa0	0xfffd
0xa1	0x0e01
0xa2	0x0e02
0xa3	0x0e03
0xa4	0x0e04
0xa5	0x0e05
0xa6	0x0e06
0xa7	0x0e07
0xa8	0x0e08
0xa9	0x0e09
0xaa	0x0e0a
0xab	0x0e0b
0xac	0x0e0c
0xad	0x0e0d
0xae	0x0e0e
0xaf	0x0e0f
0xb0	0x0e10
0xb1	0x0e11
0xb2	0x0e12
0xb3	0x0e13
0xb4	0x0e14
0xb5	0x0e15
0xb6	0x0e16
0xb7	0x0e17
0xb8	0x0e18
0xb9	0x0e19
0xba	0x0e1a
0xbb	0x0e1b
0xbc	0x0e1c
0xbd	0x0e1d
0xbe	0x0e1e
0xbf	0x0e1f
0xc0	0x0e20
0xc1	0x0e21
0xc2	0x0e22
0xc3	0x0e23
0xc4	0x0e24
0xc5	0x0e25
0xc6	0x0e26
0xc7	0x0e27
0xc8	0x0e28
0xc9	0x0e29
0xca	0x0e2a
0xcb	0x0e2b
0xcc	0x0e2c
0xcd	0x0e2d
0xce	0x0e2e
0xcf	0x0e2f
0xd0	0x0e30
0xd1	0x0e31
0xd2	0x0e32
0xd3	0x0e33
0xd4	0x0e34
0xd5	0x0e35
0xd6	0x0e36
0xd7	0x0e37
0xd8	0x0e38
0xd9	0x0e39
0xda	0x0e3a
0xdb	0xfffd
0xdc	0xfffd
0xdd	0xfffd
0xde	0xfffd
0xdf	0x0e3f
0xe0	0x0e40
0xe1	0x0e41
0xe2	0x0e42
0xe3	0x0e43
0xe4	0x0e44
0xe5	0x0e45
0xe6	0x0e46
0xe7	0x0e47
0xe8	0x0e48
0xe9	0x0e49
0xea	0x0e4a
0xeb	0x0e4b
0xec	0x0e4c
0xed	0x0e4d
0xee	0x0e4e
0xef	0x0e4f
0xf0	0x0e50
0xf1	0x0e51
0xf2	0x0e52
0xf3	0x0e53
0xf4	0x0e54
0xf5	0x0e55
0xf6	0x0e56
0xf7	0x0e57
0xf8	0x0e58
0xf9	0x0e59
0xfa	0x0e5a
0xfb	0x0e5b
0xfc	0xfffd
0xfd	0xfffd
0xfe	0xfffd
0xff	0xfffd


code:
#! /usr/local/bin/perl -w

# vim: syntax=perl
# vim: tabstop=4

use strict;

use Test;

BEGIN {
	plan tests => 7;
}

use Locale::Recode;

sub int2utf8;

my $codes = {};
while (<DATA>) {
	my ($code, $ucs4, undef) = split /\s+/, $_;
	$codes->{oct $code} = oct $ucs4;
}

my $cd_int = Locale::Recode->new (from => 'ASCII',
			     		  		 to => 'INTERNAL');
ok !$cd_int->getError;

my $cd_utf8 = Locale::Recode->new (from => 'ASCII',
								  to => 'UTF-8');
ok !$cd_utf8->getError;

my $cd_rev = Locale::Recode->new (from => 'INTERNAL',
								 to => 'ASCII');
ok !$cd_rev->getError;

# Convert into internal representation.
my $result_int = 1;
while (my ($code, $ucs4) = each %$codes) {
	my $outbuf = chr $code;
	my $result = $cd_int->recode ($outbuf);
	unless ($result && $outbuf->[0] == $ucs4) {
		$result_int = 0;
		last;
	}
}
ok $result_int;

# Convert to UTF-8.
my $result_utf8 = 1;
while (my ($code, $ucs4) = each %$codes) {
    my $outbuf = chr $code;
    my $result = $cd_utf8->recode ($outbuf);
    unless ($result && $outbuf eq int2utf8 $ucs4) {
        $result_utf8 = 0;
        last;
    }
}
ok $result_utf8;

# Convert from internal representation.
my $result_rev = 1;
while (my ($code, $ucs4) = each %$codes) {
    my $outbuf = [ $ucs4 ];
    my $result = $cd_rev->recode ($outbuf);
    unless ($result && $code == ord $outbuf) {
        $result_int = 0;
        last;
    }
}
ok $result_int;

# Check handling of unknown characters.
my $test_string1 = [ unpack 'c*', ' Supergirl ' ];
$test_string1->[0] = 0xad0be;
$test_string1->[-1] = 0xbeefbabe;
my $test_string2 = [ unpack 'c*', 'Supergirl' ];

my $unknown = "\x3f"; # Unknown character!

$cd_rev = Locale::Recode->new (from => 'INTERNAL',
                       to => 'ISO-8859-2',
                )
&& $cd_rev->recode ($test_string1)
&& $cd_rev->recode ($test_string2)
&& ($test_string2 = $unknown . $test_string2 . $unknown);

ok $test_string1 eq $test_string2;

sub int2utf8
{
    my $ucs4 = shift;

    if ($ucs4 <= 0x7f) {
		return chr $ucs4;
    } elsif ($ucs4 <= 0x7ff) {
		return pack ("C2",
			(0xc0 | (($ucs4 >> 6) & 0x1f)),
			(0x80 | ($ucs4 & 0x3f)));
    } elsif ($ucs4 <= 0xffff) {
		return pack ("C3",
			(0xe0 | (($ucs4 >> 12) & 0xf)),
			(0x80 | (($ucs4 >> 6) & 0x3f)),
			(0x80 | ($ucs4 & 0x3f)));
    } elsif ($ucs4 <= 0x1fffff) {
		return pack ("C4",
			(0xf0 | (($ucs4 >> 18) & 0x7)),
			(0x80 | (($ucs4 >> 12) & 0x3f)),
			(0x80 | (($ucs4 >> 6) & 0x3f)),
			(0x80 | ($ucs4 & 0x3f)));
    } elsif ($ucs4 <= 0x3ffffff) {
		return pack ("C5",
			(0xf0 | (($ucs4 >> 24) & 0x3)),
			(0x80 | (($ucs4 >> 18) & 0x3f)),
			(0x80 | (($ucs4 >> 12) & 0x3f)),
			(0x80 | (($ucs4 >> 6) & 0x3f)),
			(0x80 | ($ucs4 & 0x3f)));
    } else {
		return pack ("C6",
			(0xf0 | (($ucs4 >> 30) & 0x3)),
			(0x80 | (($ucs4 >> 24) & 0x1)),
			(0x80 | (($ucs4 >> 18) & 0x3f)),
			(0x80 | (($ucs4 >> 12) & 0x3f)),
			(0x80 | (($ucs4 >> 6) & 0x3f)),
			(0x80 | ($ucs4 & 0x3f)));
    }
}

# Local Variables:
# mode: perl
# perl-indent-level: 4
# perl-continued-statement-offset: 4
# perl-continued-brace-offset: 0
# perl-brace-offset: -4
# perl-brace-imaginary-offset: 0
# perl-label-offset: -4
# cperl-indent-level: 4
# cperl-continued-statement-offset: 2
# tab-width: 4
# End:

__DATA__
0x00	0x0000
0x01	0x0001
0x02	0x0002
0x03	0x0003
0x04	0x0004
0x05	0x0005
0x06	0x0006
0x07	0x0007
0x08	0x0008
0x09	0x0009
0x0A	0x000A
0x0B	0x000B
0x0C	0x000C
0x0D	0x000D
0x0E	0x000E
0x0F	0x000F
0x10	0x0010
0x11	0x0011
0x12	0x0012
0x13	0x0013
0x14	0x0014
0x15	0x0015
0x16	0x0016
0x17	0x0017
0x18	0x0018
0x19	0x0019
0x1A	0x001A
0x1B	0x001B
0x1C	0x001C
0x1D	0x001D
0x1E	0x001E
0x1F	0x001F
0x20	0x0020
0x21	0x0021
0x22	0x0022
0x23	0x0023
0x24	0x0024
0x25	0x0025
0x26	0x0026
0x27	0x0027
0x28	0x0028
0x29	0x0029
0x2A	0x002A
0x2B	0x002B
0x2C	0x002C
0x2D	0x002D
0x2E	0x002E
0x2F	0x002F
0x30	0x0030
0x31	0x0031
0x32	0x0032
0x33	0x0033
0x34	0x0034
0x35	0x0035
0x36	0x0036
0x37	0x0037
0x38	0x0038
0x39	0x0039
0x3A	0x003A
0x3B	0x003B
0x3C	0x003C
0x3D	0x003D
0x3E	0x003E
0x3F	0x003F
0x40	0x0040
0x41	0x0041
0x42	0x0042
0x43	0x0043
0x44	0x0044
0x45	0x0045
0x46	0x0046
0x47	0x0047
0x48	0x0048
0x49	0x0049
0x4A	0x004A
0x4B	0x004B
0x4C	0x004C
0x4D	0x004D
0x4E	0x004E
0x4F	0x004F
0x50	0x0050
0x51	0x0051
0x52	0x0052
0x53	0x0053
0x54	0x0054
0x55	0x0055
0x56	0x0056
0x57	0x0057
0x58	0x0058
0x59	0x0059
0x5A	0x005A
0x5B	0x005B
0x5C	0x005C
0x5D	0x005D
0x5E	0x005E
0x5F	0x005F
0x60	0x0060
0x61	0x0061
0x62	0x0062
0x63	0x0063
0x64	0x0064
0x65	0x0065
0x66	0x0066
0x67	0x0067
0x68	0x0068
0x69	0x0069
0x6A	0x006A
0x6B	0x006B
0x6C	0x006C
0x6D	0x006D
0x6E	0x006E
0x6F	0x006F
0x70	0x0070
0x71	0x0071
0x72	0x0072
0x73	0x0073
0x74	0x0074
0x75	0x0075
0x76	0x0076
0x77	0x0077
0x78	0x0078
0x79	0x0079
0x7A	0x007A
0x7B	0x007B
0x7C	0x007C
0x7D	0x007D
0x7E	0x007E
0x7F	0x007F

repo_name: mthl/texinfo

license: mit


code:
#! /usr/local/bin/perl -w

# vim: syntax=perl
# vim: tabstop=4

use strict;

use Test;

BEGIN {
	plan tests => 5;
}

use Locale::Recode;

sub int2utf8;

my $codes = {};
foreach (0 .. 0xcfff
		 # 0 .. 0x11_000,
		 # 0x10_000 .. 0x11_000,
	     # 0x200_000 .. 0x201_000,      # :-(  # Not supported by Perl 5.6
	     # 0x4_000_000 .. 0x4_001_000,  # :-(  # Not supported by Perl 5.6
         ) {
	$codes->{$_} = int2utf8 $_;
}

my $cd_int = Locale::Recode->new (from => 'UTF-8',
			     		  		 to => 'INTERNAL');
ok !$cd_int->getError;

my $cd_rev = Locale::Recode->new (from => 'INTERNAL',
								 to => 'UTF-8');
ok !$cd_rev->getError;

# Convert into internal representation.
my $result_int = 1;
while (my ($ucs4, $outbuf) = each %$codes) {
	my $result = $cd_int->recode ($outbuf);
	unless ($result && $outbuf->[0] == $ucs4) {
		$result_int = 0;
		last;
	}
}
ok $result_int;

# Convert from internal representation.
my $result_rev = 1;
if (1) {
	# FIXME: This test only succeeds with use bytes in Perl >= 5.8.0.
	# However, this will fail with Perl <= Perl 5.6.0. :-(
	# FIXME: Is it really fixed now?
while (my ($ucs4, $code) = each %$codes) {
    my $outbuf = [ $ucs4 ];
    my $result = $cd_rev->recode ($outbuf);
    unless ($result && $code eq $outbuf) {
        $result_rev = 0;
        last;
    }
}
}
ok $result_rev;

# Check handling of unknown characters.  This assumes that the
# character set is a subset of US-ASCII.
my $test_string1 = "\xffSupergirl\xff";
$cd_rev = Locale::Recode->new (from => 'ASCII',
							   to => 'UTF-8',
							  );
$result_rev = $cd_rev->recode ($test_string1);
ok $result_rev && $test_string1 eq "�Supergirl�";

sub int2utf8
{
    my $ucs4 = shift;

    if ($ucs4 <= 0x7f) {
		return chr $ucs4;
    } elsif ($ucs4 <= 0x7ff) {
		return pack ("C2",
			(0xc0 | (($ucs4 >> 6) & 0x1f)),
			(0x80 | ($ucs4 & 0x3f)));
    } elsif ($ucs4 <= 0xffff) {
		return pack ("C3",
			(0xe0 | (($ucs4 >> 12) & 0xf)),
			(0x80 | (($ucs4 >> 6) & 0x3f)),
			(0x80 | ($ucs4 & 0x3f)));
    } elsif ($ucs4 <= 0x1fffff) {
		return pack ("C4",
			(0xf0 | (($ucs4 >> 18) & 0x7)),
			(0x80 | (($ucs4 >> 12) & 0x3f)),
			(0x80 | (($ucs4 >> 6) & 0x3f)),
			(0x80 | ($ucs4 & 0x3f)));
    } elsif ($ucs4 <= 0x3ffffff) {
		return pack ("C5",
			(0xf0 | (($ucs4 >> 24) & 0x3)),
			(0x80 | (($ucs4 >> 18) & 0x3f)),
			(0x80 | (($ucs4 >> 12) & 0x3f)),
			(0x80 | (($ucs4 >> 6) & 0x3f)),
			(0x80 | ($ucs4 & 0x3f)));
    } else {
		return pack ("C6",
			(0xf0 | (($ucs4 >> 30) & 0x3)),
			(0x80 | (($ucs4 >> 24) & 0x1)),
			(0x80 | (($ucs4 >> 18) & 0x3f)),
			(0x80 | (($ucs4 >> 12) & 0x3f)),
			(0x80 | (($ucs4 >> 6) & 0x3f)),
			(0x80 | ($ucs4 & 0x3f)));
    }
}

# Local Variables:
# mode: perl
# perl-indent-level: 4
# perl-continued-statement-offset: 4
# perl-continued-brace-offset: 0
# perl-brace-offset: -4
# perl-brace-imaginary-offset: 0
# perl-label-offset: -4
# cperl-indent-level: 4
# cperl-continued-statement-offset: 2
# tab-width: 4
# End:


code:
#! /usr/local/bin/perl -w

# vim: tabstop=4
# vim: syntax=perl

use strict;

use Test;

BEGIN {
	plan tests => 7;
}

use Locale::Recode;

sub int2utf8;

my $local2ucs = {};
my $ucs2local = {};

while (<DATA>) {
	my ($code, $ucs, undef) = map { oct $_ } split /\s+/, $_;
	$local2ucs->{$code} = $ucs;
	$ucs2local->{$ucs} = $code unless $ucs == 0xfffd;
}

my $cd_int = Locale::Recode->new (from => 'VISCII',
				  to => 'INTERNAL');
ok !$cd_int->getError;

my $cd_utf8 = Locale::Recode->new (from => 'VISCII',
				   to => 'UTF-8');
ok !$cd_utf8->getError;

my $cd_rev = Locale::Recode->new (from => 'INTERNAL',
				  to => 'VISCII');
ok !$cd_rev->getError;

# Convert into internal representation.
my $result_int = 1;
while (my ($code, $ucs) = each %$local2ucs) {
    my $outbuf = chr $code;
    my $result = $cd_int->recode ($outbuf);
    unless ($result && $outbuf->[0] == $ucs) {
	$result_int = 0;
	last;
    }
}
ok $result_int;

# Convert to UTF-8.
my $result_utf8 = 1;
while (my ($code, $ucs) = each %$local2ucs) {
    my $outbuf = chr $code;
    my $result = $cd_utf8->recode ($outbuf);
    unless ($result && $outbuf eq int2utf8 $ucs) {
        $result_utf8 = 0;
        last;
    }
}
ok $result_utf8;

# Convert from internal representation.
my $result_rev = 1;
while (my ($ucs, $code) = each %$ucs2local) {
    my $outbuf = [ $ucs ];
    my $result = $cd_rev->recode ($outbuf);
    unless ($result && $code == ord $outbuf) {
        $result_int = 0;
        last;
    }
}
ok $result_int;

# Check handling of unknown characters.
my $test_string1 = [ unpack 'c*', ' Supergirl ' ];
$test_string1->[0] = 0xad0be;
$test_string1->[-1] = 0xbeefbabe;
my $test_string2 = [ unpack 'c*', 'Supergirl' ];

my $unknown = "\x3f"; # Unknown character!

$cd_rev = Locale::Recode->new (from => 'INTERNAL',
		               to => 'VISCII',
				)
&& $cd_rev->recode ($test_string1)
&& $cd_rev->recode ($test_string2)
&& ($test_string2 = $unknown . $test_string2 . $unknown);

ok $test_string1 eq $test_string2;

sub int2utf8
{
    my $ucs4 = shift;

    if ($ucs4 <= 0x7f) {
	return chr $ucs4;
    } elsif ($ucs4 <= 0x7ff) {
	return pack ("C2",
		     (0xc0 | (($ucs4 >> 6) & 0x1f)),
		     (0x80 | ($ucs4 & 0x3f)));
    } elsif ($ucs4 <= 0xffff) {
	return pack ("C3",
		     (0xe0 | (($ucs4 >> 12) & 0xf)),
		     (0x80 | (($ucs4 >> 6) & 0x3f)),
		     (0x80 | ($ucs4 & 0x3f)));
    } elsif ($ucs4 <= 0x1fffff) {
	return pack ("C4",
		     (0xf0 | (($ucs4 >> 18) & 0x7)),
		     (0x80 | (($ucs4 >> 12) & 0x3f)),
		     (0x80 | (($ucs4 >> 6) & 0x3f)),
		     (0x80 | ($ucs4 & 0x3f)));
    } elsif ($ucs4 <= 0x3ffffff) {
	return pack ("C5",
		     (0xf0 | (($ucs4 >> 24) & 0x3)),
		     (0x80 | (($ucs4 >> 18) & 0x3f)),
		     (0x80 | (($ucs4 >> 12) & 0x3f)),
		     (0x80 | (($ucs4 >> 6) & 0x3f)),
		     (0x80 | ($ucs4 & 0x3f)));
    } else {
	return pack ("C6",
		     (0xf0 | (($ucs4 >> 30) & 0x3)),
		     (0x80 | (($ucs4 >> 24) & 0x1)),
		     (0x80 | (($ucs4 >> 18) & 0x3f)),
		     (0x80 | (($ucs4 >> 12) & 0x3f)),
		     (0x80 | (($ucs4 >> 6) & 0x3f)),
		     (0x80 | ($ucs4 & 0x3f)));
    }
}

#Local Variables:
#mode: perl
#perl-indent-level: 4
#perl-continued-statement-offset: 4
#perl-continued-brace-offset: 0
#perl-brace-offset: -4
#perl-brace-imaginary-offset: 0
#perl-label-offset: -4
#tab-width: 4
#End:

__DATA__
0x00	0x0000
0x01	0x0001
0x02	0x1eb2
0x03	0x0003
0x04	0x0004
0x05	0x1eb4
0x06	0x1eaa
0x07	0x0007
0x08	0x0008
0x09	0x0009
0x0a	0x000a
0x0b	0x000b
0x0c	0x000c
0x0d	0x000d
0x0e	0x000e
0x0f	0x000f
0x10	0x0010
0x11	0x0011
0x12	0x0012
0x13	0x0013
0x14	0x1ef6
0x15	0x0015
0x16	0x0016
0x17	0x0017
0x18	0x0018
0x19	0x1ef8
0x1a	0x001a
0x1b	0x001b
0x1c	0x001c
0x1d	0x001d
0x1e	0x1ef4
0x1f	0x001f
0x20	0x0020
0x21	0x0021
0x22	0x0022
0x23	0x0023
0x24	0x0024
0x25	0x0025
0x26	0x0026
0x27	0x0027
0x28	0x0028
0x29	0x0029
0x2a	0x002a
0x2b	0x002b
0x2c	0x002c
0x2d	0x002d
0x2e	0x002e
0x2f	0x002f
0x30	0x0030
0x31	0x0031
0x32	0x0032
0x33	0x0033
0x34	0x0034
0x35	0x0035
0x36	0x0036
0x37	0x0037
0x38	0x0038
0x39	0x0039
0x3a	0x003a
0x3b	0x003b
0x3c	0x003c
0x3d	0x003d
0x3e	0x003e
0x3f	0x003f
0x40	0x0040
0x41	0x0041
0x42	0x0042
0x43	0x0043
0x44	0x0044
0x45	0x0045
0x46	0x0046
0x47	0x0047
0x48	0x0048
0x49	0x0049
0x4a	0x004a
0x4b	0x004b
0x4c	0x004c
0x4d	0x004d
0x4e	0x004e
0x4f	0x004f
0x50	0x0050
0x51	0x0051
0x52	0x0052
0x53	0x0053
0x54	0x0054
0x55	0x0055
0x56	0x0056
0x57	0x0057
0x58	0x0058
0x59	0x0059
0x5a	0x005a
0x5b	0x005b
0x5c	0x005c
0x5d	0x005d
0x5e	0x005e
0x5f	0x005f
0x60	0x0060
0x61	0x0061
0x62	0x0062
0x63	0x0063
0x64	0x0064
0x65	0x0065
0x66	0x0066
0x67	0x0067
0x68	0x0068
0x69	0x0069
0x6a	0x006a
0x6b	0x006b
0x6c	0x006c
0x6d	0x006d
0x6e	0x006e
0x6f	0x006f
0x70	0x0070
0x71	0x0071
0x72	0x0072
0x73	0x0073
0x74	0x0074
0x75	0x0075
0x76	0x0076
0x77	0x0077
0x78	0x0078
0x79	0x0079
0x7a	0x007a
0x7b	0x007b
0x7c	0x007c
0x7d	0x007d
0x7e	0x007e
0x7f	0x007f
0x80	0x1ea0
0x81	0x1eae
0x82	0x1eb0
0x83	0x1eb6
0x84	0x1ea4
0x85	0x1ea6
0x86	0x1ea8
0x87	0x1eac
0x88	0x1ebc
0x89	0x1eb8
0x8a	0x1ebe
0x8b	0x1ec0
0x8c	0x1ec2
0x8d	0x1ec4
0x8e	0x1ec6
0x8f	0x1ed0
0x90	0x1ed2
0x91	0x1ed4
0x92	0x1ed6
0x93	0x1ed8
0x94	0x1ee2
0x95	0x1eda
0x96	0x1edc
0x97	0x1ede
0x98	0x1eca
0x99	0x1ece
0x9a	0x1ecc
0x9b	0x1ec8
0x9c	0x1ee6
0x9d	0x0168
0x9e	0x1ee4
0x9f	0x1ef2
0xa0	0x00d5
0xa1	0x1eaf
0xa2	0x1eb1
0xa3	0x1eb7
0xa4	0x1ea5
0xa5	0x1ea7
0xa6	0x1ea9
0xa7	0x1ead
0xa8	0x1ebd
0xa9	0x1eb9
0xaa	0x1ebf
0xab	0x1ec1
0xac	0x1ec3
0xad	0x1ec5
0xae	0x1ec7
0xaf	0x1ed1
0xb0	0x1ed3
0xb1	0x1ed5
0xb2	0x1ed7
0xb3	0x1ee0
0xb4	0x01a0
0xb5	0x1ed9
0xb6	0x1edd
0xb7	0x1edf
0xb8	0x1ecb
0xb9	0x1ef0
0xba	0x1ee8
0xbb	0x1eea
0xbc	0x1eec
0xbd	0x01a1
0xbe	0x1edb
0xbf	0x01af
0xc0	0x00c0
0xc1	0x00c1
0xc2	0x00c2
0xc3	0x00c3
0xc4	0x1ea2
0xc5	0x0102
0xc6	0x1eb3
0xc7	0x1eb5
0xc8	0x00c8
0xc9	0x00c9
0xca	0x00ca
0xcb	0x1eba
0xcc	0x00cc
0xcd	0x00cd
0xce	0x0128
0xcf	0x1ef3
0xd0	0x0110
0xd1	0x1ee9
0xd2	0x00d2
0xd3	0x00d3
0xd4	0x00d4
0xd5	0x1ea1
0xd6	0x1ef7
0xd7	0x1eeb
0xd8	0x1eed
0xd9	0x00d9
0xda	0x00da
0xdb	0x1ef9
0xdc	0x1ef5
0xdd	0x00dd
0xde	0x1ee1
0xdf	0x01b0
0xe0	0x00e0
0xe1	0x00e1
0xe2	0x00e2
0xe3	0x00e3
0xe4	0x1ea3
0xe5	0x0103
0xe6	0x1eef
0xe7	0x1eab
0xe8	0x00e8
0xe9	0x00e9
0xea	0x00ea
0xeb	0x1ebb
0xec	0x00ec
0xed	0x00ed
0xee	0x0129
0xef	0x1ec9
0xf0	0x0111
0xf1	0x1ef1
0xf2	0x00f2
0xf3	0x00f3
0xf4	0x00f4
0xf5	0x00f5
0xf6	0x1ecf
0xf7	0x1ecd
0xf8	0x1ee5
0xf9	0x00f9
0xfa	0x00fa
0xfb	0x0169
0xfc	0x1ee7
0xfd	0x00fd
0xfe	0x1ee3
0xff	0x1eee


code:
#! /usr/local/bin/perl -w

# vim: syntax=perl
# vim: tabstop=4

use strict;

use Test;

use constant NUM_TESTS => 6;

use Locale::Messages qw (LC_MESSAGES bindtextdomain textdomain dcgettext dgettext gettext);
require POSIX;
require File::Spec;

BEGIN {
	my $package;
	if ($0 =~ /_pp\.t$/) {
		$package = 'gettext_pp';
	} else {
		$package = 'gettext_xs';
	}

	my $selected = Locale::Messages->select_package ($package);
	if ($selected ne $package && 'gettext_xs' eq $package) {
		print "1..0 # Skip: Locale::$package not available here.\n";
		exit 0;
	}
	plan tests => NUM_TESTS;
}

my $locale_dir = $0;
$locale_dir =~ s,[^\\/]+$,, or $locale_dir = '.';
$locale_dir .= '/LocaleData';

my $textdomain = 'existing';
Locale::Messages::nl_putenv ("LANGUAGE=de_AT");
Locale::Messages::nl_putenv ("LC_ALL=de_AT");
Locale::Messages::nl_putenv ("LANG=de_AT");
Locale::Messages::nl_putenv ("LC_MESSAGES=de_AT");
Locale::Messages::nl_putenv ("OUTPUT_CHARSET=iso-8859-1");

my $bound_dir = bindtextdomain $textdomain => $locale_dir;

ok defined $bound_dir;
ok (File::Spec->catdir ($bound_dir), File::Spec->catdir ($bound_dir));

my $bound_domain = textdomain $textdomain;

ok defined $bound_domain;
ok $bound_domain, $textdomain;

# Normal lookup.
ok dcgettext (existing => 'View', LC_MESSAGES), 'Anzeigen';

# Can we retrieve a translation with the gettext glue?
ok dcgettext (existing => "Which folder would you like to view?\004View",
              LC_MESSAGES), 'Ansicht';

__END__

Local Variables:
mode: perl
perl-indent-level: 4
perl-continued-statement-offset: 4
perl-continued-brace-offset: 0
perl-brace-offset: -4
perl-brace-imaginary-offset: 0
perl-label-offset: -4
cperl-indent-level: 4
cperl-continued-statement-offset: 2
tab-width: 4
End:


code:
#! /usr/local/bin/perl -w

# vim: syntax=perl
# vim: tabstop=4

use strict;

use Test;

use constant NUM_TESTS => 14;

use Locale::Messages qw (bindtextdomain textdomain bind_textdomain_codeset
						 gettext);
require POSIX;
require File::Spec;

BEGIN {
	my $package;
	if ($0 =~ /_pp\.t$/) {
		$package = 'gettext_pp';
	} else {
		$package = 'gettext_xs';
	}

	my $selected = Locale::Messages->select_package ($package);
	if ($selected ne $package && 'gettext_xs' eq $package) {
		print "1..0 # Skip: Locale::$package not available here.\n";
		exit 0;
	}
	plan tests => NUM_TESTS;
}

my $locale_dir = $0;
$locale_dir =~ s,[^\\/]+$,, or $locale_dir = '.';
$locale_dir .= '/LocaleData';

my $textdomain = 'existing';

Locale::Messages::nl_putenv ("LANGUAGE=de_AT");
Locale::Messages::nl_putenv ("LC_ALL=de_AT");
Locale::Messages::nl_putenv ("LANG=de_AT");
Locale::Messages::nl_putenv ("LC_MESSAGES=de_AT");
Locale::Messages::nl_putenv ("OUTPUT_CHARSET");

my $missing_locale = 'locale de_AT missing';
my $setlocale = POSIX::setlocale (POSIX::LC_ALL() => '');
if ($setlocale && $setlocale =~ /(?:austria|at)/i) {
	$missing_locale = '';
} else {
	require Locale::Util;

	$setlocale = Locale::Util::set_locale (POSIX::LC_ALL(), 'de', 'AT');
	if ($setlocale && $setlocale =~ /(?:austria|at)/i) {
		$missing_locale = '';
	}
}

my $bound_dir = bindtextdomain $textdomain => $locale_dir;

ok defined $bound_dir;
ok (File::Spec->catdir ($locale_dir) eq File::Spec->catdir ($bound_dir));

my $bound_domain = textdomain $textdomain;

ok defined $bound_domain;
ok $textdomain, $bound_domain;

my $bound_codeset = bind_textdomain_codeset $textdomain => 'ISO-8859-1';

ok defined $bound_codeset;
ok $bound_codeset, 'ISO-8859-1';

skip $missing_locale, gettext ('January'), 'J�nner';
ok gettext ('March'), 'M�rz';

# This will cause GNU gettext to re-load our catalog.
$bound_dir = bindtextdomain $textdomain => $locale_dir . '/../LocaleData';

ok defined $bound_dir;
ok (File::Spec->catdir ($bound_dir),
    File::Spec->catdir ("$locale_dir/../LocaleData"));

$bound_codeset = bind_textdomain_codeset $textdomain => 'UTF-8';

ok defined $bound_codeset;
ok uc $bound_codeset, 'UTF-8';

skip $missing_locale, gettext ('January'), 'Jänner';
skip $missing_locale, gettext ('March'), 'März';

__END__

Local Variables:
mode: perl
perl-indent-level: 4
perl-continued-statement-offset: 4
perl-continued-brace-offset: 0
perl-brace-offset: -4
perl-brace-imaginary-offset: 0
perl-label-offset: -4
cperl-indent-level: 4
cperl-continued-statement-offset: 2
tab-width: 4
End:


code:
#! /usr/local/bin/perl -w

# vim: syntax=perl
# vim: tabstop=4

use strict;

use Test;

use constant NUM_TESTS => 7;

use Locale::Messages qw (LC_MESSAGES textdomain bind_textdomain_filter
                          gettext  dgettext  dcgettext
                         ngettext dngettext dcngettext);

BEGIN {
	my $package;
	if ($0 =~ /_pp\.t$/) {
		$package = 'gettext_pp';
	} else {
		$package = 'gettext_xs';
	}

	my $selected = Locale::Messages->select_package ($package);
	if ($selected ne $package && 'gettext_xs' eq $package) {
		print "1..0 # Skip: Locale::$package not available here.\n";
		exit 0;
	}
	plan tests => NUM_TESTS;
}

textdomain 'bogus';

my $gettext = gettext ('foobar');
my $dgettext = dgettext (bogus => 'foobar');
my $dcgettext = dcgettext (bogus => 'foobar', LC_MESSAGES);
my $ngettext = ngettext ('foobar', 'barbaz', 1);
my $dngettext = dngettext (bogus => 'foobar', 'barbaz', 1);
my $dcngettext = dcngettext (bogus => 'foobar', 'barbaz', 1, LC_MESSAGES);

package MyPackage;

use strict;

sub new {
	bless {}, shift;
}

sub filterMethod {
	my ($self, $string) = @_;

	return 'prefix - ' . $string;
};

package main;

sub wrapper {
	my ($string, $obj) = @_;

	$obj->filterMethod ($string);
}

my $obj = MyPackage->new;
ok (bind_textdomain_filter ('bogus', \&wrapper, $obj));

my $prefix = 'prefix - ';
ok "$prefix$gettext", gettext ('foobar');
ok "$prefix$dgettext", dgettext (bogus => 'foobar');
ok "$prefix$dcgettext", dcgettext (bogus => 'foobar', LC_MESSAGES);
ok "$prefix$ngettext", ngettext ('foobar', 'barbaz', 1);
ok "$prefix$dngettext", dngettext (bogus => 'foobar', 'barbaz', 1);
ok "$prefix$dcngettext",
	dcngettext (bogus => 'foobar', 'barbaz', 1, LC_MESSAGES);

__END__

Local Variables:
mode: perl
perl-indent-level: 4
perl-continued-statement-offset: 4
perl-continued-brace-offset: 0
perl-brace-offset: -4
perl-brace-imaginary-offset: 0
perl-label-offset: -4
cperl-indent-level: 4
cperl-continued-statement-offset: 2
tab-width: 4
End:


code:
#! /usr/local/bin/perl -w

# vim: syntax=perl
# vim: tabstop=4

use strict;

use Test;

use constant NUM_TESTS => 12;

use Locale::Messages qw (bindtextdomain);

BEGIN {
	my $package;
	if ($0 =~ /_pp\.t$/) {
		$package = 'gettext_pp';
	} else {
		$package = 'gettext_xs';
	}

	my $selected = Locale::Messages->select_package ($package);
	if ($selected ne $package && 'gettext_xs' eq $package) {
		print "1..0 # Skip: Locale::$package not available here.\n";
		exit 0;
	}
	plan tests => NUM_TESTS;
}

my $bound_domain = bindtextdomain 'existing';
ok defined $bound_domain;
ok length $bound_domain;

$bound_domain = bindtextdomain 'existing', '.';
ok defined $bound_domain;
ok $bound_domain, '.';

$bound_domain = bindtextdomain 'existing';
ok defined $bound_domain;
ok $bound_domain, '.';

$bound_domain = bindtextdomain 'not_existing';
ok defined $bound_domain;
ok length $bound_domain;

$bound_domain = bindtextdomain 'not_existing', '.';
ok defined $bound_domain;
ok $bound_domain, '.';

$bound_domain = bindtextdomain 'not_existing';
ok defined $bound_domain;
ok $bound_domain, '.';

__END__

Local Variables:
mode: perl
perl-indent-level: 4
perl-continued-statement-offset: 4
perl-continued-brace-offset: 0
perl-brace-offset: -4
perl-brace-imaginary-offset: 0
perl-label-offset: -4
cperl-indent-level: 4
cperl-continued-statement-offset: 2
tab-width: 4
End:


code:
#! /usr/local/bin/perl -w

# vim: syntax=perl
# vim: tabstop=4

use strict;

use Test;

use constant NUM_TESTS => 11;

use Locale::Messages qw (bindtextdomain dcgettext LC_MESSAGES);
require POSIX;
require File::Spec;

BEGIN {
	my $package;
	if ($0 =~ /_pp\.t$/) {
		$package = 'gettext_pp';
	} else {
		$package = 'gettext_xs';
	}

	my $selected = Locale::Messages->select_package ($package);
	if ($selected ne $package && 'gettext_xs' eq $package) {
		print "1..0 # Skip: Locale::$package not available here.\n";
		exit 0;
	}
	plan tests => NUM_TESTS;
}

my $locale_dir = $0;
$locale_dir =~ s,[^\\/]+$,, or $locale_dir = '.';
$locale_dir .= '/LocaleData';

Locale::Messages::nl_putenv ("LANGUAGE=de_AT");
Locale::Messages::nl_putenv ("LC_ALL=de_AT");
Locale::Messages::nl_putenv ("LANG=de_AT");
Locale::Messages::nl_putenv ("LC_MESSAGES=de_AT");
Locale::Messages::nl_putenv ("OUTPUT_CHARSET=iso-8859-1");

my $missing_locale = 'locale de_AT missing';
my $setlocale = POSIX::setlocale (POSIX::LC_ALL() => '');
if ($setlocale && $setlocale =~ /(?:austria|at)/i) {
	$missing_locale = '';
} else {
	require Locale::Util;

	$setlocale = Locale::Util::set_locale (POSIX::LC_ALL(), 'de', 'AT');
	if ($setlocale && $setlocale =~ /(?:austria|at)/i) {
		$missing_locale = '';
	}
}

my $bound_dir = bindtextdomain existing => $locale_dir;
ok defined $bound_dir;
ok (File::Spec->catdir ($bound_dir), File::Spec->catdir ($locale_dir));

$bound_dir = bindtextdomain additional => $locale_dir;
ok defined $bound_dir;
ok (File::Spec->catdir ($bound_dir), File::Spec->catdir ($locale_dir));

ok 'Dezember', dcgettext (existing => 'December', LC_MESSAGES);
ok 'September', dcgettext (existing => 'September', LC_MESSAGES);
ok 'Not translated', dcgettext (existing => 'Not translated', LC_MESSAGES);
skip $missing_locale, 'J�nner', dcgettext (existing => 'January', LC_MESSAGES);

ok 'Montag', dcgettext (additional => 'Monday', LC_MESSAGES);
ok 'Not translated', dcgettext (additional => 'Not translated', LC_MESSAGES);
skip $missing_locale,
	dcgettext (additional => 'Saturday', LC_MESSAGES), 'Sonnabend';

__END__

Local Variables:
mode: perl
perl-indent-level: 4
perl-continued-statement-offset: 4
perl-continued-brace-offset: 0
perl-brace-offset: -4
perl-brace-imaginary-offset: 0
perl-label-offset: -4
cperl-indent-level: 4
cperl-continued-statement-offset: 2
tab-width: 4
End:


code:
#! /usr/local/bin/perl -w

# vim: syntax=perl
# vim: tabstop=4

use strict;

use Test;

use constant NUM_TESTS => 85;

use Locale::Messages qw (bindtextdomain dcngettext LC_MESSAGES);
require POSIX;
require File::Spec;

BEGIN {
	my $package;
	if ($0 =~ /_pp\.t$/) {
		$package = 'gettext_pp';
	} else {
		$package = 'gettext_xs';
	}

	my $selected = Locale::Messages->select_package ($package);
	if ($selected ne $package && 'gettext_xs' eq $package) {
		print "1..0 # Skip: Locale::$package not available here.\n";
		exit 0;
	}
	plan tests => NUM_TESTS;
}

Locale::Messages::nl_putenv ("LANGUAGE=C");
Locale::Messages::nl_putenv ("LC_ALL=C");
Locale::Messages::nl_putenv ("LANG=C");
Locale::Messages::nl_putenv ("LC_MESSAGES=C");
Locale::Messages::nl_putenv ("OUTPUT_CHARSET=iso-8859-1");
POSIX::setlocale (POSIX::LC_ALL() => '');

my $locale_dir = $0;
$locale_dir =~ s,[^\\/]+$,, or $locale_dir = '.';
$locale_dir .= '/LocaleData';

bindtextdomain not_here => $locale_dir;

my @strings = qw (Singular Plural);
for (0 .. 9) {
	my $translation = dcngettext (not_here => $strings[0], $strings[1], $_, LC_MESSAGES);
	my $expected = $_ == 1 ? 'Singular' : 'Plural';
	ok $translation, $expected;
}

Locale::Messages::nl_putenv ("LANGUAGE=C");
Locale::Messages::nl_putenv ("LC_ALL=C");
Locale::Messages::nl_putenv ("LANG=C");
Locale::Messages::nl_putenv ("LC_MESSAGES=C");

POSIX::setlocale (POSIX::LC_ALL() => '');

my $bound_dir = bindtextdomain existing => $locale_dir;

ok defined $bound_dir;
ok (File::Spec->catdir ($bound_dir), File::Spec->catdir ($locale_dir));

for (0 .. 9) {
	my $translation = dcngettext (existing => $strings[0], $strings[1], $_, LC_MESSAGES);
	my $expected = $_ == 1 ? 'Singular' : 'Plural';
	ok $translation, $expected;
}

Locale::Messages::nl_putenv ("LANGUAGE=de_AT");
Locale::Messages::nl_putenv ("LC_ALL=de_AT");
Locale::Messages::nl_putenv ("LANG=de_AT");
Locale::Messages::nl_putenv ("LC_MESSAGES=de_AT");

my $missing_locale = 'locale de_AT missing';
my $setlocale = POSIX::setlocale (POSIX::LC_ALL() => '');
if ($setlocale && $setlocale =~ /(?:austria|at)/i) {
	$missing_locale = '';
} else {
	require Locale::Util;

	$setlocale = Locale::Util::set_locale (POSIX::LC_ALL(), 'de', 'AT');
	if ($setlocale && $setlocale =~ /(?:austria|at)/i) {
		$missing_locale = '';
	}
}

for (0 .. 9) {
	my $translation = dcngettext (existing => $strings[0], $strings[1], $_, LC_MESSAGES);
	skip $missing_locale, $translation, $_ == 1 ? 'Einzahl' : 'Mehrzahl';
}

Locale::Messages::nl_putenv ("LANGUAGE=C");
Locale::Messages::nl_putenv ("LC_ALL=C");
Locale::Messages::nl_putenv ("LANG=C");
Locale::Messages::nl_putenv ("LC_MESSAGES=C");

POSIX::setlocale (POSIX::LC_ALL() => '');

$bound_dir = bindtextdomain additional => $locale_dir;

ok defined $bound_dir;
ok (File::Spec->catdir ($locale_dir), File::Spec->catdir ($bound_dir));

for (0 .. 9) {
	my $translation = dcngettext (additional => $strings[0], $strings[1], $_, LC_MESSAGES);
	ok $translation, $_ == 1 ? 'Singular' : 'Plural';
}

Locale::Messages::nl_putenv ("LANGUAGE=de_AT");
Locale::Messages::nl_putenv ("LC_ALL=de_AT");
Locale::Messages::nl_putenv ("LANG=de_AT");
Locale::Messages::nl_putenv ("LC_MESSAGES=de_AT");

POSIX::setlocale (POSIX::LC_ALL() => $setlocale) unless $missing_locale;

for (0 .. 40) {
	my $translation = dcngettext (additional => $strings[0], $strings[1], $_, LC_MESSAGES);
	my $plural = ($_ == 1 ? 0 :
				  $_ % 10 == 2 ? 1 :
				  $_ % 10 == 3 || $_ %10 == 4 ? 2 : 3);
	skip $missing_locale, $translation, "Numerus $plural";
}

__END__

Local Variables:
mode: perl
perl-indent-level: 4
perl-continued-statement-offset: 4
perl-continued-brace-offset: 0
perl-brace-offset: -4
perl-brace-imaginary-offset: 0
perl-label-offset: -4
cperl-indent-level: 4
cperl-continued-statement-offset: 2
tab-width: 4
End:


code:
#! /usr/local/bin/perl -w

# vim: syntax=perl
# vim: tabstop=4

use strict;

use Test;

use constant NUM_TESTS => 95;

use Locale::Messages qw (bindtextdomain dcnpgettext LC_MESSAGES);
require POSIX;
require File::Spec;

BEGIN {
	my $package;
	if ($0 =~ /_pp\.t$/) {
		$package = 'gettext_pp';
	} else {
		$package = 'gettext_xs';
	}

	my $selected = Locale::Messages->select_package ($package);
	if ($selected ne $package && 'gettext_xs' eq $package) {
		print "1..0 # Skip: Locale::$package not available here.\n";
		exit 0;
	}
	plan tests => NUM_TESTS;
}

Locale::Messages::nl_putenv ("LANGUAGE=C");
Locale::Messages::nl_putenv ("LC_ALL=C");
Locale::Messages::nl_putenv ("LANG=C");
Locale::Messages::nl_putenv ("LC_MESSAGES=C");
Locale::Messages::nl_putenv ("OUTPUT_CHARSET=iso-8859-1");
POSIX::setlocale (POSIX::LC_ALL() => '');

my $locale_dir = $0;
$locale_dir =~ s,[^\\/]+$,, or $locale_dir = '.';
$locale_dir .= '/LocaleData';

bindtextdomain not_here => $locale_dir;

# make sure it works with distinct key (where context doesn't matter)
my $context3 = "Context here (3)";
my @strings3 = ("Singular 3", "Plural 3");
for (0 .. 9) {
	# Prototype checking fails here if you pass the list @strings.
	my $translation = dcnpgettext (not_here => $context3, $strings3[0], $strings3[1], $_, LC_MESSAGES);
	my $expected  = $_ == 1 ? 'Singular 3' : 'Plural 3';
	ok $translation, $expected;
}

# not try a msgid that matches existing one
my $context = "Context here (2)";
my @strings = qw (Singular Plural);
for (0 .. 9) {
	# Prototype checking fails here if you pass the list @strings.
	my $translation = dcnpgettext (not_here => $context, $strings[0], $strings[1], $_, LC_MESSAGES);
	my $expected  = $_ == 1 ? 'Singular' : 'Plural';
	ok $translation, $expected;
}

Locale::Messages::nl_putenv ("LANGUAGE=C");
Locale::Messages::nl_putenv ("LC_ALL=C");
Locale::Messages::nl_putenv ("LANG=C");
Locale::Messages::nl_putenv ("LC_MESSAGES=C");

POSIX::setlocale (POSIX::LC_ALL() => '');

my $bound_dir = bindtextdomain existing => $locale_dir;

ok defined $bound_dir;
ok (File::Spec->catdir ($bound_dir), File::Spec->catdir ($locale_dir));

for (0 .. 9) {
	my $translation = dcnpgettext (existing => $context, $strings[0], $strings[1], $_, LC_MESSAGES);
	my $expected  = $_ == 1 ? 'Singular' : 'Plural';
	ok $translation, $expected;
}

Locale::Messages::nl_putenv ("LANGUAGE=de_AT");
Locale::Messages::nl_putenv ("LC_ALL=de_AT");
Locale::Messages::nl_putenv ("LANG=de_AT");
Locale::Messages::nl_putenv ("LC_MESSAGES=de_AT");

POSIX::setlocale (POSIX::LC_ALL() => '');

for (0 .. 9) {
	my $translation = dcnpgettext (existing => $context, $strings[0], $strings[1], $_, LC_MESSAGES);
	my $expected  = $_ == 1 ? 'Einzahl 2' : 'Mehrzahl 2';
	ok $translation, $expected;
}

Locale::Messages::nl_putenv ("LANGUAGE=C");
Locale::Messages::nl_putenv ("LC_ALL=C");
Locale::Messages::nl_putenv ("LANG=C");
Locale::Messages::nl_putenv ("LC_MESSAGES=C");

POSIX::setlocale (POSIX::LC_ALL() => '');

$bound_dir = bindtextdomain additional => $locale_dir;

ok defined $bound_dir;
ok (File::Spec->catdir ($bound_dir), File::Spec->catdir ($locale_dir));

for (0 .. 9) {
	my $translation = dcnpgettext (additional => $context, $strings[0], $strings[1], $_, LC_MESSAGES);
	my $expected  = $_ == 1 ? 'Singular' : 'Plural';
	ok $translation, $expected;
}

Locale::Messages::nl_putenv ("LANGUAGE=de_AT");
Locale::Messages::nl_putenv ("LC_ALL=de_AT");
Locale::Messages::nl_putenv ("LANG=de_AT");
Locale::Messages::nl_putenv ("LC_MESSAGES=de_AT");

POSIX::setlocale (POSIX::LC_ALL() => '');

for (0 .. 40) {
	my $translation = dcnpgettext (additional => $context, $strings[0], $strings[1], $_, LC_MESSAGES);
	my $plural = ($_ == 1 ? 0 :
				  $_ % 10 == 2 ? 1 :
				  $_ % 10 == 3 || $_ %10 == 4 ? 2 : 3);
	ok $translation, "Numerus 2:$plural";
}

__END__

Local Variables:
mode: perl
perl-indent-level: 4
perl-continued-statement-offset: 4
perl-continued-brace-offset: 0
perl-brace-offset: -4
perl-brace-imaginary-offset: 0
perl-label-offset: -4
cperl-indent-level: 4
cperl-continued-statement-offset: 2
tab-width: 4
End:


code:
#! /usr/local/bin/perl -w

# vim: syntax=perl
# vim: tabstop=4

use strict;

use Test;

use constant NUM_TESTS => 10;

use Locale::Messages qw (bindtextdomain dcgettext dcpgettext LC_MESSAGES);
require POSIX;
require File::Spec;

BEGIN {
	my $package;
	if ($0 =~ /_pp\.t$/) {
		$package = 'gettext_pp';
	} else {
		$package = 'gettext_xs';
	}

	my $selected = Locale::Messages->select_package ($package);
	if ($selected ne $package && 'gettext_xs' eq $package) {
		print "1..0 # Skip: Locale::$package not available here.\n";
		exit 0;
	}
	plan tests => NUM_TESTS;
}

my $locale_dir = $0;
$locale_dir =~ s,[^/\\]+$,, or $locale_dir = '.';
$locale_dir .= '/LocaleData';

Locale::Messages::nl_putenv ("LANGUAGE=de_AT");
Locale::Messages::nl_putenv ("LC_ALL=de_AT");
Locale::Messages::nl_putenv ("LANG=de_AT");
Locale::Messages::nl_putenv ("LC_MESSAGES=de_AT");
Locale::Messages::nl_putenv ("OUTPUT_CHARSET=iso-8859-1");

my $bound_dir = bindtextdomain existing => $locale_dir;
ok defined $bound_dir;
ok (File::Spec->catdir ($locale_dir), File::Spec->catdir ($bound_dir));

$bound_dir = bindtextdomain additional => $locale_dir;
ok defined $bound_dir;
ok (File::Spec->catdir ($locale_dir), File::Spec->catdir ($bound_dir));

# make sure dgettext and dpgettext return diff values
ok 'Anzeigen', dcgettext (existing => 'View', LC_MESSAGES);
ok 'Ansicht', dcpgettext (existing => 'Which folder would you like to view?','View', LC_MESSAGES);
ok 'Not translated', dcpgettext (existing => 'none', 'Not translated', LC_MESSAGES);

ok 'Ein weiterer Blick', dcpgettext (additional => 'Context', 'Another View', LC_MESSAGES);
ok 'Not translated', dcpgettext (additional => 'none', 'Not translated', LC_MESSAGES);
ok 'Ein weiterer Blick', dcpgettext (additional => 'Context', 'Another View', LC_MESSAGES);

__END__

Local Variables:
mode: perl
perl-indent-level: 4
perl-continued-statement-offset: 4
perl-continued-brace-offset: 0
perl-brace-offset: -4
perl-brace-imaginary-offset: 0
perl-label-offset: -4
cperl-indent-level: 4
cperl-continued-statement-offset: 2
tab-width: 4
End:


code:
#! /usr/local/bin/perl -w

# vim: syntax=perl
# vim: tabstop=4

use strict;

use Test;

use constant NUM_TESTS => 11;

use Locale::Messages qw (bindtextdomain dgettext);
require POSIX;
require File::Spec;

BEGIN {
	my $package;
	if ($0 =~ /_pp\.t$/) {
		$package = 'gettext_pp';
	} else {
		$package = 'gettext_xs';
	}

	my $selected = Locale::Messages->select_package ($package);
	if ($selected ne $package && 'gettext_xs' eq $package) {
		print "1..0 # Skip: Locale::$package not available here.\n";
		exit 0;
	}
	plan tests => NUM_TESTS;
}

my $locale_dir = $0;
$locale_dir =~ s,[^/\\]+$,, or $locale_dir = '.';
$locale_dir .= '/LocaleData';

Locale::Messages::nl_putenv ("LANGUAGE=de_AT");
Locale::Messages::nl_putenv ("LC_ALL=de_AT");
Locale::Messages::nl_putenv ("LANG=de_AT");
Locale::Messages::nl_putenv ("LC_MESSAGES=de_AT");
Locale::Messages::nl_putenv ("OUTPUT_CHARSET=iso-8859-1");

my $missing_locale = 'locale de_AT missing';
my $setlocale = POSIX::setlocale (POSIX::LC_ALL() => '');
if ($setlocale && $setlocale =~ /(?:austria|at)/i) {
	$missing_locale = '';
} else {
	require Locale::Util;

	$setlocale = Locale::Util::set_locale (POSIX::LC_ALL(), 'de', 'AT');
	if ($setlocale && $setlocale =~ /(?:austria|at)/i) {
		$missing_locale = '';
	}
}

my $bound_dir = bindtextdomain existing => $locale_dir;
ok defined $bound_dir;
ok (File::Spec->catdir ($bound_dir), File::Spec->catdir ($locale_dir));

$bound_dir = bindtextdomain additional => $locale_dir;
ok defined $bound_dir;
ok (File::Spec->catdir ($bound_dir), File::Spec->catdir ($locale_dir));

ok 'Dezember', dgettext (existing => 'December');
ok 'September', dgettext (existing => 'September');
ok 'Not translated', dgettext (existing => 'Not translated');
skip $missing_locale, 'J�nner', dgettext (existing => 'January');

ok 'Montag', dgettext (additional => 'Monday');
ok dgettext (additional => 'Not translated'), 'Not translated';
skip $missing_locale, dgettext (additional => 'Saturday'), 'Sonnabend';

__END__

Local Variables:
mode: perl
perl-indent-level: 4
perl-continued-statement-offset: 4
perl-continued-brace-offset: 0
perl-brace-offset: -4
perl-brace-imaginary-offset: 0
perl-label-offset: -4
cperl-indent-level: 4
cperl-continued-statement-offset: 2
tab-width: 4
End:


code:
#! /usr/local/bin/perl -w

# vim: syntax=perl
# vim: tabstop=4

use strict;

use Test;

use constant NUM_TESTS => 85;

use Locale::Messages qw (bindtextdomain dngettext);
require POSIX;
require File::Spec;

BEGIN {
	my $package;
	if ($0 =~ /_pp\.t$/) {
		$package = 'gettext_pp';
	} else {
		$package = 'gettext_xs';
	}

	my $selected = Locale::Messages->select_package ($package);
	if ($selected ne $package && 'gettext_xs' eq $package) {
		print "1..0 # Skip: Locale::$package not available here.\n";
		exit 0;
	}
	plan tests => NUM_TESTS;
}

Locale::Messages::nl_putenv ("LANGUAGE=C");
Locale::Messages::nl_putenv ("LC_ALL=C");
Locale::Messages::nl_putenv ("LANG=C");
Locale::Messages::nl_putenv ("LC_MESSAGES=C");
Locale::Messages::nl_putenv ("OUTPUT_CHARSET=iso-8859-1");

POSIX::setlocale (POSIX::LC_ALL() => '');

my $locale_dir = $0;
$locale_dir =~ s,[^\\/]+$,, or $locale_dir = '.';
$locale_dir .= '/LocaleData';

bindtextdomain not_here => $locale_dir;

my @strings = qw (Singular Plural);
for (0 .. 9) {
	my $translation = dngettext (not_here => $strings[0], $strings[1], $_);
	ok $translation, $_ == 1 ? 'Singular' : 'Plural';
}

Locale::Messages::nl_putenv ("LANGUAGE=C");
Locale::Messages::nl_putenv ("LC_ALL=C");
Locale::Messages::nl_putenv ("LANG=C");
Locale::Messages::nl_putenv ("LC_MESSAGES=C");

POSIX::setlocale (POSIX::LC_ALL() => '');

my $bound_dir = bindtextdomain existing => $locale_dir;

ok defined $bound_dir;
ok (File::Spec->catdir ($bound_dir), File::Spec->catdir ($locale_dir));

for (0 .. 9) {
	my $translation = dngettext (existing => $strings[0], $strings[1], $_);
	my $expected = $_ == 1 ? 'Singular' : 'Plural';
	ok $translation, $expected;
}

Locale::Messages::nl_putenv ("LANGUAGE=de_AT");
Locale::Messages::nl_putenv ("LC_ALL=de_AT");
Locale::Messages::nl_putenv ("LANG=de_AT");
Locale::Messages::nl_putenv ("LC_MESSAGES=de_AT");

my $missing_locale = 'locale de_AT missing';
my $setlocale = POSIX::setlocale (POSIX::LC_ALL() => '');
if ($setlocale && $setlocale =~ /(?:austria|at)/i) {
	$missing_locale = '';
} else {
	require Locale::Util;

	$setlocale = Locale::Util::set_locale (POSIX::LC_ALL(), 'de', 'AT');
	if ($setlocale && $setlocale =~ /(?:austria|at)/i) {
		$missing_locale = '';
	}
}

for (0 .. 9) {
	my $translation = dngettext (existing => $strings[0], $strings[1], $_);
	skip $missing_locale,
		$translation, $_ == 1 ? 'Einzahl' : 'Mehrzahl';
}

Locale::Messages::nl_putenv ("LANGUAGE=C");
Locale::Messages::nl_putenv ("LC_ALL=C");
Locale::Messages::nl_putenv ("LANG=C");
Locale::Messages::nl_putenv ("LC_MESSAGES=C");

POSIX::setlocale (POSIX::LC_ALL() => '');

$bound_dir = bindtextdomain additional => $locale_dir;

ok defined $bound_dir;
ok (File::Spec->catdir ($locale_dir), File::Spec->catdir ($bound_dir));

for (0 .. 9) {
	my $translation = dngettext (additional => $strings[0], $strings[1], $_);
	my $expected = $_ == 1 ? 'Singular' : 'Plural';
	ok $translation, $expected;
}

Locale::Messages::nl_putenv ("LANGUAGE=de_AT");
Locale::Messages::nl_putenv ("LC_ALL=de_AT");
Locale::Messages::nl_putenv ("LANG=de_AT");
Locale::Messages::nl_putenv ("LC_MESSAGES=de_AT");

POSIX::setlocale (POSIX::LC_ALL() => $setlocale) unless $missing_locale;

for (0 .. 40) {
	my $translation = dngettext (additional => $strings[0], $strings[1], $_);
	my $plural = ($_ == 1 ? 0 :
				  $_ % 10 == 2 ? 1 :
				  $_ % 10 == 3 || $_ %10 == 4 ? 2 : 3);
	skip $missing_locale, $translation, "Numerus $plural";
}

__END__

Local Variables:
mode: perl
perl-indent-level: 4
perl-continued-statement-offset: 4
perl-continued-brace-offset: 0
perl-brace-offset: -4
perl-brace-imaginary-offset: 0
perl-label-offset: -4
cperl-indent-level: 4
cperl-continued-statement-offset: 2
tab-width: 4
End:


code:
#! /usr/local/bin/perl -w

# vim: syntax=perl
# vim: tabstop=4

use strict;

use Test;

use constant NUM_TESTS => 95;

use Locale::Messages qw (bindtextdomain dnpgettext);
require POSIX;
require File::Spec;

BEGIN {
	my $package;
	if ($0 =~ /_pp\.t$/) {
		$package = 'gettext_pp';
	} else {
		$package = 'gettext_xs';
	}

	my $selected = Locale::Messages->select_package ($package);
	if ($selected ne $package && 'gettext_xs' eq $package) {
		print "1..0 # Skip: Locale::$package not available here.\n";
		exit 0;
	}
	plan tests => NUM_TESTS;
}

Locale::Messages::nl_putenv ("LANGUAGE=C");
Locale::Messages::nl_putenv ("LC_ALL=C");
Locale::Messages::nl_putenv ("LANG=C");
Locale::Messages::nl_putenv ("LC_MESSAGES=C");
Locale::Messages::nl_putenv ("OUTPUT_CHARSET=iso-8859-1");

POSIX::setlocale (POSIX::LC_ALL() => '');

my $locale_dir = $0;
$locale_dir =~ s,[^\\/]+$,, or $locale_dir = '.';
$locale_dir .= '/LocaleData';

bindtextdomain not_here => $locale_dir;

# make sure it works with distinct key (where context doesn't matter)
my $context3 = "Context here (3)";
my @strings3 = ("Singular 3", "Plural 3");
for (0 .. 9) {
	# Prototype checking fails here if you pass the list @strings.
	my $translation = dnpgettext (not_here => $context3, $strings3[0], $strings3[1], $_);
	my $expected = $_ == 1 ? 'Singular 3' : 'Plural 3';
	ok $translation, $expected;
}

# not try a msgid that matches existing one
my $context = "Context here (2)";
my @strings = qw (Singular Plural);
for (0 .. 9) {
	# Prototype checking fails here if you pass the list @strings.
	my $translation = dnpgettext (not_here => $context, $strings[0], $strings[1], $_);
	my $expected = $_ == 1 ? 'Singular' : 'Plural';
	ok $translation, $expected;
}

Locale::Messages::nl_putenv ("LANGUAGE=C");
Locale::Messages::nl_putenv ("LC_ALL=C");
Locale::Messages::nl_putenv ("LANG=C");
Locale::Messages::nl_putenv ("LC_MESSAGES=C");

POSIX::setlocale (POSIX::LC_ALL() => '');

my $bound_dir = bindtextdomain existing => $locale_dir;

ok defined $bound_dir;
ok (File::Spec->catdir ($bound_dir), File::Spec->catdir ($locale_dir));

for (0 .. 9) {
	my $translation = dnpgettext (existing => $context, $strings[0], $strings[1], $_);
	my $expected = $_ == 1 ? 'Singular' : 'Plural';
	ok $translation, $expected;
}

Locale::Messages::nl_putenv ("LANGUAGE=de_AT");
Locale::Messages::nl_putenv ("LC_ALL=de_AT");
Locale::Messages::nl_putenv ("LANG=de_AT");
Locale::Messages::nl_putenv ("LC_MESSAGES=de_AT");

POSIX::setlocale (POSIX::LC_ALL() => '');

for (0 .. 9) {
	my $translation = dnpgettext (existing => $context, $strings[0], $strings[1], $_);
	my $expected = $_ == 1 ? 'Einzahl 2' : 'Mehrzahl 2';
	ok $expected, $translation;
}

Locale::Messages::nl_putenv ("LANGUAGE=C");
Locale::Messages::nl_putenv ("LC_ALL=C");
Locale::Messages::nl_putenv ("LANG=C");
Locale::Messages::nl_putenv ("LC_MESSAGES=C");

POSIX::setlocale (POSIX::LC_ALL() => '');

$bound_dir = bindtextdomain additional => $locale_dir;

ok defined $bound_dir;
ok (File::Spec->catdir ($bound_dir), File::Spec->catdir ($locale_dir));

for (0 .. 9) {
	my $translation = dnpgettext (additional => $context, $strings[0], $strings[1], $_);
	my $expected = $_ == 1 ? 'Singular' : 'Plural';
	ok $translation, $expected;
}

Locale::Messages::nl_putenv ("LANGUAGE=de_AT");
Locale::Messages::nl_putenv ("LC_ALL=de_AT");
Locale::Messages::nl_putenv ("LANG=de_AT");
Locale::Messages::nl_putenv ("LC_MESSAGES=de_AT");

POSIX::setlocale (POSIX::LC_ALL() => '');

for (0 .. 40) {
	my $translation = dnpgettext (additional => $context, $strings[0], $strings[1], $_);
	my $plural = ($_ == 1 ? 0 :
				  $_ % 10 == 2 ? 1 :
				  $_ % 10 == 3 || $_ %10 == 4 ? 2 : 3);
	ok $translation, "Numerus 2:$plural";
}

__END__

Local Variables:
mode: perl
perl-indent-level: 4
perl-continued-statement-offset: 4
perl-continued-brace-offset: 0
perl-brace-offset: -4
perl-brace-imaginary-offset: 0
perl-label-offset: -4
cperl-indent-level: 4
cperl-continued-statement-offset: 2
tab-width: 4
End:


code:
#! /usr/local/bin/perl -w

# vim: syntax=perl
# vim: tabstop=4

use strict;

use Test;

use constant NUM_TESTS => 9;

use Locale::Messages qw (bindtextdomain gettext dgettext dpgettext);
require POSIX;
require File::Spec;

BEGIN {
	my $package;
	if ($0 =~ /_pp\.t$/) {
		$package = 'gettext_pp';
	} else {
		$package = 'gettext_xs';
	}

	my $selected = Locale::Messages->select_package ($package);
	if ($selected ne $package && 'gettext_xs' eq $package) {
		print "1..0 # Skip: Locale::$package not available here.\n";
		exit 0;
	}
	plan tests => NUM_TESTS;
}

my $locale_dir = $0;
$locale_dir =~ s,[^/\\]+$,, or $locale_dir = '.';
$locale_dir .= '/LocaleData';

Locale::Messages::nl_putenv ("LANGUAGE=de_AT");
Locale::Messages::nl_putenv ("LC_ALL=de_AT");
Locale::Messages::nl_putenv ("LANG=de_AT");
Locale::Messages::nl_putenv ("LC_MESSAGES=de_AT");
Locale::Messages::nl_putenv ("OUTPUT_CHARSET=iso-8859-1");

POSIX::setlocale (POSIX::LC_ALL() => '');

my $bound_dir = bindtextdomain existing => $locale_dir;
ok defined $bound_dir;
ok (File::Spec->catdir ($bound_dir), File::Spec->catdir ($locale_dir));

$bound_dir = bindtextdomain additional => $locale_dir;
ok defined $bound_dir;
ok (File::Spec->catdir ($bound_dir), File::Spec->catdir ($locale_dir));

# make sure dgettext and dpgettext return diff values
ok dgettext (existing => 'View'), 'Anzeigen';
ok dpgettext (existing => 'Which folder would you like to view?', 'View'), 'Ansicht';
ok dpgettext (existing => 'none', 'Not translated'), 'Not translated';

ok dpgettext (additional => 'Context', 'Another View'), 'Ein weiterer Blick';
ok dpgettext (additional => 'none', 'Not translated'), 'Not translated';

__END__

Local Variables:
mode: perl
perl-indent-level: 4
perl-continued-statement-offset: 4
perl-continued-brace-offset: 0
perl-brace-offset: -4
perl-brace-imaginary-offset: 0
perl-label-offset: -4
cperl-indent-level: 4
cperl-continued-statement-offset: 2
tab-width: 4
End:


code:
#! /usr/local/bin/perl -w

# vim: syntax=perl
# vim: tabstop=4

use strict;

use Test;

use constant NUM_TESTS => 8;

use Locale::Messages qw (bindtextdomain textdomain gettext);
require POSIX;
require File::Spec;

BEGIN {
	my $package;
	if ($0 =~ /_pp\.t$/) {
		$package = 'gettext_pp';
	} else {
		$package = 'gettext_xs';
	}

	my $selected = Locale::Messages->select_package ($package);
	if ($selected ne $package && 'gettext_xs' eq $package) {
		print "1..0 # Skip: Locale::$package not available here.\n";
		exit 0;
	}
	plan tests => NUM_TESTS;
}

my $locale_dir = $0;
$locale_dir =~ s,[^\\/]+$,, or $locale_dir = '.';
$locale_dir .= '/LocaleData';

my $textdomain = 'existing';
Locale::Messages::nl_putenv ("LANGUAGE=de_AT");
Locale::Messages::nl_putenv ("LC_ALL=de_AT");
Locale::Messages::nl_putenv ("LANG=de_AT");
Locale::Messages::nl_putenv ("LC_MESSAGES=de_AT");
Locale::Messages::nl_putenv ("OUTPUT_CHARSET=iso-8859-1");

my $missing_locale = 'locale de_AT missing';
my $setlocale = POSIX::setlocale (POSIX::LC_ALL() => '');
if ($setlocale && $setlocale =~ /(?:austria|at)/i) {
	$missing_locale = '';
} else {
	require Locale::Util;

	$setlocale = Locale::Util::set_locale (POSIX::LC_ALL(), 'de', 'AT');
	if ($setlocale && $setlocale =~ /(?:austria|at)/i) {
		$missing_locale = '';
	}
}

my $bound_dir = bindtextdomain $textdomain => $locale_dir;

ok defined $bound_dir;
ok (File::Spec->catdir ($bound_dir), File::Spec->catdir ($bound_dir));

my $bound_domain = textdomain $textdomain;

ok defined $bound_domain;
ok $bound_domain, $textdomain;

# Default case.
ok gettext ('December'), 'Dezember';

# msgid eq msgstr.
ok gettext ('September'), 'September';

# Unknown.
ok gettext ('Not translated'), 'Not translated';

# Special translation for Austrian German.
skip $missing_locale, gettext ('January'), 'J�nner';

__END__

Local Variables:
mode: perl
perl-indent-level: 4
perl-continued-statement-offset: 4
perl-continued-brace-offset: 0
perl-brace-offset: -4
perl-brace-imaginary-offset: 0
perl-label-offset: -4
cperl-indent-level: 4
cperl-continued-statement-offset: 2
tab-width: 4
End:


code:
#! /usr/local/bin/perl -w

# vim: syntax=perl
# vim: tabstop=4

use strict;

use Test;

use constant NUM_TESTS => 6;

use Locale::Messages qw (bindtextdomain textdomain gettext);
require POSIX;
require File::Spec;

BEGIN {
	# The xs version of this test is omitted on purpose.  We can
	# only test it when the locale de and de_AT are installed, but
	# checking for them will spoil our results.
	my $package;
	if ($0 =~ /_pp\.t$/) {
		$package = 'gettext_pp';
	} else {
		$package = 'gettext_xs';
	}

	my $selected = Locale::Messages->select_package ($package);
	if ($selected ne $package && 'gettext_xs' eq $package) {
		print "1..0 # Skip: Locale::$package not available here.\n";
		exit 0;
	}

	plan tests => NUM_TESTS;
}

Locale::Messages::nl_putenv ("LANGUAGE=de_AT");
Locale::Messages::nl_putenv ("LC_ALL=de_AT");
Locale::Messages::nl_putenv ("LANG=de_AT");
Locale::Messages::nl_putenv ("LC_MESSAGES=de_AT");
# Actually both de_AT and de are required.  We assume here that
# de will be installed, too, if de_AT is.  This test does not
# use Locale::Util::set_locale() for setting the locale, and
# that is on purpose.
my $missing_locale = POSIX::setlocale (POSIX::LC_ALL() => '') ?
    '' : 'locale de_AT missing';
POSIX::setlocale (POSIX::LC_ALL() => 'C');

my $locale_dir = $0;
$locale_dir =~ s,[^\\/]+$,, or $locale_dir = '.';
$locale_dir .= '/LocaleData';

my $textdomain = 'existing';
Locale::Messages::nl_putenv ("LANG=whatever");
Locale::Messages::nl_putenv ("LC_ALL=whatever");
Locale::Messages::nl_putenv ("LC_MESSAGES=whatever");
Locale::Messages::nl_putenv ("LANGUAGE=ab_CD:ef_GH:de_AT:de");
Locale::Messages::nl_putenv ("OUTPUT_CHARSET=iso-8859-1");
POSIX::setlocale (POSIX::LC_ALL(), '');

my $bound_dir = bindtextdomain $textdomain => $locale_dir;

ok defined $bound_dir;
ok (File::Spec->catdir ($bound_dir), File::Spec->catdir ($locale_dir));

my $bound_domain = textdomain $textdomain;

ok defined $bound_domain;
ok $bound_domain, $textdomain;

# Austrian German has precedence.
skip $missing_locale, gettext ('January'), 'J�nner';
my $translation = gettext ('January');

Locale::Messages::nl_putenv ("LANGUAGE=ab_CD:ef_GH:de:de_AT");
ok gettext ('February'), 'Februar'; # not 'Feber'!

__END__

Local Variables:
mode: perl
perl-indent-level: 4
perl-continued-statement-offset: 4
perl-continued-brace-offset: 0
perl-brace-offset: -4
perl-brace-imaginary-offset: 0
perl-label-offset: -4
cperl-indent-level: 4
cperl-continued-statement-offset: 2
tab-width: 4
End:


code:
#! /usr/local/bin/perl -w

# vim: syntax=perl
# vim: tabstop=4

use strict;

use Test;

use constant NUM_TESTS => 88;

use Locale::Messages qw (bindtextdomain textdomain ngettext);
require POSIX;
require File::Spec;

BEGIN {
	my $package;
	if ($0 =~ /_pp\.t$/) {
		$package = 'gettext_pp';
	} else {
		$package = 'gettext_xs';
	}

	my $selected = Locale::Messages->select_package ($package);
	if ($selected ne $package && 'gettext_xs' eq $package) {
		print "1..0 # Skip: Locale::$package not available here.\n";
		exit 0;
	}
	plan tests => NUM_TESTS;
}

Locale::Messages::nl_putenv ("LANGUAGE=C");
Locale::Messages::nl_putenv ("LC_ALL=C");
Locale::Messages::nl_putenv ("LANG=C");
Locale::Messages::nl_putenv ("LC_MESSAGES=C");
Locale::Messages::nl_putenv ("OUTPUT_CHARSET=iso-8859-1");

POSIX::setlocale (POSIX::LC_ALL() => '');

my $locale_dir = $0;
$locale_dir =~ s,[^\\/]+$,, or $locale_dir = '.';
$locale_dir .= '/LocaleData';

bindtextdomain not_here => $locale_dir;
textdomain 'not_here';

my @strings = qw (Singular Plural);
for (0 .. 9) {
	# Prototype checking fails here if you pass the list @strings.
	my $translation = ngettext ($strings[0], $strings[1], $_);
	my $expected = $_ == 1 ? 'Singular' : 'Plural';
	ok $translation, $expected;
}

my $textdomain = 'existing';
Locale::Messages::nl_putenv ("LANGUAGE=C");
Locale::Messages::nl_putenv ("LC_ALL=C");
Locale::Messages::nl_putenv ("LANG=C");
Locale::Messages::nl_putenv ("LC_MESSAGES=C");

POSIX::setlocale (POSIX::LC_ALL() => '');

my $bound_dir = bindtextdomain $textdomain => $locale_dir;

ok defined $bound_dir;
ok (File::Spec->catdir ($bound_dir), File::Spec->catdir ($locale_dir));

my $bound_domain = textdomain $textdomain;

ok  defined $bound_domain && $textdomain eq $bound_domain;

for (0 .. 9) {
	my $translation = ngettext ($strings[0], $strings[1], $_);
	my $expected = $_ == 1 ? 'Singular' : 'Plural';
	ok $translation, $expected;
}

Locale::Messages::nl_putenv ("LANGUAGE=de_AT");
Locale::Messages::nl_putenv ("LC_ALL=de_AT");
Locale::Messages::nl_putenv ("LANG=de_AT");
Locale::Messages::nl_putenv ("LC_MESSAGES=de_AT");

my $missing_locale = 'locale de_AT missing';
my $setlocale = POSIX::setlocale (POSIX::LC_ALL() => '');
if ($setlocale && $setlocale =~ /(?:austria|at)/i) {
	$missing_locale = '';
} else {
	require Locale::Util;

	$setlocale = Locale::Util::set_locale (POSIX::LC_ALL(), 'de', 'AT');
	if ($setlocale && $setlocale =~ /(?:austria|at)/i) {
		$missing_locale = '';
	}
}

for (0 .. 9) {
	my $translation = ngettext ($strings[0], $strings[1], $_);
	my $expected = $_ == 1 ? 'Einzahl' : 'Mehrzahl';
	ok $translation, $expected;
}

$textdomain = 'additional';
Locale::Messages::nl_putenv ("LANGUAGE=C");
Locale::Messages::nl_putenv ("LC_ALL=C");
Locale::Messages::nl_putenv ("LANG=C");
Locale::Messages::nl_putenv ("LC_MESSAGES=C");

POSIX::setlocale (POSIX::LC_ALL() => '');

$bound_dir = bindtextdomain $textdomain => $locale_dir;

ok defined $bound_dir;
ok (File::Spec->catdir ($bound_dir), File::Spec->catdir ($bound_dir));

$bound_domain = textdomain $textdomain;

ok defined $bound_domain;
ok $bound_domain, $textdomain;

for (0 .. 9) {
	my $translation = ngettext ($strings[0], $strings[1], $_);
	my $expected = $_ == 1 ? 'Singular' : 'Plural';
	ok $translation, $expected;
}

Locale::Messages::nl_putenv ("LANGUAGE=de_AT");
Locale::Messages::nl_putenv ("LC_ALL=de_AT");
Locale::Messages::nl_putenv ("LANG=de_AT");
Locale::Messages::nl_putenv ("LC_MESSAGES=de_AT");

POSIX::setlocale (POSIX::LC_ALL() => $setlocale) unless $missing_locale;

for (0 .. 40) {
	my $translation = ngettext ($strings[0], $strings[1], $_);
	my $plural = ($_ == 1 ? 0 :
				  $_ % 10 == 2 ? 1 :
				  $_ % 10 == 3 || $_ %10 == 4 ? 2 : 3);
	ok $translation, "Numerus $plural";
}

__END__

Local Variables:
mode: perl
perl-indent-level: 4
perl-continued-statement-offset: 4
perl-continued-brace-offset: 0
perl-brace-offset: -4
perl-brace-imaginary-offset: 0
perl-label-offset: -4
cperl-indent-level: 4
cperl-continued-statement-offset: 2
tab-width: 4
End:


code:
#! /usr/local/bin/perl -w

# vim: syntax=perl
# vim: tabstop=4

use strict;

use Test;

use constant NUM_TESTS => 99;

use Locale::Messages qw (bindtextdomain textdomain npgettext);
require POSIX;
require File::Spec;

BEGIN {
	my $package;
	if ($0 =~ /_pp\.t$/) {
		$package = 'gettext_pp';
	} else {
		$package = 'gettext_xs';
	}

	my $selected = Locale::Messages->select_package ($package);
	if ($selected ne $package && 'gettext_xs' eq $package) {
		print "1..0 # Skip: Locale::$package not available here.\n";
		exit 0;
	}
	plan tests => NUM_TESTS;
}

Locale::Messages::nl_putenv ("LANGUAGE=C");
Locale::Messages::nl_putenv ("LC_ALL=C");
Locale::Messages::nl_putenv ("LANG=C");
Locale::Messages::nl_putenv ("LC_MESSAGES=C");
Locale::Messages::nl_putenv ("OUTPUT_CHARSET=iso-8859-1");

POSIX::setlocale (POSIX::LC_ALL() => '');

my $locale_dir = $0;
$locale_dir =~ s,[^\\/]+$,, or $locale_dir = '.';
$locale_dir .= '/LocaleData';

bindtextdomain not_here => $locale_dir;
textdomain 'not_here';

# make sure it works with distinct key (where context doesn't matter)
my $context3 = "Context here (3)";
my @strings3 = ("Singular 3", "Plural 3");
for (0 .. 9) {
	# Prototype checking fails here if you pass the list @strings.
	my $translation = npgettext ($context3, $strings3[0], $strings3[1], $_);
	my $expected = $_ == 1 ? 'Singular 3' : 'Plural 3';
	ok $translation, $expected;
}

# not try a msgid that matches existing one
my $context = "Context here (2)";
my @strings = qw (Singular Plural);
for (0 .. 9) {
	# Prototype checking fails here if you pass the list @strings.
	my $translation = npgettext ($context, $strings[0], $strings[1], $_);
	my $expected = $_ == 1 ? 'Singular' : 'Plural';
	ok $translation, $expected;
}

my $textdomain = 'existing';
Locale::Messages::nl_putenv ("LANGUAGE=C");
Locale::Messages::nl_putenv ("LC_ALL=C");
Locale::Messages::nl_putenv ("LANG=C");
Locale::Messages::nl_putenv ("LC_MESSAGES=C");

POSIX::setlocale (POSIX::LC_ALL() => '');

my $bound_dir = bindtextdomain $textdomain => $locale_dir;

ok defined $bound_dir;
ok (File::Spec->catdir ($bound_dir), File::Spec->catdir ($bound_dir));

my $bound_domain = textdomain $textdomain;

ok defined $bound_domain;
ok $bound_domain, $textdomain;

for (0 .. 9) {
	my $translation = npgettext ($context, $strings[0], $strings[1], $_);
	my $expected = $_ == 1 ? 'Singular' : 'Plural';
	ok $translation, $expected;
}

Locale::Messages::nl_putenv ("LANGUAGE=de_AT");
Locale::Messages::nl_putenv ("LC_ALL=de_AT");
Locale::Messages::nl_putenv ("LANG=de_AT");
Locale::Messages::nl_putenv ("LC_MESSAGES=de_AT");
my $missing_locale = POSIX::setlocale (POSIX::LC_ALL() => '') ?
    '' : 'locale de_AT missing';

for (0 .. 9) {
	my $translation = npgettext ($context, $strings[0], $strings[1], $_);
	my $expected = $_ == 1 ? 'Einzahl 2' : 'Mehrzahl 2';
	ok $translation, $expected;
}

$textdomain = 'additional';
Locale::Messages::nl_putenv ("LANGUAGE=C");
Locale::Messages::nl_putenv ("LC_ALL=C");
Locale::Messages::nl_putenv ("LANG=C");
Locale::Messages::nl_putenv ("LC_MESSAGES=C");

POSIX::setlocale (POSIX::LC_ALL() => '');

$bound_dir = bindtextdomain $textdomain => $locale_dir;

ok defined $bound_dir;
ok (File::Spec->catdir ($bound_dir), File::Spec->catdir ($bound_dir));

$bound_domain = textdomain $textdomain;

ok defined $bound_domain;
ok $bound_domain, $textdomain;

for (0 .. 9) {
	my $translation = npgettext ($context, $strings[0], $strings[1], $_);
	my $expected = $_ == 1 ? 'Singular' : 'Plural';
	ok $translation, $expected;
}

Locale::Messages::nl_putenv ("LANGUAGE=de_AT");
Locale::Messages::nl_putenv ("LC_ALL=de_AT");
Locale::Messages::nl_putenv ("LANG=de_AT");
Locale::Messages::nl_putenv ("LC_MESSAGES=de_AT");

POSIX::setlocale (POSIX::LC_ALL() => '');

for (0 .. 40) {
	my $translation = npgettext ($context, $strings[0], $strings[1], $_);
	my $plural = ($_ == 1 ? 0 :
				  $_ % 10 == 2 ? 1 :
				  $_ % 10 == 3 || $_ %10 == 4 ? 2 : 3);
	ok $translation, "Numerus 2:$plural";
}

__END__

Local Variables:
mode: perl
perl-indent-level: 4
perl-continued-statement-offset: 4
perl-continued-brace-offset: 0
perl-brace-offset: -4
perl-brace-imaginary-offset: 0
perl-label-offset: -4
cperl-indent-level: 4
cperl-continued-statement-offset: 2
tab-width: 4
End:


code:
#! /usr/local/bin/perl -w

# vim: syntax=perl
# vim: tabstop=4

use strict;

use Test;

use constant NUM_TESTS => 8;

use Locale::Messages qw (bindtextdomain textdomain gettext pgettext);
require POSIX;
require File::Spec;

BEGIN {
	my $package;
	if ($0 =~ /_pp\.t$/) {
		$package = 'gettext_pp';
	} else {
		$package = 'gettext_xs';
	}

	my $selected = Locale::Messages->select_package ($package);
	if ($selected ne $package && 'gettext_xs' eq $package) {
		print "1..0 # Skip: Locale::$package not available here.\n";
		exit 0;
	}
	plan tests => NUM_TESTS;
}

my $locale_dir = $0;
$locale_dir =~ s,[^\\/]+$,, or $locale_dir = '.';
$locale_dir .= '/LocaleData';

my $textdomain = 'existing';
Locale::Messages::nl_putenv ("LANGUAGE=de_AT");
Locale::Messages::nl_putenv ("LC_ALL=de_AT");
Locale::Messages::nl_putenv ("LANG=de_AT");
Locale::Messages::nl_putenv ("LC_MESSAGES=de_AT");
Locale::Messages::nl_putenv ("OUTPUT_CHARSET=iso-8859-1");

my $bound_dir = bindtextdomain $textdomain => $locale_dir;

ok defined $bound_dir;
ok (File::Spec->catdir ($bound_dir), File::Spec->catdir ($bound_dir));

my $bound_domain = textdomain $textdomain;

ok defined $bound_domain;
ok $bound_domain, $textdomain;

# Default case.
ok gettext ('View'), 'Anzeigen';

# Default context case.
ok pgettext ('Which folder would you like to view?','View'), 'Ansicht';

# msgid eq msgstr.
ok pgettext ('Which folder would you like to view? (2)','View'), 'View 2';

# Unknown.
ok pgettext ('none', 'Not translated'), 'Not translated';

__END__

Local Variables:
mode: perl
perl-indent-level: 4
perl-continued-statement-offset: 4
perl-continued-brace-offset: 0
perl-brace-offset: -4
perl-brace-imaginary-offset: 0
perl-label-offset: -4
cperl-indent-level: 4
cperl-continued-statement-offset: 2
tab-width: 4
End:


code:
#! /usr/local/bin/perl -w

# vim: syntax=perl
# vim: tabstop=4

use strict;

use Test;

use constant NUM_TESTS => 4;

use Locale::Messages qw (textdomain);

BEGIN {
	my $package;
	if ($0 =~ /_pp\.t$/) {
		$package = 'gettext_pp';
	} else {
		$package = 'gettext_xs';
	}

	my $selected = Locale::Messages->select_package ($package);
	if ($selected ne $package && 'gettext_xs' eq $package) {
		print "1..0 # Skip: Locale::$package not available here.\n";
		exit 0;
	}
	plan tests => NUM_TESTS;
}

my $textdomain = '';
my $bound_domain = textdomain '';
ok defined $bound_domain;
ok $bound_domain, 'messages';

$textdomain = 'existing';
$bound_domain = textdomain $textdomain;
ok defined $bound_domain;
ok $bound_domain, $textdomain;

__END__

Local Variables:
mode: perl
perl-indent-level: 4
perl-continued-statement-offset: 4
perl-continued-brace-offset: 0
perl-brace-offset: -4
perl-brace-imaginary-offset: 0
perl-label-offset: -4
cperl-indent-level: 4
cperl-continued-statement-offset: 2
tab-width: 4
End:


code:
#! /usr/local/bin/perl -w

# vim: syntax=perl
# vim: tabstop=4

use strict;

use Test;

use constant NUM_TESTS => 2;

use Locale::Messages;
use POSIX;

BEGIN {
	plan tests => NUM_TESTS;
}

# Jan Kratochvil described the following bug: When using any functions
# from Locale::TextDomain with a locale setting for a language that
# has no message catalog installed, __find_domain() from Locale::TextDomain
# will never look into the directories "LocaleData" again.  It
# tries to bindtextdomain() to all search directories, and when it
# fails to find a translation for the emtpy string (should always be
# present), it will assume that this directory is not the one holding
# the mo files.
#
# This can actually only happen, when you switch languages behind the
# user's back. Fixed by checking for the presence of _any_ (g)mo file
# in the relevant directories.
BEGIN {
	# Force language that is not supported.
	Locale::Messages::nl_putenv ("LANGUAGE=en_US");
	Locale::Messages::nl_putenv ("LC_ALL=en_US");
	Locale::Messages::nl_putenv ("LANG=en_US");
	Locale::Messages::nl_putenv ("LC_MESSAGES=en_US");
	Locale::Messages::nl_putenv ("OUTPUT_CHARSET=iso-8859-1");

	POSIX::setlocale (POSIX::LC_ALL() => '');
}

# Make sure that LocaleData/ can befound.
BEGIN {
    unshift @INC, $1 if $0 =~ m#(.*)[\\\/]#;
}
use Locale::TextDomain ('existing');

ok "February" eq __"February";

Locale::Messages::nl_putenv ("LANGUAGE=de_AT");
Locale::Messages::nl_putenv ("LC_ALL=de_AT");
Locale::Messages::nl_putenv ("LANG=de_AT");
Locale::Messages::nl_putenv ("LC_MESSAGES=de_AT");

my $missing_locale = POSIX::setlocale (POSIX::LC_ALL() => '') ?
    '' : 'locale de_AT missing';

my $locale = POSIX::setlocale (POSIX::LC_ALL() => '');
my $translation = Locale::TextDomain::__("February");
skip $missing_locale, "Feber" eq $translation;

__END__

Local Variables:
mode: perl
perl-indent-level: 4
perl-continued-statement-offset: 4
perl-continued-brace-offset: 0
perl-brace-offset: -4
perl-brace-imaginary-offset: 0
perl-label-offset: -4
cperl-indent-level: 4
cperl-continued-statement-offset: 2
tab-width: 4
End:


code:
#! /usr/local/bin/perl -w

# vim: syntax=perl
# vim: tabstop=4

use strict;

use Test;

use constant NUM_TESTS => 5;

use Locale::TextDomain;
use POSIX;

BEGIN {
	plan tests => NUM_TESTS;
}

# When called in scalar context, N__() should return its argument,
# not a list.  On the other hand, the other noop functions should
# simply returns their arguments, see
# https://rt.cpan.org/Ticket/Display.html?id=46471 for more.

my $scalar;

$scalar = scalar N__"foobar";
ok 'foobar' eq $scalar;

($scalar) = scalar N__"foobar";
ok 'foobar' eq $scalar;

$scalar = scalar N__n"one", "two", 4;
ok 3 eq $scalar;

$scalar = scalar N__p"ctx", "foobar";
ok 2 eq $scalar;

$scalar = scalar N__np"ctx", "one", "two", 5;
ok 4 eq $scalar;

__END__

Local Variables:
mode: perl
perl-indent-level: 4
perl-continued-statement-offset: 4
perl-continued-brace-offset: 0
perl-brace-offset: -4
perl-brace-imaginary-offset: 0
perl-label-offset: -4
cperl-indent-level: 4
cperl-continued-statement-offset: 2
tab-width: 4
End:


code:
#! /usr/local/bin/perl -w

# vim: syntax=perl
# vim: tabstop=4

use strict;

use Test;

use constant NUM_TESTS => 4;

use Locale::Util qw (parse_http_accept_language parse_http_accept_charset);

BEGIN {
	plan tests => NUM_TESTS;
}

my ($string, @items, $items);

$string = "baz; q=0.1, foo, bar; q=0.7";
@items = parse_http_accept_language $string;
$items = join '|', @items;
ok $items, "foo|bar|baz";

# Illegal language identifiers should be filtered out.
$string = "baz; q=0.1, illegal4this, foo, bar; q=0.7";
@items = parse_http_accept_language $string;
$items = join '|', @items;
ok $items, "foo|bar|baz";

# The catch-all language is C.
$string = "baz; q=0.1, *; q=0.05, foo, bar; q=0.7";
@items = parse_http_accept_language $string;
$items = join '|', @items;
ok $items, "foo|bar|baz|C";

$string = "baz; q=0.1, foo, bar; q=0.7";
@items = parse_http_accept_charset $string;
$items = join '|', @items;
ok $items, "foo|bar|baz";

__END__

Local Variables:
mode: perl
perl-indent-level: 4
perl-continued-statement-offset: 4
perl-continued-brace-offset: 0
perl-brace-offset: -4
perl-brace-imaginary-offset: 0
perl-label-offset: -4
cperl-indent-level: 4
cperl-continued-statement-offset: 2
tab-width: 4
End:


code:
# Makefile for various po files.  This Makefile is intended for the
# maintainer.  No problem if you cannot run it on your system.

srcdir = .
top_srcdir = ..

LINGUAS = de de_AT
PACKAGES = existing additional

#CATALOGS = $(addsuffix .po, LINGUAS)
CATALOGS = $(LINGUAS)
MO_FILES = $(foreach pkg,$(PACKAGES), $(addprefix $(pkg)., $(addsuffix .mo, $(LINGUAS))))

MSGMERGE = msgmerge
MSGFMT   = msgfmt
CATOBJEXT = .po

all: default

default: install

install: $(MO_FILES)
	cd $(srcdir); \
	targetdir='$(top_srcdir)/LocaleData'; \
	languages='$(LINGUAS)'; \
	packages='$(PACKAGES)'; \
	for package in $$packages; do \
		for lang in $$languages; do \
			dest="$$targetdir/$$lang/LC_MESSAGES/$$package.mo"; \
			cat="$$package.$$lang.mo"; \
			echo "installing $$cat as $$dest"; \
			cp -f $$cat $$dest && chmod 644 $$dest || exit 1; \
		done; \
	done

update-mo: $(MO_FILES)
	@echo "MO-FILES: $(MO_FILES)"

clean:
	rm -f $(MO_FILES) *~

.SUFFIXES:
.SUFFIXES: .po .mo

.po.mo:
	$(MSGFMT) --check --statistics --verbose -o $@ $<


code:
msgid ""
msgstr ""
"Project-Id-Version: libintl-perl-text 0.01\n"
"POT-Creation-Date: 2002-07-13 11:47+02:00\n"
"PO-Revision-Date: 1999-02-16 21:14+01:00\n"
"Last-Translator: Guido Flohr <guido@imperia.net>\n"
"Language-Team: German <de@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=ISO-8859-1\n"
"Content-Transfer-Encoding: 8-bit\n"
"Plural-Forms: nplurals=4; plural=(n==1 ? 0 : n%10==2 ? 1 : n%10==3 || n%"
"10==4 ? 2 : 3);\n"

# The Plural-Forms header is wrong on purpose.  It is in fact the correct
# setting for Slovenian, but we abuse it here for testing ngettext and
# friends.
msgid "Singular"
msgid_plural "Plural"
msgstr[0] "Numerus 0"
msgstr[1] "Numerus 1"
msgstr[2] "Numerus 2"
msgstr[3] "Numerus 3"

msgctxt "Context here (2)"
msgid "Singular"
msgid_plural "Plural"
msgstr[0] "Numerus 2:0"
msgstr[1] "Numerus 2:1"
msgstr[2] "Numerus 2:2"
msgstr[3] "Numerus 2:3"

msgid "Sunday"
msgstr "Sonntag"

msgid "Monday"
msgstr "Montag"

msgid "Tuesday"
msgstr "Dienstag"

msgid "Wednesday"
msgstr "Mittwoch"

msgid "Thursday"
msgstr "Donnerstag"

msgid "Friday"
msgstr "Freitag"

msgid "Saturday"
msgstr "Samstag"

msgid "Another View"
msgstr "Eine andere Ansicht ohne Kontext"

msgctxt "Context"
msgid "Another View"
msgstr "Eine andere Ansicht mit Kontext"


code:
msgid ""
msgstr ""
"Project-Id-Version: libintl-perl-text 0.01\n"
"POT-Creation-Date: 2002-07-13 11:47+02:00\n"
"PO-Revision-Date: 1999-02-16 21:14+01:00\n"
"Last-Translator: Guido Flohr <guido@imperia.net>\n"
"Language-Team: German <de@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=ISO-8859-1\n"
"Content-Transfer-Encoding: 8-bit\n"
"Plural-Forms: nplurals=4; plural=(n==1 ? 0 : n%10==2 ? 1 : n%10==3 || n%"
"10==4 ? 2 : 3);\n"

msgid "Saturday"
msgstr "Sonnabend"


code:
msgid ""
msgstr ""
"Project-Id-Version: libintl-perl-text 1.12\n"
"POT-Creation-Date: 2002-07-13 11:47+02:00\n"
"PO-Revision-Date: 2005-08-10 19:02+03:00\n"
"Last-Translator: Guido Flohr <guido@imperia.net>\n"
"Language-Team: German <de@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8-bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

msgid "Singular"
msgid_plural "Plural"
msgstr[0] "Einzahl"
msgstr[1] "Mehrzahl"

msgid "January"
msgstr "Januar"

msgid "February"
msgstr "Februar"

msgid "March"
msgstr "März"

msgid "April"
msgstr "April"

msgid "May"
msgstr "Mai"

msgid "June"
msgstr "Juni"

msgid "July"
msgstr "Juli"

msgid "August"
msgstr "August"

msgid "September"
msgstr "September"

msgid "October"
msgstr "Oktober"

msgid "November"
msgstr "November"

msgid "December"
msgstr "Dezember"

msgid "View"
msgstr "Anzeigen"

msgctxt "Which folder would you like to view?"
msgid "View"
msgstr "Ansicht"

msgctxt "Which folder would you like to view? (2)"
msgid "View"
msgstr "View 2"

msgctxt "Context here (2)"
msgid "Singular"
msgid_plural "Plural"
msgstr[0] "Einzahl 2"
msgstr[1] "Mehrzahl 2"

msgctxt "Context here (3)"
msgid "Singular 3"
msgid_plural "Plural 3"
msgstr[0] "Einzahl 3"
msgstr[1] "Mehrzahl 3"


code:
msgid ""
msgstr ""
"Project-Id-Version: libintl-perl-text 1.12\n"
"POT-Creation-Date: 2002-07-13 11:47+02:00\n"
"PO-Revision-Date: 2005-08-10 19:01+03:00\n"
"Last-Translator: Guido Flohr <guido@imperia.net>\n"
"Language-Team: German <de@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=ISO-8859-1\n"
"Content-Transfer-Encoding: 8-bit\n"

msgid "January"
msgstr "J�nner"

msgid "February"
msgstr "Feber"


code:
#! /bin/sh
# $Id$
# Regenerate lists of t/ files, used for make dist(check)
# and the Perl modules.
#
# Copyright 2011, 2012, 2013, 2014, 2015 Free Software Foundation, Inc.
#
# This file is free software; as a special exception the author gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# Originally written by Patrice Dumas.

set -e

# to get a reproducible locales independent sort.
LC_ALL=C; export LC_ALL

# Regenerate files required for perl

./maintain/change_perl_modules_version.sh auto

# This regenerate files in t/include_dir/
make
# regenerate the list of XSParagraph files
sed 's;^;Texinfo/Convert/XSParagraph/;' < Texinfo/Convert/XSParagraph/MANIFEST > maintain/MANIFEST_XSParagraph_files

PACKAGE=`grep '^PACKAGE = ' Makefile | sed 's/^PACKAGE = //'`
if test z"$PACKAGE" = 'z' ; then
  exit 1
fi
# LocaleData are also generated through Makefile.docstr.  Here we want
# them to be generated by the Makefile in po*/ to test that it works.
rm -rf LocaleData

for dir in po po_document; do
  rm -rf $dir
  mkdir $dir
  cp maintain/Makefile_perl_po $dir/Makefile
  grep '^tp\/' ../$dir/POTFILES.in | sed -e 's/^tp/../' > $dir/POTFILES.in
  echo "# File automatically generated from texinfo files"
  echo "PACKAGE = $PACKAGE" > $dir/PACKAGE
  cat ../$dir/Makevars >> $dir/PACKAGE
  linguas_str=
  for lingua in `cat ../$dir/LINGUAS`; do
    linguas_str="$linguas_str $lingua"
    cp -p ../$dir/$lingua.po $dir
  done
  echo "LINGUAS = $linguas_str" >> $dir/PACKAGE

  (cd $dir && make all && make clean)
done

find LocaleData po_document po t/include_dir -type f | sort \
  > maintain/MANIFEST_generated_files
make MANIFEST
cp -p ../COPYING .
sed 's/\(my \$hardcoded_version = \).*/\1 undef;/' texi2any.pl > texi2any
chmod a+x texi2any
touch -r texi2any.pl texi2any
# We could imagine using an even more stripped down version, as
# the default paths should be ok in a standalone module.
cp -p Texinfo/ModulePath.pm.in Texinfo/ModulePath.pm


code:
#! /bin/sh

# Make sure that we start with the automake generated Makefile
(cd ../ && ./config.status)
./maintain/prepare_perl_module_files.sh

VERSION=`grep '^VERSION = ' Makefile | sed 's/^VERSION = *//'`
[ z"$VERSION" = 'z' ] && exit 1
perl Makefile.PL NO_MYMETA=1
rm -f Texinfo-$VERSION.tar.gz
make && make dist
tar xzvf Texinfo-$VERSION.tar.gz
(cd Texinfo-$VERSION/ && perl Makefile.PL && make && make test && \
                 ./maintain/all_tests.sh clean && make distcheck) || exit 1
rm -rf Texinfo-$VERSION/

./maintain/clean_perl_module_files.sh


code:
#! /bin/sh
# $Id$
# Use information from test driving files to regenerate test scripts
# that run only one test, and file lists to be used in Makefiles.
#
# Copyright 2013, 2014, 2016 Free Software Foundation, Inc.
#
# This file is free software; as a special exception the author gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# Originally written by Patrice Dumas.

# This script is run from "tp/tests/Makefile.am" to regenerate
# "tp/tests/Makefile.onetst".

#set -x

test_file='tests-parser.txt'
test_scripts_dir='test_scripts'

test -d $test_scripts_dir || mkdir $test_scripts_dir

dir=`echo $0 | sed 's,/[^/]*$,,'`
outfile=$1
shift
destdir=$1
shift

while test z"$1" = 'z-base' -o z"$1" = 'z-tex_html'; do
  if test z"$1" = 'z-base'; then
    base_test_dirs=$2
  elif test z"$1" = 'z-tex_html'; then
    tex_html_test_dirs=$2
  else
    echo "$0: Bad args" 1>&2
    exit 1
  fi
  shift
  shift
done

(
cd "$dir/../tests/$destdir" || exit 1

test_driving_files='# List of files that describe tests.  See tp/tests/README.
test_driving_files_generated_list ='
one_test_files='# List of test scripts that only run one test
one_test_files_generated_list = '

gather_tests() {
type=$1
shift
test_dirs=$1
for test_dir in $test_dirs; do
  driving_file=$test_dir/tests-parser.txt
  if test -f $driving_file; then
    test_driving_files="$test_driving_files $driving_file"
    while read line
    do
    if echo $line | grep '^ *#' >/dev/null; then continue; fi
# there are better ways
    name=`echo $line | awk '{print $1}'`
    arg=$name
    file=`echo $line | awk '{print $2}'`
    remaining=`echo $line | sed 's/[a-zA-Z0-9_./-]*  *[a-zA-Z0-9_./-]* *//'`
    test "z$name" = 'z' -o "$zfile" = 'z' && continue
    basename=`basename $file .texi`
    if test "z$name" = 'ztexi' ; then
      name="texi_${basename}"
      arg="texi ${basename}.texi"
    fi
    if test "z${test_dir}" = 'z.'; then
      name_prepended=${destdir}_
      relative_command_dir='/..'
    else
      name_prepended=${test_dir}_
      relative_command_dir=
    fi
    one_test_file="$test_scripts_dir/${name_prepended}$name.sh"
    one_test_files="$one_test_files \\
     $one_test_file"
    echo '#! /bin/sh
# This file generated by maintain/regenerate_cmd_tests.sh

if test z"$srcdir" = "z"; then
  srcdir=.
fi

command=run_parser_all.sh
one_test_logs_dir=test_log
diffs_dir=diffs

' > $one_test_file

    if test $type = 'tex_html'; then
      echo '
if test "z$TEX_HTML_TESTS" != z"yes"; then
  echo "Skipping HTML TeX tests that are not easily reproducible"
  exit 77
fi
' >> $one_test_file
    fi
    echo "dir=$test_dir
arg='$arg'
name='$name'
"'[ -d "$dir" ] || mkdir $dir

srcdir_test=$dir; export srcdir_test;
"$srcdir"'"$relative_command_dir"'/"$command" -dir $dir $arg
exit_status=$?
cat $dir/$one_test_logs_dir/$name.log
if test -f $dir/$diffs_dir/$name.diff; then
  echo
  cat $dir/$diffs_dir/$name.diff
fi
exit $exit_status
' >> $one_test_file
    chmod 0755 $one_test_file
    done < $driving_file
  else
    echo "$0: Missing file $driving_file" 1>&2
    exit 1
  fi
done
}

basefile=`basename $outfile`
cat >$outfile <<END_HEADER
# $basefile generated by $0.
#
# Copyright 2016 Free Software Foundation, Inc.
#
# This file is free software; as a special exception the author gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

END_HEADER

gather_tests base "$base_test_dirs"
gather_tests tex_html "$tex_html_test_dirs"

echo "$test_driving_files
" >> $outfile

echo "$one_test_files
" >>$outfile

)


code:
#! /bin/sh
# $Id$
# This little script pastes the content of maintain/template.pod at the
# end of converter modules, with the output format name suitably defined.
# This file should be run when maintain/template.pod is modified.
#
# Copyright 2011, 2012, 2013, 2014, 2015 Free Software Foundation, Inc.
#
# This file is free software; as a special exception the author gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# Originally written by Patrice Dumas.

for format in HTML TexinfoXML DocBook Info Plaintext; do
  sed -e '/^__END__/q' Texinfo/Convert/$format.pm \
    > Texinfo/Convert/$format.pm.$$.tmp || exit 1

  sed -e "s/OUTFORMAT/$format/g" maintain/template.pod \
  | if test $format = HTML; then
      sed 's/^__HTML \?//'
    else
      sed -e '/^__HTML/d'
    fi \
  > maintain/$format.pod || exit 1

  sed -e "/^__END__/r maintain/$format.pod" Texinfo/Convert/$format.pm.$$.tmp \
    > Texinfo/Convert/$format.pm || exit 1

  rm -f maintain/$format.pod Texinfo/Convert/$format.pm.$$.tmp
done


code:
#! /bin/sh
# $Id$
# Copyright 2011, 2012, 2013, 2014, 2015, 2016 Free Software Foundation, Inc.
#
# This file is free software; as a special exception the author gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# Originally written by Patrice Dumas.

dir=`echo $0 | sed 's,/[^/]*$,,'`
outfile=$1

(
cd "$dir/.." || exit 1

if test -f ../po_document/LINGUAS; then :; else
  echo "$0: no ../po_document/LINGUAS, goodbye" 1>&2
  exit 1
fi

basefile=`basename $outfile`
cat >$outfile <<END_HEADER
# $basefile generated by $0.
#
# Copyright 2017 Free Software Foundation, Inc.
#
# This file is free software; as a special exception the author gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

END_HEADER

for lingua in `cat ../po_document/LINGUAS`; do
  # Only run by maintainers, so assume GNU make (by using $@ in regular rules).
  # Just for convenience.
  echo '
$(srcdir)/../po_document/'"$lingua.gmo"': $(srcdir)/../po_document/'"$lingua.po"'
	cd ../po_document/ && $(MAKE) $(AM_MAKEFLAGS) '"$lingua.gmo"'

LocaleData/'"$lingua"'/LC_MESSAGES/$(document_domain).mo: $(srcdir)/../po_document/'"$lingua"'.gmo
	$(MKDIR_P) `dirname $@`
	$(INSTALL_DATA) $(srcdir)/../po_document/'"$lingua"'.gmo $@

' >>$outfile

  dependencies="$dependencies "'LocaleData/'"$lingua"'/LC_MESSAGES/$(document_domain).mo'
done

echo 'document_strings_mo_files = '"$dependencies" >>$outfile
)


code:
#! /usr/bin/env perl

# regenerate_documentlanguages.pl: download the iana files language
# and regenerate Texinfo/Documentlanguages.pm list of languages and regions
#
# Copyright 2010, 2011, 2012 Free Software Foundation, Inc.
#
# Copying and distribution of this file, with or without modification,
# are permitted in any medium without royalty provided the copyright
# notice and this notice are preserved.  This file is offered as-is,
# without any warranty.
#
# Original author: Patrice Dumas <pertusus@free.fr>
#
# Calling that script for each release could be a good idea.

use strict;

# emulates -w
BEGIN
{
  $^W = 1;
}

my $dir = 'maintain';
system ("cd $dir && wget -N http://www.iana.org/assignments/language-subtag-registry");

open (TXT,"$dir/language-subtag-registry") or die "Open $dir/language-subtag-registry: $!\n";

my $entry;
my @entries;
while (<TXT>) {
 if (/^%%/) {
   push @entries, $entry if (defined($entry));
   $entry = undef;
 } else {
   if (/^(\w+): (.*)/) {
     $entry->{$1} = $2;
   }
 }
}
push @entries, $entry if (defined($entry));
if (!defined($entry->{'Type'})) {
  die "Type not defined for $entry ".join('|', keys(%$entry))."\n";
}

open (OUT, ">Texinfo/Documentlanguages.pm") or die "Open Texinfo/Documentlanguages.pm: $!\n";

print OUT "# This file was automatically generated from $0\n\n";

print OUT "package Texinfo::Documentlanguages;\n\n";

print OUT 'our %language_codes = ('."\n";
foreach my $entry (@entries)
{
  # Scope collection macrolanguage are used
  if ($entry->{'Type'} eq 'language' and !defined($entry->{'Preferred-Value'})
       and !defined($entry->{'Macrolanguage'})
       and (!defined($entry->{'Scope'})
            or ($entry->{'Scope'} ne 'special'
                and $entry->{'Scope'} ne 'private-use'))) {
    print OUT "'$entry->{'Subtag'}' => 1,\n";
    print STDERR "$entry->{'Subtag'} Scope $entry->{'Scope'}\n"
       if defined($entry->{'Scope'});
  }
}
print OUT ");\n\n";

print OUT 'our %region_codes = ('."\n";
foreach my $entry (@entries)
{
  if ($entry->{'Type'} eq 'region' and !defined($entry->{'Preferred-Value'})
      and $entry->{'Description'} ne 'Private use'
      and $entry->{'Subtag'} !~ /^\d{3}$/) {
    print OUT "'$entry->{'Subtag'}' => 1,\n";
  }
}
print OUT ");\n\n1;\n";


code:
#! /usr/bin/env perl
# $Id$
# Copyright 2011, 2012, 2013, 2014, 2015, 2016 Free Software Foundation, Inc.
#
# This file is free software; as a special exception the author gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# Originally written by Patrice Dumas.

use strict;

# emulates -w
BEGIN
{
  $^W = 1;
}
use File::Find;
use File::Basename;
use File::Spec;

my ($command, $mydir, $suffix) = fileparse($0);
my $parent = File::Spec->catdir($mydir, File::Spec->updir());
chdir($parent) || die "chdir $parent: $!";
-d "t" || (die "goodbye, no t directory in " . `pwd`);

my %files;
find (\&wanted, ('t'));
sub wanted
{
  if ((/\.pl$/ and $File::Find::dir =~ m:^t/results/[^/]+:)
      or (!/^CVS$/ and !/^\.svn$/
          and $File::Find::dir =~ m:^t/results/[^/]+/[^/]+/res_[^/]+$:)) {
    $files{$File::Find::name} = 1;
  }
}

my %tap_files;
find (\&wanted_tap_files, ('t'));
sub wanted_tap_files
{
  if (/\.t$/ and $File::Find::dir =~ /t$/) {
    $tap_files{$File::Find::name} = 1;
  }
}

my %include_files;
find (\&wanted_include_files, ('t'));
sub wanted_include_files
{
  if (/\.[a-z]+$/ and !/^\.svn$/
      and $File::Find::dir =~ m:^t/include_reference:) {
    $include_files{$File::Find::name} = 1;
  }
}
#print STDERR join('|', keys(%include_files))."\n";

open (INCLUDE, '>Makefile.tres') or die "open(>Makefile.tres) failed: $!";
print INCLUDE <<EOH;
# Makefile.tres generated by $0.
#
# Copyright 2016 Free Software Foundation, Inc.
#
# This file is free software; as a special exception the author gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
EOH

print INCLUDE 'test_tap_files_generated_list =';
foreach my $file (sort(keys(%tap_files))) {
  print INCLUDE " \\\n  $file";
}
print INCLUDE "\n\n";

print INCLUDE 'test_files_generated_list = $(test_tap_files_generated_list)';
foreach my $file (sort(keys(%files)), sort(keys(%include_files))) {
  print INCLUDE " \\\n  $file";
}
print INCLUDE "\n\n";

print INCLUDE "t/include_dir:\n".
   "\t".'$(MKDIR_P) $@'."\n\n";
my $test_copied_include_files = 'test_copied_include_files =';
foreach my $include_file (sort(keys(%include_files))) {
  my $bfile = basename($include_file);
  $test_copied_include_files .= " t/include_dir/$bfile";

  print INCLUDE "t/include_dir/$bfile: \$(srcdir)/$include_file t/include_dir\n"
     ."\t".'$(INSTALL_DATA) $(srcdir)/'.$include_file.' $@'."\n\n";
}

print INCLUDE $test_copied_include_files ."\n\n";


code:
#! /bin/sh

# This script should be run when t/input_files/char_latin1_utf8_in_refs.texi
# is modified

iconv -f utf8 -t latin1 < t/input_files/char_latin1_utf8_in_refs.texi > t/input_files/char_latin1_latin1_in_refs.texi
sed -e 's/@documentencoding utf-8/@documentencoding iso-8859-1/' t/input_files/char_latin1_latin1_in_refs.texi > t/input_files/char_latin1_latin1_in_refs.texi.$$.tmp
mv t/input_files/char_latin1_latin1_in_refs.texi.$$.tmp t/input_files/char_latin1_latin1_in_refs.texi


code:
# $Id$
# Automatically generated from maintain/template.pod

=head1 NAME

Texinfo::Convert::OUTFORMAT - Convert Texinfo tree to OUTFORMAT

=head1 SYNOPSIS

  my $converter
    = Texinfo::Convert::OUTFORMAT->converter({'parser' => $parser});

  $converter->output($tree);
  $converter->convert($tree);
  $converter->convert_tree($tree);
__HTML   $converter->output_internal_links(); # HTML only

=head1 DESCRIPTION

Texinfo::Convert::OUTFORMAT converts a Texinfo tree to OUTFORMAT.

=head1 METHODS

=over

=item $converter = Texinfo::Convert::OUTFORMAT->converter($options)

Initialize converter from Texinfo to OUTFORMAT.

The I<$options> hash reference holds options for the converter.  In
this option hash reference a parser object may be associated with the
I<parser> key.  The other options should be configuration options
described in the Texinfo manual.  Those options, when appropriate,
override the document content.

See L<Texinfo::Convert::Converter> for more informations.

=item $converter->output($tree)

Convert a Texinfo tree I<$tree> and output the result in files as
described in the Texinfo manual.

=item $result = $converter->convert($tree)

Convert a Texinfo tree I<$tree> or tree portion and return
the resulting output.

=item $result = $converter->convert_tree($tree)

Convert a Texinfo tree portion I<$tree> and return the resulting
output.  This function does not try to output a full document but only
portions.  For a full document use C<convert>.

__HTML =item $result = $converter->output_internal_links()
__HTML
__HTML Returns text representing the links in the document.  The format should
__HTML follow the C<--internal-links> option of the texi2any/makeinfo
__HTML specification.  This is only supported in (and relevant for) HTML.
__HTML
=back

=head1 AUTHOR

Patrice Dumas, E<lt>pertusus@free.frE<gt>

=head1 COPYRIGHT AND LICENSE

Copyright 2016 Free Software Foundation, Inc.

This library is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or (at
your option) any later version.

=cut