logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

Catmandu::I18N - tools for text localisation

Authors

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

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.

Name

       Catmandu::I18N - tools for text localisation

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]

See Also

       Catmandu::Fix::i18n, Locale::Maketext::Lexicon::CatmanduConfig, Catmandu, Locale::Maketext

Synopsis

           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" );

See Also