[Po4a-commits] "po4a/lib/Locale/Po4a Common.pm,1.16,1.17"

Nicolas FRANCOIS nekral-guest at alioth.debian.org
Thu Jan 15 22:04:28 UTC 2009


Update of /cvsroot/po4a/po4a/lib/Locale/Po4a
In directory alioth:/tmp/cvs-serv30688/lib/Locale/Po4a

Modified Files:
	Common.pm 
Log Message:
	* NEWS, lib/Locale/Po4a/Common.pm: Add support for a nowrapi18n
	option in order to use Locale::Po4a programatically. 


Index: Common.pm
===================================================================
RCS file: /cvsroot/po4a/po4a/lib/Locale/Po4a/Common.pm,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- Common.pm	13 Jan 2008 15:37:17 -0000	1.16
+++ Common.pm	15 Jan 2009 22:04:26 -0000	1.17
@@ -17,6 +17,20 @@
 Locale::Po4a::Common contains common parts of the po4a scripts and some useful
 functions used along the other modules.
 
+In order to use Locale::Po4a programatically, one may want to disable
+the use of Text::WrapI18N, by writing e.g.
+
+    use Locale::Po4a::Common qw(nowrapi18n);
+    use Locale::Po4a::Text;
+
+instead of:
+
+    use Locale::Po4a::Text;
+
+Ordering is important here: as most Locale::Po4a modules themselves
+load Locale::Po4a::Common, the first time this module is loaded
+determines whether Text::WrapI18N is used.
+
 =cut
 
 package Locale::Po4a::Common;
@@ -30,8 +44,19 @@
 use strict;
 use warnings;
 
-BEGIN {
-    if (eval { require Text::WrapI18N }) {
+sub import {
+    my $class=shift;
+
+    my $wrapi18n=1;
+    if (exists $_[0] && defined $_[0] && $_[0] eq 'nowrapi18n') {
+        shift;
+        $wrapi18n=0;
+    }
+    $class->export_to_level(1, $class, @_);
+
+    return if defined &wrapi18n;
+
+    if ($wrapi18n && eval { require Text::WrapI18N }) {
     
         # Don't bother determining the wrap column if we cannot wrap.
         my $col=$ENV{COLUMNS};




More information about the Po4a-commits mailing list