Locale::Tie - Get/set locale via (localizeable) variables
This document describes version 0.03 of Locale::Tie (from Perl distribution Locale-Tie), released on 2014-10-23.
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
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.
They are not exported by default, but exportable.
Alias for $LC_ALL, but won't hashify.
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", }
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.
$ENV{LANG}
Please visit the project's homepage at https://metacpan.org/release/Locale-Tie.
Source repository is at https://github.com/perlancar/perl-Locale-Tie.
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.
perlancar <perlancar@cpan.org>
This software is copyright (c) 2014 by perlancar@cpan.org.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Locale::Tie, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Locale::Tie
CPAN shell
perl -MCPAN -e shell install Locale::Tie
For more information on module installation, please visit the detailed CPAN module installation guide.