From owner-svn-src-user@FreeBSD.ORG Wed Jul 29 22:02:13 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 995FD106566B; Wed, 29 Jul 2009 22:02:13 +0000 (UTC) (envelope-from edwin@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 879028FC0A; Wed, 29 Jul 2009 22:02:13 +0000 (UTC) (envelope-from edwin@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n6TM2DM3083643; Wed, 29 Jul 2009 22:02:13 GMT (envelope-from edwin@svn.freebsd.org) Received: (from edwin@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n6TM2DvU083639; Wed, 29 Jul 2009 22:02:13 GMT (envelope-from edwin@svn.freebsd.org) Message-Id: <200907292202.n6TM2DvU083639@svn.freebsd.org> From: Edwin Groothuis Date: Wed, 29 Jul 2009 22:02:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r195955 - user/edwin/locale/tools X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Jul 2009 22:02:13 -0000 Author: edwin Date: Wed Jul 29 22:02:13 2009 New Revision: 195955 URL: http://svn.freebsd.org/changeset/base/195955 Log: Add support for the (FreeBSD specific) alternative month. Since it is not defined in the CLDR, we have to keep track of the information ourselves as long it differs from the normal long month name. Modified: user/edwin/locale/tools/charmaps.pm user/edwin/locale/tools/charmaps.xml user/edwin/locale/tools/cldr2def.pl Modified: user/edwin/locale/tools/charmaps.pm ============================================================================== --- user/edwin/locale/tools/charmaps.pm Wed Jul 29 21:54:34 2009 (r195954) +++ user/edwin/locale/tools/charmaps.pm Wed Jul 29 22:02:13 2009 (r195955) @@ -1,5 +1,9 @@ #!/usr/local/bin/perl -w +# +# $FreeBSD$ +# + use strict; use XML::Parser; use Data::Dumper; @@ -9,7 +13,9 @@ my %d = (); my $index = -1; sub get_xmldata { - open(FIN, "charmaps.xml"); + my $xmlfile = shift; + + open(FIN, $xmlfile); my @xml = ; chomp(@xml); close(FIN); @@ -38,10 +44,12 @@ sub h_start { $data{element}{++$index} = $element; - if ($element eq "language") { + if ($index == 2 + && $data{element}{1} eq "languages" + && $element eq "language") { my $name = $attrs{name}; - my $encoding = $attrs{encoding}; my $countries = $attrs{countries}; + my $encoding = $attrs{encoding}; my $family = $attrs{family}; my $f = defined $attrs{family} ? $attrs{family} : "x"; my $link = $attrs{link}; @@ -63,7 +71,9 @@ sub h_start { return; } - if ($element eq "translation") { + if ($index == 2 + && $data{element}{1} eq "translations" + && $element eq "translation") { if (defined $attrs{hex}) { my $k = "<" . $attrs{cldr} . ">"; my $hs = $attrs{hex}; @@ -80,17 +90,51 @@ sub h_start { } return; } + + if ($index == 2 + && $data{element}{1} eq "alternativemonths" + && $element eq "language") { + my $name = $attrs{name}; + my $countries = $attrs{countries}; + + $data{fields}{name} = $name; + $data{fields}{countries} = $countries; + $data{fields}{text} = ""; + + return; + } } sub h_end { my $expat = shift; my $element = shift; + + if ($index == "2") { + if ($data{element}{1} eq "alternativemonths" + && $data{element}{2} eq "language") { + foreach my $c (split(/,/, $data{fields}{countries})) { + my $m = $data{fields}{text}; + + $m =~ s/[\t ]//g; + $d{AM}{$data{fields}{name}}{$c} = $m; + } + $data{fields} = (); + } + } + $index--; } sub h_char { my $expat = shift; my $string = shift; + + if ($index == "2") { + if ($data{element}{1} eq "alternativemonths" + && $data{element}{2} eq "language") { + $data{fields}{text} .= $string; + } + } } #use Data::Dumper; Modified: user/edwin/locale/tools/charmaps.xml ============================================================================== --- user/edwin/locale/tools/charmaps.xml Wed Jul 29 21:54:34 2009 (r195954) +++ user/edwin/locale/tools/charmaps.xml Wed Jul 29 22:02:13 2009 (r195955) @@ -1,3 +1,4 @@ + + countries="AD ES FR IT" /> @@ -46,7 +52,7 @@ countries="GR" /> + countries="AU CA GB NZ US ZA" /> + + + @@ -234,4 +243,159 @@ + + + + + "; + ""; + ""; + ""; + ""; + ""; + ""; + ""; + ""; + ""; + ""; + "" + ]]> + + + "; + ""; + ""; + ""; + ""; + ""; + ""; + "

"; + ""; + ""; + "

"; + "

" + ]]> + + + "; + ""; + ""; + ""; + ""; + ""; + ""; + ""; + ""; + ""; + ""; + "" + ]]> + + + "; + ""; + ""; + ""; + ""; + ""; + ""; + ""; + ""; + ""; + ""; + "" + ]]> + + + "; + ""; + ""; + ""; + ""; + ""; + "

"; + "

"; + ""; + "

"; + "

"; + "" + ]]> + + + "; + ""; + ""; + ""; + ""; + ""; + ""; + ""; + ""; + ""; + ""; + "" + ]]> + + + "; + ""; + ""; + ""; + ""; + ""; + "

"; + "

"; + ""; + "

"; + "

"; + "" + ]]> + + + "; + ""; + ""; + ""; + ""; + ""; + ""; + ""; + ""; + ""; + ""; + "" + ]]> + + + "; + ""; + ""; + ""; + ""; + ""; + ""; + ""; + ""; + ""; + ""; + "" + ]]> + + + + Modified: user/edwin/locale/tools/cldr2def.pl ============================================================================== --- user/edwin/locale/tools/cldr2def.pl Wed Jul 29 21:54:34 2009 (r195954) +++ user/edwin/locale/tools/cldr2def.pl Wed Jul 29 22:02:13 2009 (r195955) @@ -1,5 +1,9 @@ #!/usr/bin/perl -wC +# +# $FreeBSD$ +# + use strict; use XML::Parser; use Text::Iconv; @@ -26,6 +30,7 @@ my %values = (); my %hashtable = (); my %languages = (); my %translations = (); +my %alternativemonths = (); get_languages(); my %cm = (); @@ -44,6 +49,8 @@ my %FILESNAMES = ( my %callback = ( mdorder => \&callback_mdorder, + altmon => \&callback_altmon, + data => (), ); my %DESC = ( @@ -87,7 +94,7 @@ my %DESC = ( "XXX" => "c_fmt", "am_pm" => "AM/PM", "d_t_fmt" => "date_fmt", - "mon2" => "Long month names (without case ending)", + "altmon" => "Long month names (without case ending)", "md_order" => "md_order", "t_fmt_ampm" => "ampm_fmt", @@ -151,7 +158,8 @@ if ($TYPE eq "timedef") { "am_pm" => "as", "d_fmt" => "s", "d_t_fmt" => "s", - "mon2" => ">mon", # repeat them for now +# "altmon" => ">mon", # repeat them for now + "altmon" => " " "s", ); @@ -167,6 +175,18 @@ sub callback_mdorder { return $s; }; +sub callback_altmon { + # if the language/country is known in %alternative months then + # return that, otherwise repeat mon + my $s = shift; + + if (defined $alternativemonths{$callback{data}{l}}{$callback{data}{c}}) { + return $alternativemonths{$callback{data}{l}}{$callback{data}{c}}; + } + + return $s; +} + ############################ sub get_utf8map { @@ -197,6 +217,7 @@ sub get_languages { my %data = get_xmldata($CHARMAPS); %languages = %{$data{L}}; %translations = %{$data{T}}; + %alternativemonths = %{$data{AM}}; return if (!defined $doonly); @@ -342,16 +363,24 @@ EOF $output .= "#\n# $DESC{$k}\n"; + # Replace one row with another if ($f =~ /^>/) { $k = substr($f, 1); $f = $keys{$k}; } + + # Callback function if ($f =~ /^\ EOF