lib/I18N/LangTags.pm I18N::LangTags
lib/I18N/LangTags/README I18N::LangTags
lib/I18N/LangTags/t/01test.t See whether I18N::LangTags works
+lib/I18N/LangTags/t/02decency.t See if I18N::LangTags::List::is_decent works
lib/if.pm For "use if"
lib/if.t Tests for "use if"
lib/importenv.pl Perl routine to get environment into variables
-# Time-stamp: "2003-07-20 07:44:42 ADT"
+# Time-stamp: "2003-10-10 17:43:04 ADT"
# Sean M. Burke <sburke@cpan.org>
require 5.000;
);
%EXPORT_TAGS = ('ALL' => \@EXPORT_OK);
-$VERSION = "0.28";
+$VERSION = "0.29";
=head1 NAME
$lang1 are mutually intelligible with $lang1. Consider this
carefully.
-=cut
+=cut
sub super_languages {
my $lang1 = $_[0];
The output is untainted. If you don't know what tainting is,
don't worry about it.
-=cut
+=cut
sub locale2language_tag {
my $lang =
Value and Encoded Word Extensions: Character Sets, Languages, and
Continuations".
-* RFC 2482, C<ftp://ftp.isi.edu/in-notes/rfc2482.txt>,
+* RFC 2482, C<ftp://ftp.isi.edu/in-notes/rfc2482.txt>,
"Language Tagging in Unicode Plain Text".
* Locale::Codes, in
Revision history for Perl module I18N::LangTags.
- Time-stamp: "2002-02-02 20:45:47 MST"
+ Time-stamp: "2003-10-10 17:07:55 ADT"
+2003-10-10 Sean M. Burke sburke@cpan.org
+
+ * Release 0.29
+
+ Minor bugfix to I18N::LangTags::List code. Addition of the
+ is_decent function, and the 02decency.t test for it.
+
+ Better Makefile. Thanks to everyone who told me about the
+ INSTALLDIRS trick.
+
+
+
+2003-07-20 Sean M. Burke sburke@cpan.org
+
+ * Release 0.28
+ Doc fixes in I18N::LangTags, plus a few added variances (jw/jv,
+ cre/cr, etc.)
+ Lots of updates to I18N::LangTags::List
+ Deleted rfc3066.txt from dist.
+ Moved test.pl to t/01test.t and added more tests.
+
2002-02-02 Sean M. Burke sburke@cpan.org
* Release 0.27 -- minor mods to ::List:
require 5;
package I18N::LangTags::List;
-# Time-stamp: "2003-07-20 07:31:08 ADT"
+# Time-stamp: "2003-10-10 17:39:45 ADT"
use strict;
-use vars qw(%Name $Debug $VERSION);
-$VERSION = '0.26';
+use vars qw(%Name %Is_Disrec $Debug $VERSION);
+$VERSION = '0.29';
# POD at the end.
#----------------------------------------------------------------------
# read the table out of our own POD!
my $seeking = 1;
my $count = 0;
- my($tag,$name);
+ my($disrec,$tag,$name);
my $last_name = '';
while(<I18N::LangTags::List::DATA>) {
if($seeking) {
$seeking = 0 if m/=for woohah/;
- } elsif( ($tag, $name) =
- m/\{([-0-9a-zA-Z]+)\}(?:\s*:)?\s*([^\[\]]+)/
+ } elsif( ($disrec, $tag, $name) =
+ m/(\[?)\{([-0-9a-zA-Z]+)\}(?:\s*:)?\s*([^\[\]]+)/
) {
$name =~ s/\s*[;\.]*\s*$//g;
next unless $name;
++$count;
print "<$tag> <$name>\n" if $Debug;
$last_name = $Name{$tag} = $name;
- } elsif (m/Formerly \"([-a-z0-9]+)\"/) {
+ $Is_Disrec{$tag} = 1 if $disrec;
+ } elsif (m/[Ff]ormerly \"([-a-z0-9]+)\"/) {
$Name{$1} = "$last_name (old tag)" if $last_name;
+ $Is_Disrec{$1} = 1;
}
}
die "No tags read??" unless $count;
return "$name (Subform \"$subform\")";
}
+#--------------------------------------------------------------------------
+
+sub is_decent {
+ my $tag = lc($_[0] || return 0);
+ #require I18N::LangTags;
+
+ return 0 unless
+ $tag =~
+ /^(?: # First subtag
+ [xi] | [a-z]{2,3}
+ )
+ (?: # Subtags thereafter
+ - # separator
+ [a-z0-9]{1,8} # subtag
+ )*
+ $/xs;
+
+ my @supers = ();
+ foreach my $bit (split('-', $tag)) {
+ push @supers,
+ scalar(@supers) ? ($supers[-1] . '-' . $bit) : $bit;
+ }
+ return 0 unless @supers;
+ shift @supers if $supers[0] =~ m<^(i|x|sgn)$>s;
+ return 0 unless @supers;
+
+ foreach my $f ($tag, @supers) {
+ return 0 if $Is_Disrec{$f};
+ return 2 if $Name{$f};
+ # so that decent subforms of indecent tags are decent
+ }
+ return 2 if $Name{$tag}; # not only is it decent, it's known!
+ return 1;
+}
+
+#--------------------------------------------------------------------------
1;
__DATA__
=head1 DESCRIPTION
-This module provides a function
+This module provides a function
C<I18N::LangTags::List::name( I<langtag> ) > that takes
a language tag (see L<I18N::LangTags|I18N::LangTags>)
and returns the best attempt at an English name for it, or
The function I18N::LangTags::List::name(...) is not exported.
+This module also provides a function
+C<I18N::LangTags::List::is_decent( I<langtag> )> that returns true iff
+the language tag is syntactically valid and is for general use (like
+"fr" or "fr-ca", below). That is, it returns false for tags that are
+syntactically invalid and for tags, like "aus", that are listed in
+brackets below. This function is not exported.
+
The map of tags-to-names that it uses is accessable as
%I18N::LangTags::List::Name, and it's the same as the list
that follows in this documentation, which should be useful
for denoting human languages. The two-letter ISO 639-1 language
codes are well known (as "en" for English), as are their forms
when qualified by a country code ("en-US"). Less well-known are the
-arbitrary-length non-ISO codes (like "i-mingo"), and the
+arbitrary-length non-ISO codes (like "i-mingo"), and the
recently (in 2001) introduced three-letter ISO-639-2 codes.
Remember these important facts:
The latest version of I18N::LangTags is available from the
Comprehensive Perl Archive Network (CPAN). Visit
-<http://www.cpan.org/> to find a CPAN site near you.
+<http://www.perl.com/CPAN/> to find a CPAN site near you.
COPYRIGHT
use vars qw($VERSION @Pagers $Bindir $Pod2man
$Temp_Files_Created $Temp_File_Lifetime
);
-$VERSION = '3.10';
+$VERSION = '3.11';
#..........................................................................
BEGIN { # Make a DEBUG constant very first thing...
*IS_Dos = $^O eq 'dos' ? \&TRUE : \&FALSE unless defined &IS_Dos;
*IS_OS2 = $^O eq 'os2' ? \&TRUE : \&FALSE unless defined &IS_OS2;
*IS_Cygwin = $^O eq 'cygwin' ? \&TRUE : \&FALSE unless defined &IS_Cygwin;
+ *IS_Linux = $^O eq 'linux' ? \&TRUE : \&FALSE unless defined &IS_Linux;
+ *IS_HPUX = $^O =~ m/hpux/ ? \&TRUE : \&FALSE unless defined &IS_HPUX;
}
$Temp_File_Lifetime ||= 60 * 60 * 24 * 5;
. " $switches --lax $file | $render -man"
; # no temp file, just a pipe!
+ # Thanks to Brendan O'Dea for contributing the following block
+ if(Pod::Perldoc::IS_Linux and -t STDOUT
+ and my ($cols) = `stty -a` =~ m/\bcolumns\s+(\d+)/
+ ) {
+ my $c = $cols * 39 / 40;
+ $cols = $c > $cols - 2 ? $c : $cols -2;
+ $command .= ' -rLL=' . (int $c) . 'n' if $cols > 80;
+ }
+
# I hear persistent reports that adding a -c switch to $render
# solves many people's problems. But I also hear that some mans
# don't have a -c switch, so that adding it here would presumably
# be a Bad Thing -- sburke@cpan.org
- $command .= " | col -x" if $^O =~ /hpux/;
+ $command .= " | col -x" if Pod::Perldoc::IS_HPUX;
defined(&Pod::Perldoc::DEBUG)
and Pod::Perldoc::DEBUG()
Past contributors are:
Kenneth Albanowski <kjahds@kjahds.com>,
-Andy Dougherty <doughera@lafayette.edu>,
+Andy Dougherty <doughera@lafcol.lafayette.edu>,
and many others.
=cut
# This "$file" file was generated by "$0"
require 5;
-use Pod::Perldoc;
BEGIN { \$^W = 1 if \$ENV{'PERLDOCDEBUG'} }
+use Pod::Perldoc;
exit( Pod::Perldoc->run() );
!GROK!THIS!