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 |
Functions
Replace
Exported Function to use this localizer easier. This function registers
- DE_EPAGES::TLE::API::SpaceFormatter
- DE_EPAGES::TLE::API::CaseFormatter
- DE_EPAGES::TLE::API::HtmlFormatter
Syntax |
$Template = Replace( $MasterTemplate, $hMergedStrings ); |
Input |
|
Return |
|
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 |
|
Return |
|
registerHandler
Formatter uses this function to add more functionality to this TLE localizer. You can add different types:
- 'FormatHandler' - functions to format each TLE value ( [] in template)
- 'EncodingHandler' - functions to encode each TLE value (in template)
Syntax |
$ReturnValue = $Localizer->registerHandler( $HandlerType, $Handler, $Name); |
Example |
$TLEProcessor->registerHandler('FormatHandler', DE_EPAGES::TLE::API::SpaceFormatter->new); |
Input |
|