Delayed I18N translation of strings
Perl
Switch branches/tags
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib/I18N
.gitignore
Changes
README.pod
dist.ini

README.pod

SYNOPSIS

use I18N::String qw('_');

I18N::String->localize_via( \&localize );

my @Days = (
    _('Monday'),   _('Tuesday'),  _('Wednesday'),
    _('Thursday'), _('Friday'),   _('Saturday'),
    _('Sunday')
);

sub day_of_week {
    my $day = shift;
    return $Days[$day]
}

DESCRIPTION

Sometimes it is useful to store I18N'able strings in variables, but delay their translation until the point that they are actually used. I18N::String does this for you.

USAGE

Importing

use I18N::String;           # exports loc()
use I18N::String 'foo'      # exports a func named foo()


my $str = foo('String');

print $str;                 # localized version of 'String'

localize_via()

I18N::String->localize_via( $coderef );

You need to set this once, and it is global. This is the function that will be called when your variable is stringified, to return the localized version.

loc()

You can also store strings that require arguments, eg:

$str = _('I found [quant,_1,file,files]');

And stringify them via:

$str->loc(@args);

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc I18N::String

You can also look for information at: