DeltaX::Language - Perl module for reading language files
_____ / \ _____ ______ ______ ___________ / \ / \\__ \ / ___// ___// __ \_ __ \ / Y \/ __ \_\___ \ \___ \\ ___/| | \/ \____|__ (____ /____ >____ >\___ >__| \/ \/ \/ \/ \/ project
use DeltaX::Language; my $lang_file = new DeltaX::Language('my_lang.EN'); my $texts = $lang_file->read(); my @conflicts = $lang_file->get_conflicts(); print $texts->{'text_id'};
Constructor. The first argument is a filename (required), second (optional) field separator (default is a tabelator ('\t')), other arguments are in key => value form, they are directive definitions in "directive_name => sub reference" form (see "DIRECTIVES").
This function reads given file and returns undef (in case of error) or reference to a hash in which keys are text id's and values a texts themselfs.
This function returns error in textual form (only valid after read() call).
This function returns array with text id's which occured more than once (in result of read() function will be only the last one). Only valid after read() call.
Text files have a simple structure: one line = one record, in key<separator>text form. Everything form # sign to end of line is a comment, except #!<directive> (see "DIRECTIVES"). Everything other (empty lines, ...) is ignored.
Example:
# this is comment # id1_This is text id2_This is another text #!include other_file [character _ means separator, often tabelator ('\t')]
Directives are special form of comments: #!directive [parameters]. DeltaX::Config knows two of them:
#!directive [parameters]
It includes given file. Filename of included file is the first and only argument. If it is not absolute path, path is got from actually readed filename.
It sets given character as a new separator, it can be in escaped form (for example #!separator \t). You cannot set new line or space as a separator using this directive.
By setting parameter to new() you can define other directives and use it in your files. Every definition must be sub reference. This sub will be called with all arguments for this directive.
Program: sub myspec_func { my $arg = shift; # return reference to a hash or undef in case of error } my $conf = new DeltaX::Language('my_lang.EN',myspec=>\&myspec_func); Configuration file: #!myspec something
To install DeltaX::Page, copy and paste the appropriate command in to your terminal.
cpanm
cpanm DeltaX::Page
CPAN shell
perl -MCPAN -e shell install DeltaX::Page
For more information on module installation, please visit the detailed CPAN module installation guide.