Update of /cvsroot/po4a/po4a/lib/Locale/Po4a
In directory haydn:/tmp/cvs-serv314
Modified Files:
Po.pm
Log Message:
Added 2 new small functions: {g|s}et_charset(), that work with the po header
Index: Po.pm
===================================================================
RCS file: /cvsroot/po4a/po4a/lib/Locale/Po4a/Po.pm,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- Po.pm 2 Aug 2004 09:35:39 -0000 1.16
+++ Po.pm 6 Aug 2004 22:48:51 -0000 1.17
@@ -265,7 +265,7 @@
=item gettextize()
This function produce one translated message catalog from two catalogs, an
-original an a translation. This process is described in po4a(7), section
+original and a translation. This process is described in po4a(7), section
I<Gettextization: how does it work?>.
=cut
@@ -873,6 +873,39 @@
return $msgid if ($self->{po}{$msgid}{'pos'} eq $num);
}
return undef;
+}
+
+=item get_charset()
+
+This returns the character set specified in the po header. If it hasn't been
+set, it will return "CHARSET".
+
+=cut
+
+sub get_charset() {
+ my $self=shift;
+ $self->{header} =~ /charset=(.*?)[\s\\]/;
+ return $1;
+}
+
+=item set_charset()
+
+This sets the character set of the po header to the value specified in its
+first argument. If you never call this function (and no file with an specified
+character set is read), the default value is left to "CHARSET". This value
+doesn't change the behavior of this module, it's just used to fill that field
+in the header, and to return it in get_charset().
+
+=cut
+
+sub set_charset() {
+ my $self=shift;
+
+ my ($newchar,$oldchar);
+ $newchar = shift;
+ $oldchar = $self->get_charset();
+
+ $self->{header} =~ s/$oldchar/$newchar/;
}
#----[ helper functions ]---------------------------------------------------