...
 
Commits (6)
#!/bin/sh
#
# Copyright © 2018 Dr. Tobias Quathamer <toddy@debian.org>
# Copyright © 2018-2019 Dr. Tobias Quathamer <toddy@debian.org>
#
# 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
......@@ -17,62 +17,23 @@
# Require one argument (the name of the manpage)
if [ -z "$1" ]; then
echo "Please specify the name of the manpage, e.g. 'arch.1'."
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)
mandir="man"$(echo $manpage | sed -e "s/.*\.\([0-9]\).\?$/\1/")
pofile=$mandir/$manpage.po
potfile=../templates/$mandir/$manpage.pot
# Determine directory names from upstream directory.
directories=$(find ../upstream -maxdepth 1 -type d | cut -d/ -f3- | LC_ALL=C sort)
for directory in $directories; do
# Skip adding a new translation if it exists already.
pofile=$(find $directory -type f -name "$manpage.po")
if [ -f "$pofile" ]; then
echo "The translation for '$manpage' already exists in '$directory', skipping."
continue
fi
# Find the upstream manpage
manpage_path=$(find "../upstream/$directory" -type f -name "$manpage")
if [ ! -f "$manpage_path" ]; then
echo "The manpage '$manpage' does not exist in '$directory', skipping."
continue
fi
# Determine if an encoding is specified,
# otherwise fall back to ISO-8859-1
coding=$(grep "\-\*\- coding:" "$manpage_path" | sed -e "s/.*coding:\s\+\([^ ]\+\).*/\1/")
if [ -z "$coding" ]; then
coding="ISO-8859-1"
fi
# Extract the mandir from the upstream path
mandir=$(dirname "$manpage_path" | cut -d/ -f3-)
potfile="../templates/$mandir/$manpage.pot"
pofile="$mandir/$manpage.po"
# As there hasn't been a translation yet, the potfile
# has been skipped by "update-templates.sh".
# Therefore, create a potfile now.
po4a-gettextize -f man \
--option groff_code=verbatim \
--option generated \
--option untranslated="a.RE,\|" \
--option unknown_macros=untranslated \
--master "$manpage_path" -M "$coding" \
--po "$potfile"
if [ -f "$potfile" ]; then
# Remove location information
sed -i -e "/^#: /d" "$potfile"
# Ensure the correct encoding is set
sed -i -e "s/^\"Content-Type: text\/plain; charset=CHARSET\\\\n\"$/\"Content-Type: text\/plain; charset=UTF-8\\\\n\"/" \
"$potfile"
fi
# Create the template
cd ../templates
./generate-one-template.sh $manpage
cd ../po
# Ensure that there is a .po file
if [ ! -f $mandir/$manpage.po ]; then
# Create a new .po file
msginit --no-translator --locale="de" -i "$potfile" -o "$pofile"
......@@ -92,7 +53,7 @@ for directory in $directories; do
# 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/^\"Project-Id-Version: manpages-de .*$/\"Project-Id-Version: manpages-de\\\n\"/" "$pofile"
fi
# Finally, populate the translation from the compendium.
./update-po.sh "$pofile"
done
# Finally, populate the translation from the compendium.
./update-po.sh "$pofile"
This diff is collapsed.
......@@ -19,21 +19,25 @@
# upstream manpage, e.g. when a package has been removed.
# Determine directory names from upstream directory.
directories=$(find ../upstream -maxdepth 1 -type d | cut -d/ -f3- | LC_ALL=C sort)
distributions=$(find ../upstream -maxdepth 1 -type d | cut -d/ -f3- | LC_ALL=C sort)
# path to the upstream manpages
upstreamdir="../upstream"
for directory in $directories; do
echo "Processing directory '$directory'"
translations=$(find "$directory"/man* -name "*.po" | LC_ALL=C sort)
for translation in $translations; do
# Find the manpage by removing the .po extension
manpage=$(basename $translation .po)
mandir=$(dirname $translation)
manpage="$upstreamdir/$mandir/$manpage"
if [ ! -f "$manpage" ]; then
echo "No upstream found for '$translation'"
translations=$(find man* -name "*.po" | LC_ALL=C sort)
for translation in $translations; do
found_upstream="no"
# Find the manpage by removing the .po extension
manpage=$(basename $translation .po)
mandir=$(dirname $translation)
for distribution in $distributions; do
upstream_manpage="$upstreamdir/$distribution/$mandir/$manpage"
if [ -f "$upstream_manpage" ]; then
found_upstream="yes"
break
fi
done
if [ $found_upstream = "no" ]; then
echo "No upstream found for '$translation'"
fi
done
#!/bin/sh
#
# Copyright © 2019 Dr. Tobias Quathamer <toddy@debian.org>
#
# 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 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)
potfile=$(find man* -type f -name "$manpage.pot")
# If the file exists, create a backup.
if [ -f "$potfile" ]; then
cp "$potfile" backup.pot
fi
tmp1=$(mktemp)
tmp2=$(mktemp)
# Get the current time to ensure that all potfiles
# have the exact same date and time of creation in the header.
datetime=$(date --iso-8601=minutes | sed -e "s/T/ /")
# Find all upstream manpages with a matching name
potfiles=""
upstream_manpages=$(find ../upstream/*/ -type f -name "$manpage" | LC_ALL=C sort)
if [ -z "$upstream_manpages" ]; then
echo "The manpage '$manpage' could not be found." >&2
exit 1
fi
# Create pot file
echo "Generating pot file for manpage '$manpage'"
for upstream_manpage in $upstream_manpages; do
# Create a template for each distribution
distribution=$(echo $upstream_manpage | cut -d/ -f3)
potfile=$(mktemp --tmpdir "$distribution.$manpage.XXX.pot")
potfiles="$potfiles $potfile"
./generate-template.sh $distribution $manpage > $potfile
# Ensure the same timestamp
if [ -f "$potfile" ]; then
sed -i -e "s/^\"POT-Creation-Date: .*$/\"POT-Creation-Date: $datetime\\\\n\"/" "$potfile"
fi
done
mandir=$(basename $(dirname $upstream_manpage))
# Merge all pot files into one
msgcat -o "$mandir/$manpage.pot" $potfiles
# Remove random characters from multiple file information
# and reformat the comment into something more readable, e.g.:
# "#. #-#-#-#-# archlinux.fclose.3.0bX.pot (PACKAGE VERSION) #-#-#-#-#"
sed -i -e "s/^#\. #-#-#-#-# \([^.]*\)\.\(.\+\)\.[A-Za-z0-9]\{3\}\.pot/#. #-#-#-#-# \1: \2.pot/" "$mandir/$manpage.pot"
# Determine if the only change is the "POT-Creation-Date:" header
# If so, copy back the backup to revert that change
if [ -f "$mandir/$manpage.pot" -a -f "backup.pot" ]; then
sed -f remove-potcdate.sed < "backup.pot" > "$tmp1"
sed -f remove-potcdate.sed < "$mandir/$manpage.pot" > "$tmp2"
if cmp "$tmp1" "$tmp2" >/dev/null 2>&1; then
mv "backup.pot" "$mandir/$manpage.pot"
fi
fi
rm -f $tmp1 $tmp2 backup.pot $potfiles
This diff is collapsed.
......@@ -18,69 +18,13 @@
# Find all translation mandirs
mandirs=$(find ../po -maxdepth 1 -type d -name "man*" | cut -d/ -f3- | LC_ALL=C sort)
# Save old templates for comparing the file contents
mkdir backup
for i in man*/*; do
mv $i backup
done
# Start with clean directories
rm -rf man*
tmp1=$(mktemp)
tmp2=$(mktemp)
for mandir in $mandirs; do
echo Section $mandir
mkdir "$mandir"
# Find all translations of the section
translations=$(find "../po/$mandir" -type f | cut -d/ -f3- | LC_ALL=C sort)
for translation in $translations; do
manpage=$(basename $translation .po)
# Create pot file
echo "Generating pot file for manpage '$manpage'"
# Get the current time to ensure that all potfiles
# have the exact same date and time of creation in the header.
datetime=$(date --iso-8601=minutes | sed -e "s/T/ /")
# Find all upstream manpages with a matching name
potfiles=""
upstream_manpages=$(find ../upstream/*/ -type f -name "$manpage" | LC_ALL=C sort)
for upstream_manpage in $upstream_manpages; do
# Create a template for each distribution
distribution=$(echo $upstream_manpage | cut -d/ -f3)
potfile=$(mktemp --tmpdir "$distribution.$manpage.XXX.pot")
potfiles="$potfiles $potfile"
./generate-template.sh $distribution $manpage > $potfile
# Ensure the same timestamp
if [ -f "$potfile" ]; then
sed -i -e "s/^\"POT-Creation-Date: .*$/\"POT-Creation-Date: $datetime\\\\n\"/" "$potfile"
fi
done
# Merge all pot files into one
msgcat -o "$mandir/$manpage.pot" $potfiles
# Remove random characters from multiple file information
# and reformat the comment into something more readable, e.g.:
# "#. #-#-#-#-# archlinux.fclose.3.0bX.pot (PACKAGE VERSION) #-#-#-#-#"
sed -i -e "s/^#\. #-#-#-#-# \([^.]*\)\.\(.\+\)\.[A-Za-z0-9]\{3\}\.pot/#. #-#-#-#-# \1: \2.pot/" "$mandir/$manpage.pot"
# Determine if the only change is the "POT-Creation-Date:" header
# If so, copy back the backup to revert that change
if [ -f "$mandir/$manpage.pot" -a -f "backup/$manpage.pot" ]; then
sed -f remove-potcdate.sed < "backup/$manpage.pot" > "$tmp1"
sed -f remove-potcdate.sed < "$mandir/$manpage.pot" > "$tmp2"
if cmp "$tmp1" "$tmp2" >/dev/null 2>&1; then
mv "backup/$manpage.pot" "$mandir/$manpage.pot"
fi
fi
./generate-one-template.sh $manpage
done
done
rm -rf backup $tmp1 $tmp2 $potfiles