Note that there are some explanatory texts on larger screens.

plurals
  1. POLocalization in Perl using gettext and Locale::TextDomain, with fallback if Locale::TextDomain is not available
    text
    copied!<p>The "<a href="http://rassie.org/archives/247" rel="noreferrer" title="Rassie’s Doghouse » On the state of i18n in Perl">On the state of i18n in Perl</a>" blog post from 26 April 2009 recommends using <a href="http://p3rl.org/Locale::TextDomain" rel="noreferrer">Locale::TextDomain</a> module from libintl-perl distribution for l10n / i18n in Perl. Besides I have to use gettext anyway, and gettext support in Locale::Messages / Locale::TextDomain is more natural than in gettext emulation in <a href="http://p3rl.org/Locale::Maketext" rel="noreferrer">Locale::Maketext</a>.</p> <p>The subsection "<a href="http://www.gnu.org/software/gettext/manual/gettext.html#Perl" rel="noreferrer">15.5.18 Perl</a>" in chapter "<a href="http://www.gnu.org/software/gettext/manual/gettext.html#Programming-Languages" rel="noreferrer">15 Other Programming Languages</a>" in GNU gettext manual says:</p> <blockquote> <p><dl><dt><b>Portability</b></dt><br /> <dd>The <code>libintl-perl</code> package is platform independent but is not part of the Perl core. The programmer is responsible for providing a dummy implementation of the required functions if the package is not installed on the target system.</dd></dl><br /></p> </blockquote> <p>However neither of two examples in <a href="http://git.savannah.gnu.org/cgit/gettext.git/tree/gettext-tools/examples/hello-perl/" rel="noreferrer"><code>examples/hello-perl</code></a> in gettext sources (one using lower level Locale::Messages, one using higher level Locale::TextDomain) includes <strong>detecting</strong> if the package is installed on the target system, and providing <strong>dummy implementation</strong> if it is not.</p> <p>What is complicating matter (with respect to detecting if package is installed or not) is the following fragment of Locale::TextDomain manpage:</p> <blockquote> <p><strong>SYNOPSIS</strong></p> <pre><code>use Locale::TextDomain ('my-package', @locale_dirs); use Locale::TextDomain qw (my-package); </code></pre> <p><strong>USAGE</strong></p> <p>It is crucial to remember that you use Locale::TextDomain(3) as specified in the section "SYNOPSIS", that means you have to <strong>use</strong> it, not <strong>require</strong> it. The module behaves quite differently compared to other modules.</p> </blockquote> <p>Could you please tell me how one should detect if libintl-perl is present on target system, and how to provide dummy fallthrough implementation if it is not installed? Or give examples of programs / modules which do this?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload