[Po4a-commits] "po4a/lib/Locale/Po4a Xml.pm,1.59,1.60"
Nicolas FRANCOIS
nekral-guest at alioth.debian.org
Thu Feb 14 17:59:49 UTC 2008
Update of /cvsroot/po4a/po4a/lib/Locale/Po4a
In directory alioth:/tmp/cvs-serv32365/lib/Locale/Po4a
Modified Files:
Xml.pm
Log Message:
* lib/Locale/Po4a/Xml.pm: Add the translated and untranslated
options. They should replace the tags option and provide a more
configurable and understandable way to use the Xml module.
* lib/Locale/Po4a/Xml.pm (get_translate_options): Add support for
the translated and untranslated options.
* lib/Locale/Po4a/Xml.pm: Document the translated and untranslated
options.
* lib/Locale/Po4a/Xml.pm: Document that the tags and tagsonly
options are deprecated.
* NEWS: Document the new options.
Index: Xml.pm
===================================================================
RCS file: /cvsroot/po4a/po4a/lib/Locale/Po4a/Xml.pm,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -d -r1.59 -r1.60
--- Xml.pm 14 Feb 2008 16:53:16 -0000 1.59
+++ Xml.pm 14 Feb 2008 17:59:46 -0000 1.60
@@ -247,6 +247,8 @@
Extracts only the specified tags in the "tags" option. Otherwise, it
will extract all the tags except the ones specified.
+Note: This option is deprecated.
+
=item doctype
String that will try to match with the first line of the document's doctype
@@ -266,6 +268,9 @@
Example: WE<lt>chapterE<gt>E<lt>titleE<gt>
+Note: This option is deprecated.
+You should use the B<translated> and B<untranslate> options instead.
+
=item attributes
Space-separated list of the tag's attributes you want to translate. You can
@@ -297,6 +302,20 @@
Note: the preprocessor directives must only appear between tags
(they must not break a tag).
+=item translated
+=item unstranslated
+
+Space-separated list of the tags you want to translate or not.
+The tags must be in the form <aaa>, but you can join some (<bbb><aaa>) to
+indicate that the content of the tag <aaa> will only be translated when
+itâs into a <bbb> tag.
+
+You can also specify some tag options putting some characters in front of
+the tag hierarchy. For example, you can put âwâ (wrap) or âWâ (donât wrap)
+to overide the default behavior specified by the global "wrap" option.
+
+Example: W<chapter><title>
+
=back
=cut
@@ -318,6 +337,8 @@
$self->{options}{'caseinsensitive'}=0;
$self->{options}{'tagsonly'}=0;
$self->{options}{'tags'}='';
+ $self->{options}{'translated'}='';
+ $self->{options}{'untranslated'}='';
$self->{options}{'attributes'}='';
$self->{options}{'inline'}='';
$self->{options}{'placeholder'}='';
@@ -341,6 +362,8 @@
#It will maintain the list of the translatable tags
$self->{tags}=();
+ $self->{translated}=();
+ $self->{untranslated}=();
#It will maintain the list of the translatable attributes
$self->{attributes}=();
#It will maintain the list of the inline tags
@@ -1068,6 +1091,21 @@
$translate = 1;
}
+# TODO: a less precise set of tags should not override a more precise one
+ # The tags and tagsonly options are deprecated.
+ # The translated and untranslated options have an higher priority.
+ $tag = $self->get_tag_from_list($path, @{$self->{untranslated}});
+ if (defined $tag) {
+ $options = "";
+ $translate = 0;
+ }
+ $tag = $self->get_tag_from_list($path, @{$self->{translated}});
+ if (defined $tag) {
+ $options = $tag;
+ $options =~ s/<.*$//;
+ $translate = 1;
+ }
+
if ($translate and $options !~ m/w/i) {
$options .= ($self->{options}{'wrap'})?"w":"W";
}
@@ -1465,6 +1503,14 @@
}
$self->{tags} = \@list_tags;
+ $self->{options}{'translated'} =~ /\s*(.*)\s*/s;
+ my @list_translated = split(/\s+/s,$1);
+ $self->{translated} = \@list_translated;
+
+ $self->{options}{'untranslated'} =~ /\s*(.*)\s*/s;
+ my @list_untranslated = split(/\s+/s,$1);
+ $self->{untranslated} = \@list_untranslated;
+
$self->{options}{'attributes'} =~ /\s*(.*)\s*/s;
my @list_attr = split(/\s+/s,$1);
$self->{attributes} = \@list_attr;
More information about the Po4a-commits
mailing list