diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 19:43:11 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 19:43:11 +0000 |
commit | fc22b3d6507c6745911b9dfcc68f1e665ae13dbc (patch) | |
tree | ce1e3bce06471410239a6f41282e328770aa404a /po/create-new-translation.sh | |
parent | Initial commit. (diff) | |
download | manpages-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 'po/create-new-translation.sh')
-rwxr-xr-x | po/create-new-translation.sh | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/po/create-new-translation.sh b/po/create-new-translation.sh new file mode 100755 index 00000000..45cc2ace --- /dev/null +++ b/po/create-new-translation.sh @@ -0,0 +1,89 @@ +#!/bin/bash +# +# Copyright © 2018-2019 Dr. Tobias Quathamer <toddy@debian.org> +# 2021,2022 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/>. + +if [ -d man1 ]; then + lcode=$(basename $(pwd)) +elif [ a"$2" != a ]; then + if [ -d $2 ]; then + cd $2 + lcode=$2 + else + echo "Language $2 could not be found, aborting" + exit 11 + fi +else + echo "Could not determine target directory, aborting" + exit 12 +fi + +source ../l10n_set + +# Require one argument (the name of the manpage) +if [ -z "$1" ]; 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 ${1%%.po}) +mandir="man"$(echo $manpage | sed -e 's/[a-z]*$//' | sed -e "s/.*\.\([0-9]\).\?$/\1/") +pofile=$mandir/$manpage.po +potfile=../../templates/$mandir/$manpage.pot + +# Create the template +cd ../../templates +./generate-one-template.sh $manpage +returncode=$(echo $?) + +if [ $returncode != 0 ]; then + exit 16 +fi + +# Update common templates +./create-common-templates.sh +cd ../po/$lcode + +# Update common translations +../update-common.sh + +# Ensure that there is a .po file +if [ ! -f $mandir/$manpage.po ]; then + # Create a new .po file + msginit --no-translator --locale="$lcode" -i "$potfile" -o "$pofile" + + # Get the head of the file until first msgid line + # and generate the standard header + tmppo1=$(mktemp) + tmppo2=$(mktemp) + sed -e "1,/^msgid/d" "$pofile" > "$tmppo1" + echo "# $langname translation of manpages" > "$pofile" + echo "# This file is distributed under the same license as the manpages-l10n package." >> "$pofile" + echo "# Copyright © of this file:" >> "$pofile" + echo "msgid \"\"" >> "$pofile" + cat "$pofile" "$tmppo1" > "$tmppo2" + mv "$tmppo2" "$pofile" + rm -f "$tmppo1" "$tmppo2" + + # Adjust two header lines + #sed -i -e "s/^\"Language-Team: none\\\n\"$/\"Language-Team: German <debian-l10n-german@lists.debian.org>\\\n\"/" "$pofile" + sed -i -e "s/^\"Language-Team: none\\\n\"$/\"Language-Team: $langmail\\\n\"/" "$pofile" + sed -i -e "s/^\"Project-Id-Version: manpages-de .*$/\"Project-Id-Version: manpages-l10n\\\n\"/" "$pofile" +fi + +# Finally, populate the translation from the compendium. +../update-po.sh "$pofile" "$lcode" |