Right, what if the requirements for adding locales are as follows:

############################################################################

If you need to add a custom locale that cannot inherit from an existing one:

1) Inherit from DateTime::Locale::Base - you'll need to implement
   the following methods:

  locale_id
  month_names
  month_abbreviations
  day_names
  day_abbreviations
  am_pm_list
  eras                               # Someday soon...
  date_formats
  time_formats
  date_time_format_pattern_order

It's highly recommended that your locale id uses the following format:

  LanguageId[_TerritoryId[_VariantId]]

  LanguageId  = Lower case ISO-639 standard language code
  TerritoryId = Upper case ISO-3166 standard country code
  VariantId   = Upper case custom string

Choose locale id's carefully - there's no warning if you register a locale
that already exists.

As well as the supplied DateTime::Locale ids, the following are also
reserved:

  c
  posix
  Afar
  Amharic
  Austrian
  Brazilian
  Czech
  Danish
  Dutch
  English
  French
  Gedeo
  German
  Italian
  Norwegian
  Oromo
  Portugese
  Sidama
  Somali
  Spanish
  Swedish
  Tigre
  TigrinyaEritrean
  TigrinyaEthiopian

2) Register your locale:

  a) If you're using the DateTime::Locale namespace:

     DateTime::Locale->register_locale(de_DE_RIDAS1 =>
                                      'deu_DE_RIDAS1',
                                      'ger_DE_RIDAS1',
                                      'German_Germany_Ridas custom 1', 
                                      'Deutsch_Deutschland_Ridas custom 1');

     In this case, the class name is DateTime::Locale::de_DE_RIDAS1, and
     can be instantiated with any of the following:

     DateTime::Locale->load("de_DE_RIDAS1");
     DateTime::Locale->load("deu_DE_RIDAS1");
     DateTime::Locale->load("ger_DE_RIDAS1");
     DateTime::Locale->load("German_Germany_Ridas custom 1");

  b) If you're using a custom namespace, supply the full Class name
     in addition - for Ridas::Locales::GermanGermanyOne.pm :

     DateTime::Locale->register_locale(de_DE_RIDAS1 =>
                                      'deu_DE_RIDAS1',
                                      'ger_DE_RIDAS1',
                                      'German_Germany_Ridas custom 1', 
                                      'Deutsch_Deutschland_Ridas custom 1',
                                      'Ridas::Locales::GermanGermanyOne');

     In this case, as in a) above, the locale can be instantiated with any
     of the following:

     DateTime::Locale->load("de_DE_RIDAS1");
     DateTime::Locale->load("deu_DE_RIDAS1");
     DateTime::Locale->load("ger_DE_RIDAS1");
     DateTime::Locale->load("German_Germany_Ridas custom 1");

If you register a locale that already exists, your newly registered locale 
takes preference for the rest of that session.

3) [Optional] Make your registrations permanent

Create DateTime::Locale::CustomInstall.pm, and register your locales in the
import() method. These locales will be automatically registered whenever
DateTime::Locale is used:

  package DateTime::Locale::CustomInstall;

  use DateTime::Locale;

  sub import
  {
    DateTime::Locale->register_locale( [
      [
        'de_DE_RIDAS1',
        'deu_DE_RIDAS1',
        'ger_DE_RIDAS1',
        'German_Germany_Ridas custom 1', 
        'Deutsch_Deutschland_Ridas custom 1',
        'Ridas::Locales::GermanGermanyOne',
      ],
      [
        'de_DE_RIDAS2',
        'deu_DE_RIDAS2',
        'ger_DE_RIDAS2',
        'German_Germany_Ridas custom 2', 
        'Deutsch_Deutschland_Ridas custom 2',
        'Ridas::Locales::GermanGermanyTwo',
      ],
      [
        'de_DE_RIDAS3',
        'deu_DE_RIDAS3',
        'ger_DE_RIDAS3',
        'German_Germany_Ridas custom 3', 
        'Deutsch_Deutschland_Ridas custom 3',
        'Ridas::Locales::GermanGermanyThree',
      ],
    ] );
  }

  1;

That's it.

So, any better? I should be able to implement the code needed for this quite
easily.

Cheers,
Rich
-- 
Richard Evans
[EMAIL PROTECTED]

Reply via email to