=head1 NAME

DateTime::Format::Natural::Lang::Authoring - Authoring the translation metadata

=head1 DESCRIPTION

Whenever a language is provided via the C<lang> parameter to 
C<DateTime::Format::Natural's> C<parse_datetime>, C<parse_datetime>
will subsequently use the I<translation metadata> found within, for example,
C<DateTime::Format::Natural::Lang::EN>, if we chosen the english language.

=head1 STRUCTURE

The layout of a translation class will be explained by examining the
class providing the english metadata, C<DateTime::Format::Natural::Lang::EN>:

The header should look as following:

 package DateTime::Format::Natural::Lang::EN;

 use strict;
 use warnings;

 our $VERSION = '0.5';

 our ($AUTOLOAD, %data_weekdays, %data_months);

 sub __new {
     my $class = shift;

     my $obj = {};
     $obj->{weekdays} = \%data_weekdays;
     $obj->{months}   = \%data_months;

     return bless $obj, $class || ref($class);
 }

 AUTOLOAD {
     my ($self, $exp) = @_;

     my $sub = $AUTOLOAD;
     $sub =~ s/^.*:://;

     if (substr($sub, 0, 2) eq '__') {
         $sub =~ s/^__//;
         no strict 'refs';
         return ${$sub}{$exp};
     }
 }

Substitute C<EN> with the appropriate language code. Use C<$VERSION = '0.1'>
if it's a initial release, otherwise replace it with your custom version number.

 {
     my $i = 1;

     %data_weekdays = map { $_ => $i++ } qw(Monday Tuesday Wednesday Thursday
                                            Friday Saturday Sunday);
     $i = 1;

     %data_months = map { $_ => $i++ } qw(January February March April
                                          May June July August September
                                          October November December);
 }

Replace C<%data_weekdays> with the weekdays in your language chosen.
The same with C<%data_months> concerning months.

 our %main = ('second'         => qr/^second$/i,
              'ago'            => qr/^ago$/i,
              'now'            => qr/^now$/i,
              'daytime'        => [qr/^(?:morning|afternoon|evening)$/i],
              'months'         => [qw(in this)],
              'at_intro'       => qr/^(\d{1,2})(?!\d|st|nd|rd|th)(\:\d{2})?(am|pm)?|(noon|midnight)$/i,
              'at_matches'     => [qw(day in month)],
              'number_intro'   => qr/^(\d{1,2})(?:st|nd|rd|th)? ?$/i,
              'number_matches' => [qw(day week month in)],
              'weekdays'       => qr/^(?:this|next|last)$/i,
              'this_in'        => qr/^(?:this|in)$/i,
              'next'           => qr/^next$/i,
              'last'           => qr/^last$/i,
              );

This is the hash with contains the regular expressions for the C<parse_datetime()>
routine in C<DateTime::Format::Natural>.

 %ago = ('hour'  => qr/^hour(?:s)?$/i,
         'day'   => qr/^day(?:s)?$/i,
         'week'  => qr/^week(?:s)?$/i,
         'month' => qr/^month(?:s)?$/i,
         'year'  => qr/^year(?:s)?$/i,
        );

C<%ago> contains the regular expressions for strings such as 
I<1 hour ago>, I<10 weeks ago> & I<3 years ago>.

 %now = ('day'    => qr/^day(?:s)?$/i,
         'week'   => qr/^week(?:s)?$/i,
         'month'  => qr/^month(?:s)?$/i,
         'year'   => qr/^year(?:s)?$/i,
         'before' => qr/^before$/i,
         'from'   => qr/^from$/i,
         );

C<%now> contains the regular expressions for strings such as
I<1 day before now>, I<4 months from now> & I<3 years from now>.

 %daytime = ('tokens'     => [ qr/\d/, qr/^in$/i, qr/^the$/i ],
             'morning'    => qr/^morning$/i,
             'afternoon'  => qr/^afternoon$/i,
             );

C<%daytime> contains the regular expressions for strings such as
I<7 in the morning> & I<4 in the afternoon>.

 %months = ('number' => qr/^(\d{1,2})(?:st|nd|rd|th)? ?$/i);

C<%months> contains the regular expression for matching
days within a month.

 %number = ('month'  => qr/month(?:s)/i,
            'hour'   => qr/hour(?:s)/i,
            'before' => qr/before/i,
            'after'  => qr/after/i,
           );

C<%number> contains the regular expressions for strings such as
I<7 hours before> & I<1 month after>.

 %at = ('noon'     => qr/noon/i,
        'midnight' => qr/midnight/i,
       );

C<%at> contains the regular expressions for strings such as
I<noon> & I<midnight>.

 %this_in = ('hour'   => qr/hour(?:s)/i,
             'week'   => qr/^week$/i,
             'number' => qr/^(\d{1,2})(?:st|nd|rd|th)?$/i,
            );

C<%this_in> contains the regular expressions for strings such as
I<in 1 hours> & I<this week>.

 %next = ('week'   => qr/^week$/i,
          'day'    => qr/^day$/i,
          'month'  => qr/^month$/i,
          'year'   => qr/^year$/i,
          'number' => qr/^(\d{1,2})(?:st|nd|rd|th)$/,
         );

C<%next> contains the regular expressions for strings such as
I<next week>, I<next day>, I<next month> & I<next year>.

 %last = ('week'   => qr/^week$/i,
          'day'    => qr/^day$/i,
          'month'  => qr/^month$/i,
          'year'   => qr/^year$/i,
          'number' => qr/^(\d{1,2})(?:st|nd|rd|th)$/,
          );

C<%last> contains the regular expressions for strings such as
I<last week>, I<last day>, I<last month> & I<last year>.

 %day = ('init'         => qr/^(?:today|yesterday|tomorrow)$/i,
         'yesterday'    => qr/yesterday/i,
         'tomorrow'     => qr/tomorrow/i,
         'noonmidnight' => qr/^noon|midnight$/i,
         );

C<%day> contains the regular expressions for strings such as
I<yesterday>, I<tomorrow>, I<noon> & I<midnight>.

 %setyearday = ('day' => qr/^day$/i,
                'ext' => qr/^(\d{1,3})(?:st|nd|rd|th)$/,
               );

C<%setyearday> sets the year day.

 1;

Every package has to return a true value.

=head1 SEE ALSO

L<DateTime>, L<Date::Calc>, L<http://datetime.perl.org/>

=head1 AUTHOR

Steven Schubiger <schubiger@cpan.org>

=head1 LICENSE

This program is free software; you may redistribute it and/or
modify it under the same terms as Perl itself.

See L<http://www.perl.com/perl/misc/Artistic.html>

=cut
