Catmandu::I18N(3pm)

Catmandu::I18N3pm

Tools for text localisation

Usage

    use Catmandu::Sane;
    use Catmandu::I18N;
    my $i = Catmandu::I18N->new(
        config => {
            en => [
              "Gettext",
              "/path/to/en.po"
            ],
            nl => [
              "Gettext",
              "/path/to/nl.po"
            ]
        }
    );
    $i->t( "my-lang", "my-key" );
    $i->t( "my-lang", "my-key2", "arg-1", "arg-2" );

Constructor arguments

config

Configuration for Locale::Maketext.

Must be either:

* hash reference

* string (e.g. "i18n")

When the config is a string, it is interpreted as the path to the I18N configuration in Catmandu config.

Required

on_failure

What to do when a lookup does not give a result.

Possible values:

* "undef" : return undef

* "auto" : return key itself. Always a result.

* "die" : die

Default: "undef"

Note: "undef" should be a string, as opposed to undef.

fallback_languages

array of fallback language codes

* must be array reference

* default is [ "i-default","en","en-US" ] as determined by Locale::Maketext

When Locale::Maketext does not find the specified language in your config, it will fallback to one of these, and then load the handle for that.

Only if that fallback language does not exist in the config, will it fail.

Example 1:

fallback_languages is [ "en" ]

you have only language "en" in your config, but you request language "nl", then you'll get the message in English.

Example 2:

fallback_languages is [ "en" ]

you have only language "nl" in your config, but you request language "fr", then the creation of the message will fail

You can set this to an empty array for consistent behaviour.

Notes

* the lexicon implementation determines the format of the message.

e.g. only Locale::Maketext::Lexicon::Gettext supports placeholders like %1.

For other implementations you need to use placeholders like [_1]

Releases

Unchanged in 2 releases since Debian 12 (Bookworm).

  1. 12–13

Authors

Nicolas Franck "<nicolas.franck at ugent.be>"

From libcatmandu-i18n-perl 0.01-2 in Debian 13 (Trixie). Parsed by carta from the page's man source.