Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ AsciiDoc:
(GitHub's #610 and #611) [Oliver Rahner]
* Fix table header recognition pattern and context [Jean-Noël Avila]

SimplePod:
* Fix incorrectly emitted list item content twice in translated output
(GitHub's #638 and #640) [gemmaro]

TexInfo:
* Partial support of @documentencoding (hardcoded to the english value) and
@documentlanguage (to be manually translated by the humans in the PO file)
Expand Down
28 changes: 21 additions & 7 deletions lib/Locale/Po4a/SimplePod/Parser.pm
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use warnings;
use parent qw(Pod::Simple);

use Locale::Po4a::Common qw(wrap_mod dgettext);
use Carp qw(confess);
use Carp qw(confess);

use constant MODULE_NAME => "po4a::simplepod";

Expand Down Expand Up @@ -44,11 +44,25 @@ sub _handle_element_start {
$self->{text} and die $self->unexpected_error; # [1]
push @{ $self->{elements} }, { name => $name, line => $attrs->{start_line} };

# Even if ~type is bullet, ~orig_content may be empty. Therefore, it
# cannot be predetermined as "*".
my $bullet = $attrs->{'~orig_content'} ? " $attrs->{'~orig_content'}" : "";

$self->{tractor}->pushline("\n=item$bullet\n\n");
# This hack follows the Pod::Simple::JustPod implementation[2]
# in order to preserve the original writing style as much as
# possible. Note that even if type is bullet, ~orig_content
# may be empty. Therefore, it cannot be predetermined as "*".
# [2] https://metacpan.org/release/KHW/Pod-Simple-3.47/source/lib/Pod/Simple/JustPod.pm#L87
my $bullet;
if ( $attrs->{'~orig_content'} ) {
if ( $attrs->{'~_freaky_para_hack'} ) {
my $item_text = $attrs->{'~orig_content'};
my $trailing = quotemeta $attrs->{'~_freaky_para_hack'};
$item_text =~ s/$trailing\Z//;
$bullet = " $item_text";
} else {
$bullet = " *\n\n";
}
} else {
$bullet = "\n\n";
}
$self->{tractor}->pushline("\n=item$bullet");

} elsif ( $name eq "item-number" ) {
$self->{text} and die $self->unexpected_error; # [1]
Expand Down Expand Up @@ -208,7 +222,7 @@ sub _handle_element_end {

sub translate_block {
my ( $self, $line, $type, $wrap ) = @_;
my $ref = "$self->{current_ref}:$line";
my $ref = "$self->{current_ref}:$line";
my $text = $self->{tractor}->translate( $self->{text}, $ref, $type, wrap => $wrap );
undef $self->{text};
return $text;
Expand Down
5 changes: 5 additions & 0 deletions t/fmt-simplepod.t
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ push @tests,
format => 'SimplePod',
input => 'fmt/simplepod/issues.pod',
},
{
doc => 'List specific test cases',
format => 'SimplePod',
input => 'fmt/simplepod/list.pod',
},
{
doc => 'Complete set of syntaxes from podlators',
format => 'SimplePod',
Expand Down
19 changes: 19 additions & 0 deletions t/fmt/simplepod/list.norm
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

*****************************************************
* GENERATED FILE, DO NOT EDIT *
* THIS IS NO SOURCE FILE, BUT RESULT OF COMPILATION *
*****************************************************

This file was generated by po4a(7). Do not store it (in VCS, for example),
but store the PO file used as source file by po4a-translate.

In fact, consider this as a binary, and the PO file as a regular .c file:
If the PO get lost, keeping this translation up-to-date will be harder.

=encoding UTF-8

=over

=item * foo

=back
20 changes: 20 additions & 0 deletions t/fmt/simplepod/list.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR Free Software Foundation, Inc.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: list\n"
"POT-Creation-Date: 2026-02-14 14:15+0900\n"
"PO-Revision-Date: 2026-02-14 13:35+0900\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"

#. type: =item
#: list.pod:3
msgid "foo"
msgstr "FOO"
5 changes: 5 additions & 0 deletions t/fmt/simplepod/list.pod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
=over

=item * foo

=back
22 changes: 22 additions & 0 deletions t/fmt/simplepod/list.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# SOME DESCRIPTIVE TITLE
# Copyright (C) YEAR Free Software Foundation, Inc.
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2026-02-14 13:38+0900\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"

#. type: =item
#: list.pod:3
msgid "foo"
msgstr ""
19 changes: 19 additions & 0 deletions t/fmt/simplepod/list.trans
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

*****************************************************
* GENERATED FILE, DO NOT EDIT *
* THIS IS NO SOURCE FILE, BUT RESULT OF COMPILATION *
*****************************************************

This file was generated by po4a(7). Do not store it (in VCS, for example),
but store the PO file used as source file by po4a-translate.

In fact, consider this as a binary, and the PO file as a regular .c file:
If the PO get lost, keeping this translation up-to-date will be harder.

=encoding UTF-8

=over

=item * FOO

=back
Loading