NAME
Locale::Tie - Get/set locale via (localizeable) variables
VERSION
This document describes version 0.03 of Locale::Tie (from Perl
distribution Locale-Tie), released on 2014-10-23.
SYNOPSIS
use Locale::Tie qw($LANG $LC_ALL $LC_TIME); # ...
say "Current locale is ", $LANG; # -> en_US.UTF-8
{
local $LANG = 'id_ID';
printf "%.2f\n", 12.34; # -> 12,34
}
printf "%.2f\n", 12.34; # -> 12.34
DESCRIPTION
This module is inspired by File::chdir, using a tied scalar variable to
get/set stuffs. One benefit of this is being able to use Perl's "local"
with it, effectively setting something locally.
EXPORTS
They are not exported by default, but exportable.
$LANG => str
Alias for $LC_ALL, but won't hashify.
$LC_ALL => str | hash
Return current locale as string. If different parts use different locale
(e.g. LC_COLLATE uses one locale and LC_CTYPE uses another) will return
a hash, e.g.:
{
LC_ADDRESS => "en_US.UTF-8",
LC_COLLATE => "en_US.UTF-8",
LC_CTYPE => "en_US.UTF-8",
LC_IDENTIFICATION => "en_US.UTF-8",
LC_MEASUREMENT => "en_US.UTF-8",
LC_MESSAGES => "id_ID.UTF-8",
LC_MONETARY => "en_US.UTF-8",
LC_NAME => "en_US.UTF-8",
LC_NUMERIC => "C",
LC_PAPER => "en_US.UTF-8",
LC_TELEPHONE => "en_US.UTF-8",
LC_TIME => "en_US.UTF-8",
}
$LC_ADDRESS
$LC_COLLATE
$LC_CTYPE
$LC_IDENTIFICATION
$LC_MEASUREMENT
$LC_MESSAGES
$LC_MONETARY
$LC_NAME
$LC_NUMERIC
$LC_PAPER
$LC_TELEPHONE
$LC_TIME
SEE ALSO
POSIX
Locale::Scope
Other modules with the same concept: File::chdir, File::umask,
System::setuid.
autolocale which uses Variable::Magic (similar to tie technique) to
automatically setlocale() when entry $ENV{LANG} is set.
HOMEPAGE
Please visit the project's homepage at
<
https://metacpan.org/release/Locale-Tie>.
SOURCE
Source repository is at <
https://github.com/perlancar/perl-Locale-Tie>.
BUGS
Please report any bugs or feature requests on the bugtracker website
<
https://rt.cpan.org/Public/Dist/Display.html?Name=Locale-Tie>
When submitting a bug or request, please include a test-file or a patch
to an existing test-file that illustrates the bug or desired feature.
AUTHOR
perlancar <
[email protected]>
COPYRIGHT AND LICENSE
This software is copyright (c) 2014 by
[email protected].
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.