NAME
DateTime::Language - base class for DateTime.pm-related language localization
SYNOPSIS
package DateTime::Language::Gibberish;
use base qw(DateTime::Language);
DESCRIPTION
This class provides most of the methods needed to implement language localization for DateTime.pm. A subclass of this language simply provides a set of data structures containing things like day and months names.
This module is a factory for language subclasses, and can load a class either based on the language portion of its name, such as "English", or based on its ISO code, such as "en" or "eng".
USAGE
This module provides the following methods:
new( language => $language )
This method loads the requested language and returns an object of the appropriate class. The "language" parameter may be the name of the language subclass to be used, such as "English", as returned by the
languages()
method. It can also be an ISO 639 two-letter language code. The language code may include an ISO 3166 two-letter country after a dash, so things like "en" or "en-us" are both legal. If a country code is given, then the most specific match is used. For example, if "en-au" (English, Australian) is given, then the nearest match will be "en", which will be used instead.load( $language )
This tells the module to load the specified language without creating an object. The language given can be anything accepted by the
new()
method.languages
Returns a list of supported language names.
iso_codes
Returns a list of supported ISO language codes. See the
new()
method documentation for details.
SUBCLASSING
People who want to add support for new languages may be interested in subclassing this module.
The simplest way to do this is to simply declare your new module, let's call it DateTime::Language::Inhumi
, a subclass of DateTime::Language
, and to define a set of global variables in your namespace.
These globals are:
@DayNames
The names of each day, starting with Monday.
@DayAbbreviations
Abbreviated names for each day.
@MonthNames
The names of each month, starting with January.
@MonthAbbreviations
Abbreviated names for each month.
@AMPM
The terms used for AM and PM in the language you are implementing.
The DateTime::Language
module implements methods that use these globals as needed. If you need to implement more complex algorithms, you can override the following methods:
month_names
Returns a list of month names.
month_name( $dt )
Given a
DateTime
object, this method should return the correct month name.month_abbreviations
Returns a list of month abbreviations.
month_abbreviation( $dt )
Given a
DateTime
object, this method should return the correct month abbreviation.day_names
Returns a list of day names.
day_name( $dt )
Given a
DateTime
object, this method should return the correct day name.day_abbreviations
Returns a list of day abbreviations.
day_abbreviation( $dt )
Given a
DateTime
object, this method should return the correct day abbreviation.am_pm_list
Returns a list of the AM/PM texts. First item should be the AM, the second should be the PM.
am_pm( $dt )
Given a
DateTime
object, returns the correct AM or PM abbreviation.
SUPPORT
Support for this module is provided via the datetime@perl.org email list. See http://lists.perl.org/ for more details.
AUTHOR
Dave Rolsky <autarch@urth.org>
However, please see the CREDITS file for more details on who I really stole all the code from.
COPYRIGHT
Copyright (c) 2003 David Rolsky. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Portions of the code in this distribution are derived from other works. Please see the CREDITS file for more details.
The full text of the license can be found in the LICENSE file included with this module.
SEE ALSO
datetime@perl.org mailing list
http://datetime.perl.org/