summaryrefslogtreecommitdiffstats
path: root/templates/generate-template.sh
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 19:43:11 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 19:43:11 +0000
commitfc22b3d6507c6745911b9dfcc68f1e665ae13dbc (patch)
treece1e3bce06471410239a6f41282e328770aa404a /templates/generate-template.sh
parentInitial commit. (diff)
downloadmanpages-l10n-fc22b3d6507c6745911b9dfcc68f1e665ae13dbc.tar.xz
manpages-l10n-fc22b3d6507c6745911b9dfcc68f1e665ae13dbc.zip
Adding upstream version 4.22.0.upstream/4.22.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'templates/generate-template.sh')
-rwxr-xr-xtemplates/generate-template.sh68
1 files changed, 68 insertions, 0 deletions
diff --git a/templates/generate-template.sh b/templates/generate-template.sh
new file mode 100755
index 00000000..9c172ba5
--- /dev/null
+++ b/templates/generate-template.sh
@@ -0,0 +1,68 @@
+#!/bin/sh
+#
+# Copyright © 2019 Dr. Tobias Quathamer <toddy@debian.org>
+# © 2022,2023,2024 Dr. Helge Kreutzmann <debian@helgefjell.de>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Require first argument (the name of the distribution)
+if [ -z "$1" ]; then
+ echo "Please specify the name of the distribution." >&2
+ exit 1
+fi
+distribution="$1"
+
+# Require a second argument (the name of the manpage)
+if [ -z "$2" ]; then
+ echo "Please specify the name of the manpage, e.g. 'arch.1'." >&2
+ exit 1
+fi
+
+# Normalize to the basename of the manpage
+manpage=$(basename $2)
+
+# Find upstream manpages with a matching name
+upstream_manpage=$(find "../upstream/$distribution/" -type f -name "$manpage")
+
+if [ -z "$upstream_manpage" ]; then
+ echo "A manpage named '$manpage' could not be found in distribution '$distribution'." >&2
+ exit 1
+fi
+
+# Necessary, size 0 file of mktemp fails for UTF-8 characters, see Debian bug #1022216
+tdir=$(mktemp -d)
+mkdir $tdir/$distribution
+
+# Remove / Uncomment some macros po4a cannot handle
+# #1 / #2 Errors in some pages
+# #3 / #4 The last two can be removed, if mkpasswd (Debian BTS #1036908) and gawk (fixed upstream) are fixed (or Debian #1036826)
+# #5 Po4a sometimes has troubles parsing \c - This crude pattern gets around this, but adding additional spaces and sometimes moving arguments into main text, see Debian #1036826
+cat $upstream_manpage | sed "s/^.ft C$/^\".ft C$/" | sed "s/^.ft P$/^\".ft P$/" | sed "s/\\\\fb/\\fB/" | sed "s/^\.BI \(\\\\.*\)\"\\\\c$/.BI \1\"/" | sed "s/^\.BR \(\\\\.*\)\"\\\\c$/.BI \1\"/" | sed "s/\\\\c$//" > $tdir/$distribution/$manpage
+#cat $upstream_manpage | sed "s/^.ft C$/^\".ft C$/" | sed "s/^.ft P$/^\".ft P$/" | sed "s/\\\\fb/\\fB/" | sed "s/^\.BI \(\\\\.*\)\"\\\\c$/.BI \1\"/" | sed "s/^\.BR \(\\\\.*\)\"\\\\c$/.BI \1\"/" | perl -p -e 's/\\c\n//' > $tdir/$distribution/$manpage
+
+po4a-updatepo -f man \
+ --no-deprecation \
+ --option groff_code=verbatim \
+ --option generated \
+ --option untranslated="}1,Ds,zY,zZ,Ee,ES,dT,FN,NE,NS,EX,EE,Id,rstReportMargin,INDENT,UNINDENT,UN,a.RE,\|" \
+ --option unknown_macros=untranslated \
+ --master "$tdir/$distribution/$manpage" -M utf-8 \
+ -p $tdir/tmp.pot
+
+# Reduce the location lines from the full path and line number
+cat $tdir/tmp.pot | sed -e "s,/tmp/\.private/[a-zA-Z0-9]*/tmp\.,/tmp/tmp.," | sed -e "s,^#: /tmp/tmp\.[a-zA-Z0-9]*/\([^/]\+\)/.*,#: \1," |\
+ # Ensure the correct encoding is set
+ sed -e "s/^\"Content-Type: text\/plain; charset=CHARSET\\\\n\"$/\"Content-Type: text\/plain; charset=UTF-8\\\\n\"/"
+
+rm -rf $tdir