Blame internal/langpod

Packit 95306a
#!/usr/bin/perl -w
Packit 95306a
# Copyright (c) 2012-2017 Sullivan Beck.  All rights reserved.
Packit 95306a
# This program is free software; you can redistribute it and/or modify it
Packit 95306a
# under the same terms as Perl itself.
Packit 95306a
Packit 95306a
###############################################################################
Packit 95306a
###############################################################################
Packit 95306a
# This script is used to automatically generate the language pod files.
Packit 95306a
Packit 95306a
use lib "./lib";
Packit 95306a
Packit 95306a
require 5.010000;
Packit 95306a
use IO::File;
Packit 95306a
use strict;
Packit 95306a
use warnings;
Packit 95306a
require Date::Manip::Lang::index;
Packit 95306a
$| = 1;
Packit 95306a
Packit 95306a
our $VERSION;
Packit 95306a
$VERSION='6.31';
Packit 95306a
Packit 95306a
##############################################################################
Packit 95306a
# GLOBAL VARIABLES
Packit 95306a
###############################################################################
Packit 95306a
Packit 95306a
our $langdir  = 'lib/Date/Manip/Lang';
Packit 95306a
our $curry    = ( localtime(time) )[5] + 1900;
Packit 95306a
Packit 95306a
###############################################################################
Packit 95306a
# HELP
Packit 95306a
###############################################################################
Packit 95306a
Packit 95306a
our ($usage);
Packit 95306a
my $COM = $0;
Packit 95306a
$COM =~ s/^.*\///;
Packit 95306a
Packit 95306a
$usage=
Packit 95306a
  "usage: $COM OPTIONS
Packit 95306a
      -h/--help       : Print help.
Packit 95306a
Packit 95306a
This script will generate the pod files for each of the Date::Manip
Packit 95306a
language modules.
Packit 95306a
";
Packit 95306a
Packit 95306a
###############################################################################
Packit 95306a
# PARSE ARGUMENTS
Packit 95306a
###############################################################################
Packit 95306a
Packit 95306a
while ($_ = shift) {
Packit 95306a
   (print $usage),   exit  if ($_ eq "-h"   ||  $_ eq "--help");
Packit 95306a
}
Packit 95306a
Packit 95306a
############################################################################
Packit 95306a
# MAIN PROGRAM
Packit 95306a
############################################################################
Packit 95306a
Packit 95306a
no warnings;
Packit 95306a
my @mod = values %Date::Manip::Lang::index::Lang;
Packit 95306a
use warnings;
Packit 95306a
Packit 95306a
my %mod = map { $_,1 } @mod;
Packit 95306a
@mod    = sort keys %mod;
Packit 95306a
Packit 95306a
foreach my $mod (@mod) {
Packit 95306a
   write_pod($mod);
Packit 95306a
}
Packit 95306a
Packit 95306a
############################################################################
Packit 95306a
############################################################################
Packit 95306a
Packit 95306a
no strict 'refs';
Packit 95306a
sub write_pod {
Packit 95306a
   my($mod) = @_;
Packit 95306a
Packit 95306a
   my $undef = "   Not defined in this language\n";
Packit 95306a
   eval "require Date::Manip::Lang::${mod}";
Packit 95306a
   my $lang  = ${ "Date::Manip::Lang::${mod}::Language" };
Packit 95306a
   my $name  = ${ "Date::Manip::Lang::${mod}::LangName" };
Packit 95306a
   my $year0 = ${ "Date::Manip::Lang::${mod}::YearAdded" };
Packit 95306a
Packit 95306a
   my $out  = new IO::File;
Packit 95306a
   $out->open("> ${langdir}/${mod}.pod");
Packit 95306a
   binmode $out, ":encoding(UTF-8)";
Packit 95306a
Packit 95306a
   my %words;
Packit 95306a
Packit 95306a
   my %lists = ('ampm'       => 2,
Packit 95306a
                'day_name'   => 7,
Packit 95306a
                'day_abb'    => 7,
Packit 95306a
                'day_char'   => 7,
Packit 95306a
                'month_name' => 12,
Packit 95306a
                'month_abb'  => 12,
Packit 95306a
                'fields'     => 7,
Packit 95306a
                'nextprev'   => 2,
Packit 95306a
                'nth'        => 53,
Packit 95306a
                'mode'       => 2,
Packit 95306a
                'when'       => 2,
Packit 95306a
               );
Packit 95306a
   while (my($key,$num) = each %lists) {
Packit 95306a
      if (exists $$lang{$key}) {
Packit 95306a
         foreach (my $i=0; $i < $num; $i++) {
Packit 95306a
            $words{$key}[$i] = '';
Packit 95306a
            if (defined ($$lang{$key}[$i])) {
Packit 95306a
               my @tmp = @{ $$lang{$key}[$i] };
Packit 95306a
               foreach my $tmp (@tmp) {
Packit 95306a
                  $words{$key}[$i] .= "   $tmp\n"  if ($tmp);
Packit 95306a
               }
Packit 95306a
            } else {
Packit 95306a
               print "Undefined: $mod,$key\n";
Packit 95306a
            }
Packit 95306a
            $words{$key}[$i] = $undef  if (! $words{$key}[$i]);
Packit 95306a
         }
Packit 95306a
      } else {
Packit 95306a
         foreach (my $i=0; $i < $num; $i++) {
Packit 95306a
            $words{$key}[$i] = $undef;
Packit 95306a
         }
Packit 95306a
      }
Packit 95306a
   }
Packit 95306a
Packit 95306a
   my @words = qw(at each last of on);
Packit 95306a
Packit 95306a
   foreach my $set (@words) {
Packit 95306a
      $words{$set} = '';
Packit 95306a
      if (exists $$lang{$set}) {
Packit 95306a
         my @tmp = @{ $$lang{$set} };
Packit 95306a
         foreach my $tmp (@tmp) {
Packit 95306a
            $words{$set} .= "   $tmp\n"  if ($tmp);
Packit 95306a
         }
Packit 95306a
      }
Packit 95306a
      $words{$set} = $undef  if (! $words{$set});
Packit 95306a
   }
Packit 95306a
Packit 95306a
   @words = qw(offset_date offset_time times);
Packit 95306a
Packit 95306a
   foreach my $set (@words) {
Packit 95306a
      $words{$set} = '';
Packit 95306a
      if (exists $$lang{$set}) {
Packit 95306a
         foreach my $key (sort keys %{ $$lang{$set} }) {
Packit 95306a
            my $val = $$lang{$set}{$key};
Packit 95306a
            $words{$set} .= "   $key" . " "x(20-length($key)) . " $val\n";
Packit 95306a
         }
Packit 95306a
      }
Packit 95306a
      $words{$set} = $undef  if (! $words{$set});
Packit 95306a
   }
Packit 95306a
Packit 95306a
   if (exists $$lang{"sephm"}) {
Packit 95306a
      $words{"seps"} = '';
Packit 95306a
      my @hm = @{ $$lang{"sephm"} };
Packit 95306a
      my @ms = @{ $$lang{"sepms"} };
Packit 95306a
      for (my $i=0; $i <= $#hm; $i++) {
Packit 95306a
         $words{'seps'} .= "   $hm[$i]  $ms[$i]\n";
Packit 95306a
      }
Packit 95306a
   } else {
Packit 95306a
      $words{'seps'} = $undef;
Packit 95306a
   }
Packit 95306a
Packit 95306a
   if (exists $$lang{"sepfr"}) {
Packit 95306a
      $words{"sepfr"} = $$lang{"sepfr"};
Packit 95306a
   } else {
Packit 95306a
      $words{'sepfr'} = $undef;
Packit 95306a
   }
Packit 95306a
Packit 95306a
   # Try to hide pod so it doesn't get indexed
Packit 95306a
   my $e = '=';
Packit 95306a
Packit 95306a
   print $out <<"EOF";
Packit 95306a
# Copyright (c) $year0-$curry Sullivan Beck. All rights reserved.
Packit 95306a
# This program is free software; you can redistribute it and/or modify it
Packit 95306a
# under the same terms as Perl itself.
Packit 95306a
Packit 95306a
########################################################################
Packit 95306a
########################################################################
Packit 95306a
Packit 95306a
${e}pod
Packit 95306a
Packit 95306a
${e}encoding utf-8
Packit 95306a
Packit 95306a
${e}head1 NAME
Packit 95306a
Packit 95306a
Date::Manip::Lang::${mod} - ${name} language support.
Packit 95306a
Packit 95306a
${e}head1 SYNOPSIS
Packit 95306a
Packit 95306a
This module contains a list of words and expressions supporting
Packit 95306a
the language. It is not intended to be used directly (other
Packit 95306a
Date::Manip modules will load it as needed).
Packit 95306a
Packit 95306a
${e}head1 LANGUAGE EXPRESSIONS
Packit 95306a
Packit 95306a
The following is a list of all language words and expressions used
Packit 95306a
to write times and/or dates.
Packit 95306a
Packit 95306a
All strings are case insensitive.
Packit 95306a
Packit 95306a
${e}over 4
Packit 95306a
Packit 95306a
${e}item B<Month names and abbreviations>
Packit 95306a
Packit 95306a
When writing out the name of the month, several different variations may
Packit 95306a
exist including full names and abbreviations.
Packit 95306a
Packit 95306a
The following month names may be used:
Packit 95306a
Packit 95306a
$words{month_name}[0]
Packit 95306a
$words{month_name}[1]
Packit 95306a
$words{month_name}[2]
Packit 95306a
$words{month_name}[3]
Packit 95306a
$words{month_name}[4]
Packit 95306a
$words{month_name}[5]
Packit 95306a
$words{month_name}[6]
Packit 95306a
$words{month_name}[7]
Packit 95306a
$words{month_name}[8]
Packit 95306a
$words{month_name}[9]
Packit 95306a
$words{month_name}[10]
Packit 95306a
$words{month_name}[11]
Packit 95306a
Packit 95306a
The following abbreviations may be used:
Packit 95306a
Packit 95306a
$words{month_abb}[0]
Packit 95306a
$words{month_abb}[1]
Packit 95306a
$words{month_abb}[2]
Packit 95306a
$words{month_abb}[3]
Packit 95306a
$words{month_abb}[4]
Packit 95306a
$words{month_abb}[5]
Packit 95306a
$words{month_abb}[6]
Packit 95306a
$words{month_abb}[7]
Packit 95306a
$words{month_abb}[8]
Packit 95306a
$words{month_abb}[9]
Packit 95306a
$words{month_abb}[10]
Packit 95306a
$words{month_abb}[11]
Packit 95306a
Packit 95306a
${e}item B<Day names and abbreviations>
Packit 95306a
Packit 95306a
When writing out the name of the day, several different variations may
Packit 95306a
exist including full names and abbreviations.
Packit 95306a
Packit 95306a
The following day names may be used:
Packit 95306a
Packit 95306a
$words{day_name}[0]
Packit 95306a
$words{day_name}[1]
Packit 95306a
$words{day_name}[2]
Packit 95306a
$words{day_name}[3]
Packit 95306a
$words{day_name}[4]
Packit 95306a
$words{day_name}[5]
Packit 95306a
$words{day_name}[6]
Packit 95306a
Packit 95306a
The following abbreviations may be used:
Packit 95306a
Packit 95306a
$words{day_abb}[0]
Packit 95306a
$words{day_abb}[1]
Packit 95306a
$words{day_abb}[2]
Packit 95306a
$words{day_abb}[3]
Packit 95306a
$words{day_abb}[4]
Packit 95306a
$words{day_abb}[5]
Packit 95306a
$words{day_abb}[6]
Packit 95306a
Packit 95306a
The following short (1-2 characters) abbreviations may be used:
Packit 95306a
Packit 95306a
$words{day_char}[0]
Packit 95306a
$words{day_char}[1]
Packit 95306a
$words{day_char}[2]
Packit 95306a
$words{day_char}[3]
Packit 95306a
$words{day_char}[4]
Packit 95306a
$words{day_char}[5]
Packit 95306a
$words{day_char}[6]
Packit 95306a
Packit 95306a
${e}item B<Delta field names>
Packit 95306a
Packit 95306a
These are the names (and abbreviations) for the fields in a delta.  There are
Packit 95306a
7 fields: years, months, weeks, days, hours, minutes, seconds.
Packit 95306a
Packit 95306a
The names and abbreviations for these fields are:
Packit 95306a
Packit 95306a
$words{fields}[0]
Packit 95306a
$words{fields}[1]
Packit 95306a
$words{fields}[2]
Packit 95306a
$words{fields}[3]
Packit 95306a
$words{fields}[4]
Packit 95306a
$words{fields}[5]
Packit 95306a
$words{fields}[6]
Packit 95306a
Packit 95306a
${e}item B<Morning/afternoon times>
Packit 95306a
Packit 95306a
This is a list of expressions use to designate morning or afternoon time
Packit 95306a
when a time is entered as a 12-hour time rather than a 24-hour time.
Packit 95306a
For example, in English, the time "17:00" could be specified as "5:00 PM".
Packit 95306a
Packit 95306a
Morning and afternoon time may be designated by the following sets of
Packit 95306a
words:
Packit 95306a
Packit 95306a
$words{ampm}[0]
Packit 95306a
$words{ampm}[1]
Packit 95306a
Packit 95306a
${e}item B<Each or every>
Packit 95306a
Packit 95306a
There are a list of words that specify every occurrence of something.  These
Packit 95306a
are used in the following phrases:
Packit 95306a
Packit 95306a
   EACH Monday
Packit 95306a
   EVERY Monday
Packit 95306a
   EVERY month
Packit 95306a
Packit 95306a
The following words may be used:
Packit 95306a
Packit 95306a
$words{each}
Packit 95306a
Packit 95306a
${e}item B<Next/Previous/Last occurrence>
Packit 95306a
Packit 95306a
There are a list of words that may be used to specify the next,
Packit 95306a
previous, or last occurrence of something.  These words could be used
Packit 95306a
in the following phrases:
Packit 95306a
Packit 95306a
   NEXT week
Packit 95306a
Packit 95306a
   LAST Tuesday
Packit 95306a
   PREVIOUS Tuesday
Packit 95306a
Packit 95306a
   LAST day of the month
Packit 95306a
Packit 95306a
The following words may be used:
Packit 95306a
Packit 95306a
Next occurrence:
Packit 95306a
Packit 95306a
$words{nextprev}[0]
Packit 95306a
Packit 95306a
Previous occurrence:
Packit 95306a
Packit 95306a
$words{nextprev}[1]
Packit 95306a
Packit 95306a
Last occurrence:
Packit 95306a
Packit 95306a
$words{last}
Packit 95306a
Packit 95306a
${e}item B<Delta words for going forward/backward in time>
Packit 95306a
Packit 95306a
When parsing deltas, there are words that may be used to specify
Packit 95306a
the the delta will refer to a time in the future or to a time in
Packit 95306a
the past (relative to some date).  In English, for example, you
Packit 95306a
might say:
Packit 95306a
Packit 95306a
   IN 5 days
Packit 95306a
   5 days AGO
Packit 95306a
Packit 95306a
The following words may be used to specify deltas that refer to
Packit 95306a
dates in the past or future respectively:
Packit 95306a
Packit 95306a
$words{when}[0]
Packit 95306a
$words{when}[1]
Packit 95306a
Packit 95306a
${e}item B<Business mode>
Packit 95306a
Packit 95306a
This contains two lists of words which can be used to specify a standard
Packit 95306a
(i.e. non-business) delta or a business delta.
Packit 95306a
Packit 95306a
Previously, it was used to tell whether the delta was approximate or exact,
Packit 95306a
but now this list is not used except to force the delta to be standard.
Packit 95306a
Packit 95306a
The following words may be used:
Packit 95306a
Packit 95306a
$words{mode}[0]
Packit 95306a
Packit 95306a
The following words may be used to specify a business delta:
Packit 95306a
Packit 95306a
$words{mode}[1]
Packit 95306a
Packit 95306a
${e}item B<Numbers>
Packit 95306a
Packit 95306a
Numbers may be spelled out in a variety of ways.  The following sets correspond
Packit 95306a
to the numbers from 1 to 53:
Packit 95306a
Packit 95306a
$words{nth}[0]
Packit 95306a
$words{nth}[1]
Packit 95306a
$words{nth}[2]
Packit 95306a
$words{nth}[3]
Packit 95306a
$words{nth}[4]
Packit 95306a
$words{nth}[5]
Packit 95306a
$words{nth}[6]
Packit 95306a
$words{nth}[7]
Packit 95306a
$words{nth}[8]
Packit 95306a
$words{nth}[9]
Packit 95306a
Packit 95306a
$words{nth}[10]
Packit 95306a
$words{nth}[11]
Packit 95306a
$words{nth}[12]
Packit 95306a
$words{nth}[13]
Packit 95306a
$words{nth}[14]
Packit 95306a
$words{nth}[15]
Packit 95306a
$words{nth}[16]
Packit 95306a
$words{nth}[17]
Packit 95306a
$words{nth}[18]
Packit 95306a
$words{nth}[19]
Packit 95306a
Packit 95306a
$words{nth}[20]
Packit 95306a
$words{nth}[21]
Packit 95306a
$words{nth}[22]
Packit 95306a
$words{nth}[23]
Packit 95306a
$words{nth}[24]
Packit 95306a
$words{nth}[25]
Packit 95306a
$words{nth}[26]
Packit 95306a
$words{nth}[27]
Packit 95306a
$words{nth}[28]
Packit 95306a
$words{nth}[29]
Packit 95306a
Packit 95306a
$words{nth}[30]
Packit 95306a
$words{nth}[31]
Packit 95306a
$words{nth}[32]
Packit 95306a
$words{nth}[33]
Packit 95306a
$words{nth}[34]
Packit 95306a
$words{nth}[35]
Packit 95306a
$words{nth}[36]
Packit 95306a
$words{nth}[37]
Packit 95306a
$words{nth}[38]
Packit 95306a
$words{nth}[39]
Packit 95306a
Packit 95306a
$words{nth}[40]
Packit 95306a
$words{nth}[41]
Packit 95306a
$words{nth}[42]
Packit 95306a
$words{nth}[43]
Packit 95306a
$words{nth}[44]
Packit 95306a
$words{nth}[45]
Packit 95306a
$words{nth}[46]
Packit 95306a
$words{nth}[47]
Packit 95306a
$words{nth}[48]
Packit 95306a
$words{nth}[49]
Packit 95306a
Packit 95306a
$words{nth}[50]
Packit 95306a
$words{nth}[51]
Packit 95306a
$words{nth}[52]
Packit 95306a
Packit 95306a
${e}item B<Ignored words>
Packit 95306a
Packit 95306a
In writing out dates in common forms, there are a number of words
Packit 95306a
that are typically not important.
Packit 95306a
Packit 95306a
There is frequently a word that appears in a phrase to designate
Packit 95306a
that a time is going to be specified next.  In English, you would
Packit 95306a
use the word AT in the example:
Packit 95306a
Packit 95306a
   December 3 at 12:00
Packit 95306a
Packit 95306a
The following words may be used:
Packit 95306a
Packit 95306a
$words{at}
Packit 95306a
Packit 95306a
Another word is used to designate one member of a set.  In English,
Packit 95306a
you would use the words IN or OF:
Packit 95306a
Packit 95306a
   1st day OF December
Packit 95306a
   1st day IN December
Packit 95306a
Packit 95306a
The following words may be used:
Packit 95306a
Packit 95306a
$words{of}
Packit 95306a
Packit 95306a
Another word is use to specify that something is on a certain date.  In
Packit 95306a
English, you would use ON:
Packit 95306a
Packit 95306a
   ON July 5th
Packit 95306a
Packit 95306a
The following words may be used:
Packit 95306a
Packit 95306a
$words{on}
Packit 95306a
Packit 95306a
${e}item B<Words that set the date, time, or both>
Packit 95306a
Packit 95306a
There are some words that can be used to specify a date, a
Packit 95306a
time, or both relative to now.
Packit 95306a
Packit 95306a
Words that set the date are similar to the English words 'yesterday'
Packit 95306a
or 'tomorrow'.  These are specified as a delta which is added to the
Packit 95306a
current time to get a date.  The time is NOT set however, so the delta
Packit 95306a
is only partially used (it should only include year, month, week, and
Packit 95306a
day fields).
Packit 95306a
Packit 95306a
The following words may be used:
Packit 95306a
Packit 95306a
$words{offset_date}
Packit 95306a
Packit 95306a
Words that set only the time of day are similar to the English words
Packit 95306a
'noon' or 'midnight'.
Packit 95306a
Packit 95306a
The following words may be used:
Packit 95306a
Packit 95306a
$words{times}
Packit 95306a
Packit 95306a
Words that set the entire time and date (relative to the current
Packit 95306a
time and date) are also available.
Packit 95306a
Packit 95306a
In English, the word 'now' is one of these.
Packit 95306a
Packit 95306a
The following words may be used:
Packit 95306a
Packit 95306a
$words{offset_time}
Packit 95306a
Packit 95306a
${e}item B<Hour/Minute/Second separators>
Packit 95306a
Packit 95306a
When specifying the time of day, the most common separator is a colon (:)
Packit 95306a
which can be used for both separators.
Packit 95306a
Packit 95306a
Some languages use different pairs.  For example, French allows you to
Packit 95306a
specify the time as 13h30:20, so it would use the following pairs:
Packit 95306a
Packit 95306a
   : :
Packit 95306a
   h :
Packit 95306a
Packit 95306a
The first column is the hour-minute separator and the second column is
Packit 95306a
the minute-second separator.  Both are perl regular expressions.  When
Packit 95306a
creating a new translation, be aware that regular expressions with utf-8
Packit 95306a
characters may be tricky.  For example, don't include the expression '[x]'
Packit 95306a
where 'x' is a utf-8 character.
Packit 95306a
Packit 95306a
A pair of colons is ALWAY allowed for all languages.  If a language allows
Packit 95306a
additional pairs, they are listed here:
Packit 95306a
Packit 95306a
$words{seps}
Packit 95306a
Packit 95306a
${e}item B<Fractional second separator>
Packit 95306a
Packit 95306a
When specifying fractional seconds, the most common way is to use a
Packit 95306a
decimal point (.).  Some languages may specify a different separator
Packit 95306a
that might be used.  If this is done, it is a regular expression.
Packit 95306a
Packit 95306a
The decimal point is ALWAYS allowed for all languages.  If a language allows
Packit 95306a
another separator, it is listed here:
Packit 95306a
Packit 95306a
$words{sepfr}
Packit 95306a
Packit 95306a
${e}back
Packit 95306a
Packit 95306a
${e}head1 KNOWN BUGS
Packit 95306a
Packit 95306a
None known.
Packit 95306a
Packit 95306a
${e}head1 BUGS AND QUESTIONS
Packit 95306a
Packit 95306a
Please refer to the L<Date::Manip::Problems> documentation for
Packit 95306a
information on submitting bug reports or questions to the author.
Packit 95306a
Packit 95306a
${e}head1 SEE ALSO
Packit 95306a
Packit 95306a
L<Date::Manip>       - main module documentation
Packit 95306a
Packit 95306a
${e}head1 LICENSE
Packit 95306a
Packit 95306a
This script is free software; you can redistribute it and/or
Packit 95306a
modify it under the same terms as Perl itself.
Packit 95306a
Packit 95306a
${e}head1 AUTHOR
Packit 95306a
Packit 95306a
Sullivan Beck (sbeck\@cpan.org)
Packit 95306a
Packit 95306a
${e}cut
Packit 95306a
EOF
Packit 95306a
Packit 95306a
   $out->close();
Packit 95306a
}
Packit 95306a
use strict 'refs';
Packit 95306a
Packit 95306a
# Local Variables:
Packit 95306a
# mode: cperl
Packit 95306a
# indent-tabs-mode: nil
Packit 95306a
# cperl-indent-level: 3
Packit 95306a
# cperl-continued-statement-offset: 2
Packit 95306a
# cperl-continued-brace-offset: 0
Packit 95306a
# cperl-brace-offset: 0
Packit 95306a
# cperl-brace-imaginary-offset: 0
Packit 95306a
# cperl-label-offset: 0
Packit 95306a
# End: