NAME

Log::Report::Template::Textdomain - template translation with one domain

INHERITANCE

Log::Report::Template::Textdomain
  is a Log::Report::Domain
  is a Log::Report::Minimal::Domain

SYNOPSIS

my $templater = Log::Report::Template->new(...);
my $domain    = $templater->addTextdomain(%options);

DESCRIPTION

Manage one translation domain for Log::Report::Template.

Extends "DESCRIPTION" in Log::Report::Domain.

METHODS

Extends "METHODS" in Log::Report::Domain.

Constructors

Extends "Constructors" in Log::Report::Domain.

$class->new(%options)

Inherited, see "Constructors" in Log::Report::Domain

-Option              --Defined in                  --Default
 lang                                                undef
 lexicon                                             undef
 name                  Log::Report::Minimal::Domain  <required>
 only_in_directory                                   undef
 templater                                           <required>
 translation_function                                'loc'
lang => LANGUAGES

[1.01] Initial language to translate to. Usually, this language which change for each user connection via translateTo().

lexicon => DIRECTORY
name => STRING
only_in_directory => DIRECTORY|ARRAY

The textdomain can only be used in the indicated directories: if found anywhere else, it's an error. When not specified, the function is allowed everywhere.

templater => Log::Report::Template-object
translation_function => STRING

The name of the function as used in the template to call for translation. See function(). It must be unique over all text-domains used.

$class->upgrade($domain, %options)

Upgrade a base class Log::Report::Domain-object into an Template domain.

This is a bit akward process, needed when one of the code packages uses the same domain as the templating system uses. The generic domain configuration stays intact.

Attributes

Extends "Attributes" in Log::Report::Domain.

$obj->configure(%options)

Inherited, see "Attributes" in Log::Report::Domain

$obj->contextRules()

Inherited, see "Attributes" in Log::Report::Domain

$obj->expectedIn($filename)

Return true when the function name which relates to this domain is allowed to be used for the indicated file. The msgid extractor will warn when there is no match.

$obj->function()

Returns the name of the function which is used for translations.

$obj->isConfigured()

Inherited, see "Attributes" in Log::Report::Minimal::Domain

$obj->lang()

The language we are going to translate to. Change this with translateTo() for this domain, or better Log::Report::Template::translateTo().

$obj->lexicon()

Directory where the translation tables are kept.

$obj->name()

Inherited, see "Attributes" in Log::Report::Minimal::Domain

$obj->nativeLanguage()

Inherited, see "Attributes" in Log::Report::Domain

$any->readConfig($filename)

Inherited, see "Attributes" in Log::Report::Domain

$obj->templater()

The Log::Report::Template object which is using this textdomain.

$obj->translator()

Inherited, see "Attributes" in Log::Report::Domain

Translating

Extends "Translating" in Log::Report::Domain.

$obj->defaultContext()

Inherited, see "Translating" in Log::Report::Domain

$obj->interpolate( $msgid, [$args] )

Inherited, see "Translating" in Log::Report::Minimal::Domain

$obj->setContext(STRING|HASH|ARRAY|PAIRS)

Inherited, see "Translating" in Log::Report::Domain

$obj->translate($message, $language)

Inherited, see "Translating" in Log::Report::Domain

$obj->translateTo($lang)

Set the language to translate to for $lang, for this domain only. This may be useful when various text domains do not support the same destination languages. But in general, you can best use Log::Report::Template::translateTo().

$obj->translationFunction()

This method returns a CODE which is able to handle a call for translation by Template Toolkit.

$obj->updateContext(STRING|HASH|ARRAY|PAIRS)

Inherited, see "Translating" in Log::Report::Domain

DETAILS

Extends "DETAILS" in Log::Report::Domain.

DIAGNOSTICS

Warning: Missing key '$key' in format '$format', file $use

Cast by configure()

Warning: Missing key '$key' in format '$format', in $use //template

Cast by translationFunction()

Fault: cannot open JSON file for context at $fn: $!

Cast by readConfig()

Error: extension to domain '$name' already exists

Cast by upgrade()

Error: message does not contain counting alternatives in '$msgid'

Cast by translationFunction()

Error: no counting positional for '$msgid'

Cast by translationFunction()

Error: no counting positional for '$msgid'

Cast by translationFunction()

Error: superfluous positional parameters for '$msgid'

Cast by translationFunction()

Error: superfluous positional parameters for '$msgid'

Cast by translationFunction()

Error: the native_language '$locale' is not a valid locale

Cast by configure()

Error: unsupported context file type for $fn

Cast by readConfig()

Error: you need to configure context_rules before setContext

Cast by setContext()

SEE ALSO

This module is part of Log-Report-Template version 1.04, built on November 04, 2025. Website: http://perl.overmeer.net/CPAN/

LICENSE

For contributors see file ChangeLog.

This software is copyright (c) 2017-2025 by Mark Overmeer.

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