aboutsummaryrefslogtreecommitdiff
path: root/gnu/packages/patches/po4a-partial-texinfo-menu-fix.patch
blob: 8a075fa74c92c0097b149808f8a872b46af91363 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
Submitted upstream: https://github.com/mquinson/po4a/pull/437

From 43db5c0b14ec2a8ba44d338bce024df87256457b Mon Sep 17 00:00:00 2001
From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
Date: Thu, 27 Jul 2023 17:44:49 -0400
Subject: [PATCH] lib: Texinfo: Translate partial menu node names.

Fixes <https://issues.guix.gnu.org/64881>.

* lib/Locale/Po4a/Texinfo.pm (translate_buffer_menuentry): Refine
regexp, so that it matches menu entries lacking a description.
Only call 'translate_buffer' on the description if it was provided.
* t/fmt/texinfo/partialmenus.trans: New file.
* t/fmt/texinfo/partialmenus.texi: Likewise.
* t/fmt/texinfo/partialmenus.pot: Likewise.
* t/fmt/texinfo/partialmenus.po: Likewise.
* t/fmt/texinfo/partialmenus.norm: Likewise.
* t/fmt-texinfo.t: Register the new 'partialmenus' test.
---
 lib/Locale/Po4a/Texinfo.pm       |  7 +++---
 t/fmt-texinfo.t                  |  2 +-
 t/fmt/texinfo/partialmenus.norm  | 21 +++++++++++++++++
 t/fmt/texinfo/partialmenus.po    | 40 ++++++++++++++++++++++++++++++++
 t/fmt/texinfo/partialmenus.pot   | 40 ++++++++++++++++++++++++++++++++
 t/fmt/texinfo/partialmenus.texi  | 14 +++++++++++
 t/fmt/texinfo/partialmenus.trans | 21 +++++++++++++++++
 7 files changed, 141 insertions(+), 4 deletions(-)
 create mode 100644 t/fmt/texinfo/partialmenus.norm
 create mode 100644 t/fmt/texinfo/partialmenus.po
 create mode 100644 t/fmt/texinfo/partialmenus.pot
 create mode 100644 t/fmt/texinfo/partialmenus.texi
 create mode 100644 t/fmt/texinfo/partialmenus.trans

diff --git a/lib/Locale/Po4a/Texinfo.pm b/lib/Locale/Po4a/Texinfo.pm
index b4750699..1c3a4bae 100644
--- a/lib/Locale/Po4a/Texinfo.pm
+++ b/lib/Locale/Po4a/Texinfo.pm
@@ -336,7 +336,7 @@ sub translate_buffer_menuentry {
 
     my $translated_buffer = "";
 
-    if (   $buffer =~ m/^(.*?)(::)\s+(.*)$/s
+    if (   $buffer =~ m/^(.*?)(::)(?:\s+(.*))?$/s
         or $buffer =~ m/^(.*?: .*?)(\.)\s+(.*)$/s )
     {
         my ( $name, $sep, $description ) = ( $1, $2, $3 );
@@ -347,8 +347,9 @@ sub translate_buffer_menuentry {
             $translated_buffer .= ' ' x ( $menu_sep_width - 1 - $l );
             $l = $menu_sep_width - 1;
         }
-        ( $t, @e ) = $self->translate_buffer( $description, $no_wrap, @env );
-
+        if ($description) {
+            ( $t, @e ) = $self->translate_buffer( $description, $no_wrap, @env );
+        }
         # Replace newlines with space for proper wrapping
         # See https://github.com/mquinson/po4a/issues/122
         $t =~ s/\n/ /sg;
diff --git a/t/fmt-texinfo.t b/t/fmt-texinfo.t
index 4b067e43..d9ed5df3 100644
--- a/t/fmt-texinfo.t
+++ b/t/fmt-texinfo.t
@@ -10,7 +10,7 @@ use Testhelper;
 
 my @tests;
 
-for my $test (qw(longmenu comments tindex)) {
+for my $test (qw(longmenu partialmenus comments tindex)) {
     push @tests,
       {
         'format' => 'texinfo',
diff --git a/t/fmt/texinfo/partialmenus.norm b/t/fmt/texinfo/partialmenus.norm
new file mode 100644
index 00000000..99240682
--- /dev/null
+++ b/t/fmt/texinfo/partialmenus.norm
@@ -0,0 +1,21 @@
+\input texinfo
+@c ===========================================================================
+@c
+@c This file was generated with po4a. Translate the source file.
+@c
+@c ===========================================================================
+
+
+@c These menus do not contain a description, which used to cause a
+@c Texinfo menu entry to not be translated.
+@menu
+* A menu entry without any description::  A menu entry without any 
+                                            description
+* Optional menu name: The menu node::  Optional menu name: The menu node
+@end menu
+
+@node A menu entry without any description
+@chapter A menu entry without any description
+
+@node The menu node
+@chapter Optional menu name
diff --git a/t/fmt/texinfo/partialmenus.po b/t/fmt/texinfo/partialmenus.po
new file mode 100644
index 00000000..31a14443
--- /dev/null
+++ b/t/fmt/texinfo/partialmenus.po
@@ -0,0 +1,40 @@
+# 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: 2023-07-27 17:29-0400\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: chapter
+#: partialmenus.texi:8 partialmenus.texi:10 partialmenus.texi:11
+#, no-wrap
+msgid "A menu entry without any description"
+msgstr "A MENU ENTRY WITHOUT ANY DESCRIPTION"
+
+#. type: menuentry
+#: partialmenus.texi:8
+msgid "Optional menu name: The menu node"
+msgstr "OPTIONAL MENU NAME: THE MENU NODE"
+
+#. type: node
+#: partialmenus.texi:13
+#, no-wrap
+msgid "The menu node"
+msgstr "THE MENU NODE"
+
+#. type: chapter
+#: partialmenus.texi:14
+#, no-wrap
+msgid "Optional menu name"
+msgstr "OPTIONAL MENU NAME"
diff --git a/t/fmt/texinfo/partialmenus.pot b/t/fmt/texinfo/partialmenus.pot
new file mode 100644
index 00000000..0379f805
--- /dev/null
+++ b/t/fmt/texinfo/partialmenus.pot
@@ -0,0 +1,40 @@
+# 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: 2023-08-16 09:47-0400\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: chapter
+#: partialmenus.texi:8 partialmenus.texi:10 partialmenus.texi:11
+#, no-wrap
+msgid "A menu entry without any description"
+msgstr ""
+
+#. type: menuentry
+#: partialmenus.texi:8
+msgid "Optional menu name: The menu node"
+msgstr ""
+
+#. type: node
+#: partialmenus.texi:13
+#, no-wrap
+msgid "The menu node"
+msgstr ""
+
+#. type: chapter
+#: partialmenus.texi:14
+#, no-wrap
+msgid "Optional menu name"
+msgstr ""
diff --git a/t/fmt/texinfo/partialmenus.texi b/t/fmt/texinfo/partialmenus.texi
new file mode 100644
index 00000000..f8663a2b
--- /dev/null
+++ b/t/fmt/texinfo/partialmenus.texi
@@ -0,0 +1,14 @@
+\input texinfo
+
+@c These menus do not contain a description, which used to cause a
+@c Texinfo menu entry to not be translated.
+@menu
+* A menu entry without any description::
+* Optional menu name: The menu node::
+@end menu
+
+@node A menu entry without any description
+@chapter A menu entry without any description
+
+@node The menu node
+@chapter Optional menu name
diff --git a/t/fmt/texinfo/partialmenus.trans b/t/fmt/texinfo/partialmenus.trans
new file mode 100644
index 00000000..0ef742a1
--- /dev/null
+++ b/t/fmt/texinfo/partialmenus.trans
@@ -0,0 +1,21 @@
+\input texinfo
+@c ===========================================================================
+@c
+@c This file was generated with po4a. Translate the source file.
+@c
+@c ===========================================================================
+
+
+@c These menus do not contain a description, which used to cause a
+@c Texinfo menu entry to not be translated.
+@menu
+* A MENU ENTRY WITHOUT ANY DESCRIPTION::  A MENU ENTRY WITHOUT ANY 
+                                            DESCRIPTION
+* OPTIONAL MENU NAME: THE MENU NODE::  OPTIONAL MENU NAME: THE MENU NODE
+@end menu
+
+@node A MENU ENTRY WITHOUT ANY DESCRIPTION
+@chapter A MENU ENTRY WITHOUT ANY DESCRIPTION
+
+@node THE MENU NODE
+@chapter OPTIONAL MENU NAME

base-commit: 5b1cd768afdf4e9445812c5d43428495a0fde3c6
-- 
2.41.0