Locale::TextDomain::IfEnv - Enable translation only when environment variable flag is true
This document describes version 0.002 of Locale::TextDomain::IfEnv (from Perl distribution Locale-TextDomain-IfEnv), released on 2019-12-26.
Use like you would use Locale::TextDomain (but see "Caveats"):
use Locale::TextDomain::IfEnv 'Some-TextDomain'; print __ "Hello, world!\n";
When imported, Locale::TextDomain::IfEnv will check the PERL_LOCALE_TEXTDOMAIN_IFENV environment variable. If the environment variable has a true value, the module will load Locale::TextDomain and pass the import arguments to it. If the environment variable is false, the module will install a mock version of __, et al. Thus, all strings will translate to themselves.
PERL_LOCALE_TEXTDOMAIN_IFENV
__
This module can be used to avoid the startup (and runtime) cost of translation unless when you want to enable translation.
For simplicity, currently the tied hash (%__) and its hashref ($__) are not provided. Contact me if you use and need this.
%__
$__
Please visit the project's homepage at https://metacpan.org/release/Locale-TextDomain-IfEnv.
Source repository is at https://github.com/perlancar/perl-Locale-TextDomain-IfEnv.
Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=Locale-TextDomain-IfEnv
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.
Locale::TextDomain
Locale::TextDomain::UTF8::IfEnv
Bencher::Scenarios::LocaleTextDomainIfEnv
perlancar <perlancar@cpan.org>
This software is copyright (c) 2019 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::TextDomain::IfEnv, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Locale::TextDomain::IfEnv
CPAN shell
perl -MCPAN -e shell install Locale::TextDomain::IfEnv
For more information on module installation, please visit the detailed CPAN module installation guide.