ePages 6.10 - DE_EPAGES/Dictionary/API/Localizer.pm

Package DE_EPAGES::Dictionary::API::Localizer

This package replaces dictionary entries in a content with real translations.

Example
use DE_EPAGES::Dictionary::API::Localizer qw ( Replace );
use DE_EPAGES::Dictionary::API::XML::DictionaryImportHandler qw ( ImportDictionary );
my $Dictionary = {};
ImportDictionary($_, $Dictionary) foreach @DictionaryFiles;
if (defined $Dictionary->{$LanguageCode}) {
    $Template = Replace($Template, $Dictionary->{$LanguageCode})
}
@EXPORT_OK
Replace

Functions

Replace
localize
registerHandler

Replace

Exported Function to use this localizer easier. This function registers

to the localizer and starts the localisation process with localize.

Syntax
 $Template = Replace( $MasterTemplate, $hMergedStrings );
Input
$MasterTemplate (string)
a string e.g.: template-content
$hMergedStrings (hash ref)
keyword => value pairs
Return
$Template (string)
the processed template content

localize

Replaces barwords in the given string with the corresponding value inside of an global hash (%locales) depending on the given language. It will replace only barwords encapsulate in '{' and '}'. The barword should only contain (a-zA-Z_0-9). The length and alignment may be specified as follows: {TXT_quantity[-12]} right aligned {TXT_quantity[12]} left aligned

Syntax
 $Template = $Localizer->localize( $MasterTemplate, $hMergedStrings );
Input
$MasterTemplate (string)
a string e.g.: template-content
$hMergedStrings (hash ref)
keyword => value pairs
Return
$Template (string)
the processed template content

registerHandler

Formatter uses this function to add more functionality to this TLE localizer. You can add different types:

Syntax
$ReturnValue = $Localizer->registerHandler( $HandlerType, $Handler, $Name);
Example
$TLEProcessor->registerHandler('FormatHandler', DE_EPAGES::TLE::API::SpaceFormatter->new);
Input
$HandlerType (string)
name of handler
$Handler (ref.*)
the handler object
$Name (string)
name of tle or function