AI::MicroStructure::Locale - Base class for multilingual structures


    package AI::MicroStructure::digits;
    use AI::MicroStructure::Locale;
    our @ISA = ( AI::MicroStructure::Locale );

    =head1 NAME

    AI::MicroStructure::digits - The numbers structure

    =head1 DESCRIPTION

    You can count on this module. Almost.


    # default
    # names en
    zero one two three four five six seven eight nine
    # names fr
    zero un deux trois quatre cinq six sept huit neuf
    # names it
    zero uno due tre quattro cinque sei sette otto nove
    # names yi
    nul eyn tsvey dray fir finf zeks zibn akht nayn


AI::MicroStructure::Locale is the base class for all structures that are meant to return a random excerpt from a predefined list that depends on the language.

The language is selected at construction time from:

  1. the given lang or category parameter,

  2. the current locale, as given by the environment variables LANGUAGE, LANG or (under Win32) Win32::Locale.

  3. the default language for the selected structure.

The language codes should conform to the RFC 3066 and ISO 639 standard.


AI::MicroStructure::Locale offers several methods, so that the subclasses are easy to write (see full example in SYNOPSIS):

new( lang => $lang )
new( category => $lang )

The constructor of a single instance. An instance will not repeat items until the list is exhausted.

The lang or category parameter(both are synonymous) should be expressed as a locale category. If none of those parameters is given AI::MicroStructure::Locale will try to find the user locale (with the help of environment variables LANGUAGE, LANG and the module Win32::Locale).

POSIX locales are defined as language[_territory][.codeset][@modifier]. If the specific territory is not supported, AI::MicroStructure::Locale will use the language, and if the language isn't supported either, the default is used.


init() must be called when the subclass is loaded, so as to read the __DATA__ section and fully initialise it.

name( $count )

Return $count names (default: 1).

Using 0 will return the whole list in list context, and the size of the list in scalar context (according to the lang parameter passed to the constructor).


Return the selected language for this instance.


Return the languages supported by the structure.


Return the structure name.


Codes for the Representation of Names of Languages, at

RFC 3066, Tags for the Identification of Languages, at

AI::MicroStructure, Acme::MetaSyntactic::MultiList.


Philippe 'BooK' Bruhat, <>


Copyright 2005-2006 Philippe 'BooK' Bruhat, All Rights Reserved.

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