Subject: | [PATCH] Support for systems without locales / Android |
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.