Skip Menu |
 

This queue is for tickets about the libintl-perl CPAN distribution.

Report information
The Basics
Id: 98109
Status: resolved
Priority: 0/
Queue: libintl-perl

People
Owner: Nobody in particular
Requestors: fraserbn [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 1.24

Attachments
0001-Workaround-for-systems-without-locale.patch
0002-Skips-for-tests-in-systems-without-locales.patch



Subject: [PATCH] Support for systems without locales / Android
Download (untitled) / with headers
text/plain 627b
Howdy! The attached patches add basically a bunch of guards for systems with no locale support, like Android, so that the module can build and test cleanly. There's really two problems for systems like Android: the LC_* constants and setlocale() throw "Unimplemented" exceptions, which render the module unusable without something like this patch. I'm not really a user of the module, so I don't know how much sense it makes to actually install it on a system without locales, but I went ahead and patched it because several distros on CPAN require this: https://metacpan.org/requires/distribution/libintl-perl?sort=[[2,1]]
Subject: 0001-Workaround-for-systems-without-locale.patch
From 82eab305bbeb41c5d3c56ce66bfe3f8c68f69371 Mon Sep 17 00:00:00 2001 From: Brian Fraser <fraserbn@gmail.com> Date: Sun, 17 Aug 2014 14:55:45 +0200 Subject: [PATCH 1/2] Workaround for systems without locale --- lib/Locale/gettext_pp.pm | 6 +++--- tests/04find_domain_bug.t | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/Locale/gettext_pp.pm b/lib/Locale/gettext_pp.pm index ed0847e..b1ddac5 100755 --- a/lib/Locale/gettext_pp.pm +++ b/lib/Locale/gettext_pp.pm @@ -398,10 +398,10 @@ sub dcnpgettext($$$$$$) unless (defined $output_codeset) { # Still no point. - my $lc_ctype = __locale_category (POSIX::LC_CTYPE(), - 'LC_CTYPE'); + my $lc_ctype = eval { __locale_category (POSIX::LC_CTYPE(), + 'LC_CTYPE') }; $output_codeset = $1 - if $lc_ctype =~ /^[a-z]{2}(?:_[A-Z]{2})?\.([^@]+)/; + if $lc_ctype && $lc_ctype =~ /^[a-z]{2}(?:_[A-Z]{2})?\.([^@]+)/; } # No point. :-( diff --git a/tests/04find_domain_bug.t b/tests/04find_domain_bug.t index 87f05c0..68fa6e9 100644 --- a/tests/04find_domain_bug.t +++ b/tests/04find_domain_bug.t @@ -36,7 +36,7 @@ BEGIN { Locale::Messages::nl_putenv ("LC_MESSAGES=en_US"); Locale::Messages::nl_putenv ("OUTPUT_CHARSET=iso-8859-1"); - POSIX::setlocale (POSIX::LC_ALL() => ''); + eval { POSIX::setlocale (POSIX::LC_ALL() => '') }; } # Make sure that LocaleData/ can befound. @@ -52,10 +52,10 @@ Locale::Messages::nl_putenv ("LC_ALL=de_AT"); Locale::Messages::nl_putenv ("LANG=de_AT"); Locale::Messages::nl_putenv ("LC_MESSAGES=de_AT"); -my $missing_locale = POSIX::setlocale (POSIX::LC_ALL() => '') ? +my $missing_locale = eval { POSIX::setlocale (POSIX::LC_ALL() => '') } ? '' : 'locale de_AT missing'; -my $locale = POSIX::setlocale (POSIX::LC_ALL() => ''); +my $locale = eval { POSIX::setlocale (POSIX::LC_ALL() => '') }; my $translation = Locale::TextDomain::__("February"); skip $missing_locale, "Feber" eq $translation; -- 1.7.12.4 (Apple Git-37)
Subject: 0002-Skips-for-tests-in-systems-without-locales.patch

Message body is not shown because it is too large.

Download (untitled) / with headers
text/plain 450b
Hi, I think instead of putting an eval{} around the constant definition, it would be better to emulate them, pretty much the same way it is done in Locale::gettext_pp for LC_MESSAGES, and actually use those constants insteaod of those from POSIX. That was actually planned from the beginning but that goal was forgotten, when all systems I came across actually had the LC_ constants. Android is the first exception. I will come back to it. Guido
Download (untitled) / with headers
text/plain 1.2k
Hi, Am So 17. Aug 2014, 11:41:08, Hugmeir schrieb: Show quoted text
> Howdy! > > The attached patches add basically a bunch of guards for systems with > no locale support, like Android, so that the module can build and test > cleanly.
There is actually a much simpler way to do that. There is a wrapper script test.pl around all tests. I could filter out the tests in question there. In fact, it is already done for another case. Show quoted text
> > There's really two problems for systems like Android: the LC_* > constants and setlocale() throw "Unimplemented" exceptions, which > render the module unusable without something like this patch.
But as a matter of fact, the module _is_ unusable if your system lacks setlocale() and the LC_ constants? Show quoted text
> I'm not really a user of the module, so I don't know how much sense it > makes to actually install it on a system without locales, but I went > ahead and patched it because several distros on CPAN require this: > https://metacpan.org/requires/distribution/libintl-perl?sort=[[2,1]]
On the other hand, for some time, libintl-perl has a third backend gettext_dumb.pm which is not only pure Perl but doesn't bother to use setlocale() at all. Maybe I can make gettext_dumb the default backend on systems without locale support.
Download (untitled) / with headers
text/plain 309b
Fixed in git now, although I cannot really test it. Locale::Messages will now force the "dumb" backend of libintl-perl if the system does not have locale support. The tests are then disabled as well. Sorry, for not using your patch but it is really a lot easier to just filter out the tests in the wrapper.
fixed in 1.24
fixed in 1.24


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.