Home | Wiki | OI 1.x Docs | OI 2.x Docs OI logo

NAME

OpenInteract2::I18N::Initializer - Read in localization messages and generate maketext classes

SYNOPSIS

 my $init = OpenInteract2::I18N::Initializer->new;
 $init->add_message_files( @some_message_files );
 my $gen_classes = $init->run;
 print "I generated the following classes: ", join( @{ $gen_classes } ), "\n";

DESCRIPTION

This class is generally only used by the OI2 startup procedure, which scans all packages for message files and adds them to this initializer, then runs it. The purpose of this class is to generate subclasses for use with Locale::Maketext. Those classes are fairly simple and generally only contain a package variable %Lexicon which L::M uses to work its magic.

CLASS METHODS

new()

Return a new object. Any parameters are ignored.

OBJECT METHODS

add_message_files( @fully_qualified_files )

Adds all files in @fully_qualified_files to its internal list of files to process. It does not process these files until run().

locate_global_message_files()

Finds all message files (that is, files ending in '.msg') in the global message directory as reported by the OpenInteract2::Context and adds them to the initializer. Normally only called by OpenInteract2::Setup.

Returns: arrayref of fully-qualified files added

run()

Reads messages from all files added via add_message_files() and generates language-specific subclasses for all messages found. (Once the subclasses are created the system does not know from where the messages come since all messages are flattened into a per-language data structure.) So the following:

 file: msg-en.msg
 keys:
   foo.title
   foo.intro
   foo.label.main
 file: other_msg-en.msg
 keys:
   baz.title
   baz.intro
   baz.conclusion
 file: another_msg-en.msg
   bar.title
   bar.intro
   bar.error.notfound

would be flattened into:

 lang: en
   foo.title
   foo.intro
   foo.label.main
   baz.title
   baz.intro
   baz.conclusion
   bar.title
   bar.intro
   bar.error.notfound

The method throws an exception on any of the following conditions:

Note that a duplicate key (that is, a key defined in multiple message files) will not generate an exception. Instead it will generate a logging message with an 'error' level.

See more about the format used for the message files in OpenInteract2::Manual::I18N.

Returns: arrayref of the names of the classes generated.

SEE ALSO

OpenInteract2::I18N

OpenInteract2::Manual::I18N

Locale::Maketext

COPYRIGHT

Copyright (c) 2003 Chris Winters. All rights reserved.

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

AUTHORS

Chris Winters <chris@cwinters.com>

Generated from the OpenInteract 1.99_04 source.


Home | Wiki | OI 1.x Docs | OI 2.x Docs
SourceForge Logo