Debian Codegraph @

po/sv/generate-addendum.sh

raw symbols SCIP
1 #!/bin/shscip-shell filesystem . . `/bin/sh`.
2 #
3 # Copyright © 2010-2017 Dr. Tobias Quathamer <[email protected]>
4 # 2022,2025,2026 Dr. Helge Kreutzmann <[email protected]>
5 #
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18
19 translation="$1"
20 addendum="$2"
21 masterfile="$3"
22
23 ismdoc=$(grepscip-shell system . . grep. -Rl "\.Sh NAME" $masterfile)
24
25 # Use the header up until the first msgid
26 # and remove the comment character
27 translators=$(sedscip-shell system . . sed. '/msgid/q;s/^#\s\+//scip-shell filesystem . . `/msgid/q;s/^#\s\+//`.' "$translation" |
28 # Throw away the common (non translator) lines
29 grepscip-shell system . . grep. -a -v "Swedish translation of manpages" |
30 grepscip-shell system . . grep. -a -v "This file is distributed under the same license as the manpages-l10n package." |
31 grepscip-shell system . . grep. -a -v "Copyright © of this file:" |
32 grepscip-shell system . . grep. -a -v "FIXME:" |
33 grepscip-shell system . . grep. -a -v "msgid" |
34 grepscip-shell system . . grep. -a -v '^#[[:space:]]*$' |
35 # Split lines to extract the name (and e-mail address)
36 cutscip-shell system . . cut. -f1 -d","| sedscip-shell system . . sed. 's/\.$//')
37 # Determine number of translators
38 number_translators=$(echoscip-shell system . . echo. "$translators" | wcscip-shell system . . wc. -l)
39
40 # Output of common header
41 echoscip-shell system . . echo. "PO4A-HEADER:mode=after;position=^\.(TH|Dt);beginboundary=FakePo4aBoundary" > "$addendum"
42
43 # Special case for manpages which use mdoc syntax
44 if [scip-shell system . . `[`. $ismdoc ]; then
45 # MDOC File
46 echoscip-shell system . . echo. ".Pp" >> "$addendum"
47 echoscip-shell system . . echo. ".Sh ÖVERSÄTTNING" >> "$addendum"
48 else
49 # Groff file
50 echoscip-shell system . . echo. ".PP" >> "$addendum"
51 echoscip-shell system . . echo. ".SH ÖVERSÄTTNING" >> "$addendum"
52 fi
53 echoscip-shell system . . echo. "Den svenska översättningen av denna manualsida skapades av" >> "$addendum"
54
55 # Warn if the translators string is empty
56 if [scip-shell system . . `[`. -z "$translators" ]; then
57 echoscip-shell system . . echo. "Warning: No translators found for '$translation'." >&2
58 fi
59 # Apply correct formatting, depending on the number of translators
60 if [scip-shell system . . `[`. $number_translators -eq 1 ]; then
61 echoscip-shell system . . echo. "$translators" >> "$addendum"
62 fi
63 if [scip-shell system . . `[`. $number_translators -eq 2 ]; then
64 echoscip-shell system . . echo. "$translators" | headscip-shell system . . head. -n1 >> "$addendum"
65 echoscip-shell system . . echo. "och" >> "$addendum"
66 echoscip-shell system . . echo. "$translators" | tailscip-shell system . . tail. -n1 >> "$addendum"
67 fi
68 if [scip-shell system . . `[`. $number_translators -ge 3 ]; then
69 echoscip-shell system . . echo. "$translators" | headscip-shell system . . head. -n$(($number_translators - 2)) | perlscip-shell system . . perl. -pe "s/$/,/" >> "$addendum"
70 echoscip-shell system . . echo. "$translators" | tailscip-shell system . . tail. -n2 | headscip-shell system . . head. -n1 >> "$addendum"
71 echoscip-shell system . . echo. "och" >> "$addendum"
72 echoscip-shell system . . echo. "$translators" | tailscip-shell system . . tail. -n1 >> "$addendum"
73 fi
74
75 # Output of common ending
76 echoscip-shell system . . echo. "." >> "$addendum"
77
78 # Special case for manpages which use mdoc syntax
79 if [scip-shell system . . `[`. $ismdoc ]; then
80 # MDOC File
81 catscip-shell system . . cat. license-mdoc.add >> "$addendum"
82 else
83 # Groff file
84 catscip-shell system . . cat. license-groff.add >> "$addendum"
85 fi