Commit 4072558e authored by Tobias Quathamer's avatar Tobias Quathamer

Rewrite workflow of scripts and repository

parent 2a3cfa98
# Makefile for manpages-de
#
# Copyright © 2012-2017 Dr. Tobias Quathamer <toddy@debian.org>
# Copyright © 2012-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
......@@ -26,19 +26,12 @@ update-upstream:
git commit -m "Update upstream manpages" || true
# Update all template files from upstream manpages.
# In order to re-use translations from 'primary' for
# the secondary translations before they get overwritten
# by changes to the primary templates, it's needed to
# update all translations (with 'make update-po') first,
# and afterwards update the templates, the common
# templates, and then the translations again.
.PHONY: update-translations
update-translations:
cd $(top_srcdir)/po ; \
$(MAKE) update-po ; \
cd .. ; \
cd $(top_srcdir)/templates ; \
./update-templates.sh ; \
./update-all-templates.sh ; \
git add . ; \
git commit -m "Update templates" || true ; \
./create-common-templates.sh ; \
git add . ; \
git commit -m "Update common templates" || true ; \
......
......@@ -16,7 +16,7 @@
# Makefile for manpages-de
#
# Copyright © 2012-2017 Dr. Tobias Quathamer <toddy@debian.org>
# Copyright © 2012-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
......@@ -259,6 +259,7 @@ build_alias = @build_alias@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
distribution = @distribution@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
......@@ -288,7 +289,6 @@ target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
upstream = @upstream@
SUBDIRS = po
all: all-recursive
......@@ -756,19 +756,12 @@ update-upstream:
git commit -m "Update upstream manpages" || true
# Update all template files from upstream manpages.
# In order to re-use translations from 'primary' for
# the secondary translations before they get overwritten
# by changes to the primary templates, it's needed to
# update all translations (with 'make update-po') first,
# and afterwards update the templates, the common
# templates, and then the translations again.
.PHONY: update-translations
update-translations:
cd $(top_srcdir)/po ; \
$(MAKE) update-po ; \
cd .. ; \
cd $(top_srcdir)/templates ; \
./update-templates.sh ; \
./update-all-templates.sh ; \
git add . ; \
git commit -m "Update templates" || true ; \
./create-common-templates.sh ; \
git add . ; \
git commit -m "Update common templates" || true ; \
......
......@@ -584,7 +584,7 @@ PACKAGE_URL=''
ac_subst_vars='LTLIBOBJS
LIBOBJS
po4a
upstream
distribution
AM_BACKSLASH
AM_DEFAULT_VERBOSITY
AM_DEFAULT_V
......@@ -1289,7 +1289,7 @@ Optional Features:
--disable-silent-rules verbose build output (undo: "make V=0")
--enable-distribution=DIST
Enable translations for specific distribution.
[default=debian].
[default=debian-unstable].
Report bugs to the package provider.
_ACEOF
......@@ -2334,16 +2334,7 @@ fi
if test "${enable_distribution+set}" = set; then :
enableval=$enable_distribution;
else
enable_distribution="debian"
fi
# Handle the distribution and set up the upstream directory name
if test "x$enable_distribution" = "xdebian"; then :
upstream="primary"
else
upstream="secondary-$enable_distribution"
enable_distribution="debian-unstable"
fi
......@@ -2358,7 +2349,7 @@ $as_echo "$enable_distribution" >&6; }
# own translations in an upstream directory
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking that \"$enable_distribution\" has own translations" >&5
$as_echo_n "checking that \"$enable_distribution\" has own translations... " >&6; }
if test -d "upstream/$upstream"; then :
if test -d "upstream/$enable_distribution"; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
else
......@@ -2369,6 +2360,8 @@ $as_echo "no" >&6; }
fi
distribution=$enable_distribution
# Check that po4a is available on the system
# Extract the first word of "po4a", so it can be a program name with args.
......
......@@ -22,21 +22,12 @@ AM_INIT_AUTOMAKE([foreign dist-xz no-dist-gzip])
# Add option for selection of distribution
AC_ARG_ENABLE([distribution],
AS_HELP_STRING([--enable-distribution=DIST],
[Enable translations for specific distribution. @<:@default=debian@:>@.]
[Enable translations for specific distribution. @<:@default=debian-unstable@:>@.]
),
,
[enable_distribution="debian"]
[enable_distribution="debian-unstable"]
)
# Handle the distribution and set up the upstream directory name
AS_IF([test "x$enable_distribution" = "xdebian"],
dnl Special case: Debian uses the name "primary".
[upstream="primary"],
dnl All other cases: Prepend "secondary-" to the name.
[upstream="secondary-$enable_distribution"]
)
AC_SUBST([upstream])
# Show the wanted distribution
AC_MSG_CHECKING([name of wanted distribution])
AC_MSG_RESULT([$enable_distribution])
......@@ -44,13 +35,14 @@ AC_MSG_RESULT([$enable_distribution])
# Check if the wanted distribution has
# own translations in an upstream directory
AC_MSG_CHECKING([that "$enable_distribution" has own translations])
AS_IF([test -d "upstream/$upstream"],
AS_IF([test -d "upstream/$enable_distribution"],
[AC_MSG_RESULT([yes])],
[
AC_MSG_RESULT([no])
AC_MSG_ERROR([there are no translations for "$enable_distribution".])
]
)
AC_SUBST([distribution], [$enable_distribution])
# Check that po4a is available on the system
AC_PATH_PROG([po4a], [po4a], [no])
......
#!/bin/sh
#
# Copyright © 2017 Dr. Tobias Quathamer <toddy@debian.org>
# Copyright © 2017-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
......@@ -23,14 +23,14 @@ if [ -z "$distribution" ]; then
fi
# Safety net
if [ -d "upstream/secondary-$distribution" ]; then
if [ -d "upstream/$distribution" ]; then
echo "The distribution '$distribution' already exists."
exit
fi
# Create the upstream directory
mkdir "upstream/secondary-$distribution"
cd "upstream/secondary-$distribution"
mkdir "upstream/$distribution"
cd "upstream/$distribution"
touch links.txt
touch update-manpages.sh
chmod +x update-manpages.sh
......@@ -40,7 +40,7 @@ git commit -m "Add skeleton for new distribution '$distribution'"
echo "Done."
echo "Please edit this script:"
echo
echo " upstream/secondary-$distribution/update-manpages.sh"
echo " upstream/$distribution/update-manpages.sh"
echo
echo "See upstream/README.md for details."
echo "When ready, run the second part of this setup script."
#!/bin/sh
#
# Copyright © 2017 Dr. Tobias Quathamer <toddy@debian.org>
# Copyright © 2017-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
......@@ -23,7 +23,7 @@ if [ -z "$distribution" ]; then
fi
# Safety net
if [ ! -d "upstream/secondary-$distribution" ]; then
if [ ! -d "upstream/$distribution" ]; then
echo "The distribution '$distribution' does not exist."
echo "Please start with the first part of this script."
exit
......@@ -31,7 +31,7 @@ fi
# Make sure that the update-manpages.sh script has been run
# Start with clean directories and no leftover links.txt
cd "upstream/secondary-$distribution"
cd "upstream/$distribution"
rm -rf man* links.txt
./update-manpages.sh
# Sort the file links.txt
......@@ -43,46 +43,22 @@ git add .
git commit -m "Add manpages for '$distribution'"
cd ../..
# Create the po directory
cd "po"
mkdir "secondary-$distribution"
cp -r primary/* secondary-$distribution
git add secondary-$distribution
git commit -m "Copy all translations from primary to secondary-$distribution"
cd ..
# Create the templates directory
# Create the templates
cd "templates"
mkdir "secondary-$distribution"
./update-templates.sh
if [ ! -d "common-secondary" ]; then
# Create a new secondary directory from primary
mkdir "common-secondary"
cp common-primary/* common-secondary
fi
./update-all-templates.sh
git add man*
git commit -m "Add templates for new distribution '$distribution'"
./create-common-templates.sh
git add common-secondary/*
git add common/*
git commit -m "Add common templates for new distribution '$distribution'"
cd ..
# Create the common po directory
# Update po files
cd "po"
if [ ! -d "common-secondary" ]; then
# Create a new secondary directory from primary
mkdir "common-secondary"
cp common-primary/* common-secondary
fi
compendium=$(mktemp)
msgcat secondary-$distribution/man*/*po > "$compendium"
for pofile in common-secondary/*po; do
# Find the pot file by adding the letter 't'
potfile="../templates/$pofile""t"
msgmerge --previous --compendium "$compendium" "$pofile" "$potfile" > tmp.po
# Remove obsolete strings
msgattrib --force-po --no-obsolete tmp.po > "$pofile"
done
git add common-secondary
git commit -m "Fill up common translations from manpages"
rm -f "$compendium" tmp.po
./update-translations.sh
git add man*
git commit -m "Update .po files for new distribution '$distribution'"
./update-common.sh
git add common/*
git commit -m "Update common .po files for new distribution '$distribution'"
cd ..
# Makefile for manpages-de
#
# Copyright © 2017 Dr. Tobias Quathamer <toddy@debian.org>
# Copyright © 2017-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
......@@ -15,47 +15,40 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Use only primary and secondary with [ps] selection,
# in order to filter out the common-* directories
pofiles = $(sort $(wildcard $(srcdir)/[ps]*/man*/*.po))
# Filter out the 'common' directory
pofiles = $(sort $(wildcard $(srcdir)/man*/*.po))
manpages = $(patsubst %.po,%, $(pofiles))
current_pofiles = $(sort $(wildcard $(srcdir)/$(upstream)/man*/*.po))
current_manpages = $(patsubst %.po,%, $(current_pofiles))
MOSTLYCLEANFILES = $(manpages)
# Common rules for all manpage sections
%: %.po
$(srcdir)/generate-manpage.sh $@
$(srcdir)/generate-manpage.sh $(distribution) $@
# Generate all localized manpages for given distribution
all-local: $(current_manpages)
# Generate all manpages for every distribution
all-manpages: $(manpages)
all-local: $(manpages)
# Install localized manpages for given distribution
install-data-hook: $(current_manpages)
for directory in $(srcdir)/$(upstream)/man*; do \
install-data-hook: $(manpages)
for directory in $(srcdir)/$(distribution)/man*; do \
mansection=$$(basename $$directory) ; \
$(mkinstalldirs) $(DESTDIR)$(mandir)/de/$$mansection ; \
done
for manpage in $(current_manpages); do \
for manpage in $(manpages); do \
filename=$$(basename $$manpage) ; \
mansection=$$(basename $$(dirname $$manpage)) ; \
$(INSTALL_DATA) $$manpage $(DESTDIR)$(mandir)/de/$$mansection ; \
gzip --best $(DESTDIR)$(mandir)/de/$$mansection/$$filename ; \
done
perl $(top_srcdir)/create-links.pl $(DESTDIR)$(mandir)/de \
$(top_srcdir)/upstream/$(upstream)/links.txt
$(top_srcdir)/upstream/$(distribution)/links.txt
# Uninstall localized manpages for given distribution
uninstall-hook:
for link in $$(cut -d" " -f2 $(top_srcdir)/upstream/$(upstream)/links.txt); do \
for link in $$(cut -d" " -f2 $(top_srcdir)/upstream/$(distribution)/links.txt); do \
rm -f $(DESTDIR)$(mandir)/de/$$link ; \
done
for manpage in $(current_manpages); do \
for manpage in $(manpages); do \
filename=$$(basename $$manpage) ; \
mansection=$$(basename $$(dirname $$manpage)) ; \
rm -f $(DESTDIR)$(mandir)/de/$$mansection/$$filename.gz ; \
......
......@@ -16,7 +16,7 @@
# Makefile for manpages-de
#
# Copyright © 2017 Dr. Tobias Quathamer <toddy@debian.org>
# Copyright © 2017-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
......@@ -179,6 +179,7 @@ build_alias = @build_alias@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
distribution = @distribution@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
......@@ -208,14 +209,10 @@ target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
upstream = @upstream@
# Use only primary and secondary with [ps] selection,
# in order to filter out the common-* directories
pofiles = $(sort $(wildcard $(srcdir)/[ps]*/man*/*.po))
# Filter out the 'common' directory
pofiles = $(sort $(wildcard $(srcdir)/man*/*.po))
manpages = $(patsubst %.po,%, $(pofiles))
current_pofiles = $(sort $(wildcard $(srcdir)/$(upstream)/man*/*.po))
current_manpages = $(patsubst %.po,%, $(current_pofiles))
MOSTLYCLEANFILES = $(manpages)
all: all-am
......@@ -408,35 +405,32 @@ uninstall-am:
# Common rules for all manpage sections
%: %.po
$(srcdir)/generate-manpage.sh $@
$(srcdir)/generate-manpage.sh $(distribution) $@
# Generate all localized manpages for given distribution
all-local: $(current_manpages)
# Generate all manpages for every distribution
all-manpages: $(manpages)
all-local: $(manpages)
# Install localized manpages for given distribution
install-data-hook: $(current_manpages)
for directory in $(srcdir)/$(upstream)/man*; do \
install-data-hook: $(manpages)
for directory in $(srcdir)/$(distribution)/man*; do \
mansection=$$(basename $$directory) ; \
$(mkinstalldirs) $(DESTDIR)$(mandir)/de/$$mansection ; \
done
for manpage in $(current_manpages); do \
for manpage in $(manpages); do \
filename=$$(basename $$manpage) ; \
mansection=$$(basename $$(dirname $$manpage)) ; \
$(INSTALL_DATA) $$manpage $(DESTDIR)$(mandir)/de/$$mansection ; \
gzip --best $(DESTDIR)$(mandir)/de/$$mansection/$$filename ; \
done
perl $(top_srcdir)/create-links.pl $(DESTDIR)$(mandir)/de \
$(top_srcdir)/upstream/$(upstream)/links.txt
$(top_srcdir)/upstream/$(distribution)/links.txt
# Uninstall localized manpages for given distribution
uninstall-hook:
for link in $$(cut -d" " -f2 $(top_srcdir)/upstream/$(upstream)/links.txt); do \
for link in $$(cut -d" " -f2 $(top_srcdir)/upstream/$(distribution)/links.txt); do \
rm -f $(DESTDIR)$(mandir)/de/$$link ; \
done
for manpage in $(current_manpages); do \
for manpage in $(manpages); do \
filename=$$(basename $$manpage) ; \
mansection=$$(basename $$(dirname $$manpage)) ; \
rm -f $(DESTDIR)$(mandir)/de/$$mansection/$$filename.gz ; \
......
#!/bin/sh
#
# Copyright © 2017 Dr. Tobias Quathamer <toddy@debian.org>
# Copyright © 2017-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
......@@ -15,18 +15,17 @@
# 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 there's a commandline argument, it's the upstream directory.
if [ "$1" ]; then
directories="$1"
else
# Determine directory names from upstream directory.
directories=$(find ../upstream -maxdepth 1 -type d | cut -d/ -f3- | LC_ALL=C sort)
# Require distribution name
if [ -z "$1" ]; then
echo "Please specify the distribution." >&2
exit 1
fi
distribution=$1
for directory in $directories; do
echo "Processing directory '$directory'"
translations=$(find "$directory"/man* -name "*.po" | LC_ALL=C sort)
for translation in $translations; do
./generate-manpage.sh "$translation"
done
echo "Processing distribution '$distribution'"
manpages=$(find "../upstream/$distribution"/man* -type f | cut -d/ -f4- | LC_ALL=C sort)
for manpage in $manpages; do
if [ -f "$manpage.po" ]; then
./generate-manpage.sh $distribution "$manpage"
fi
done
#!/bin/sh
#
# Copyright © 2017 Dr. Tobias Quathamer <toddy@debian.org>
# Copyright © 2017-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
......@@ -24,10 +24,6 @@ if [ -z "$2" ]; then
echo "Specify the compendium filename."
exit 1
fi
if [ -z "$3" ]; then
echo "Specify the level."
exit 1
fi
# Extract header entry for compendium (first line until first blank line)
header=$(mktemp)
......@@ -35,11 +31,7 @@ sed -n "1,/^$/p" "$1" > "$header"
# Join all files into one compendium
giant=$(mktemp)
if [ "$3" = "secondary" ]; then
msgcat common-primary/*po common-secondary/*po > "$giant"
else
msgcat common-primary/*po > "$giant"
fi
msgcat common/*po > "$giant"
# Remove untranslated and fuzzy entries
tmpcompendium=$(mktemp)
......@@ -47,4 +39,4 @@ msgattrib --translated --no-fuzzy "$giant" > "$tmpcompendium"
# Create a custom compendium with the header from the translation
msgcat --use-first "$header" "$tmpcompendium" > "$2"
rm -f "$giant" "$tmpcompendium"
rm -f "$header" "$giant" "$tmpcompendium"
#!/bin/sh
#
# Copyright © 2010-2017 Dr. Tobias Quathamer <toddy@debian.org>
# 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
......@@ -15,18 +15,21 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# This is the distribution for which the manpage should be generated
distribution="$1"
# This is the filename of the localized manpage
localized="$1"
localized="$2"
# If the filename ends with ".po", remove that part.
localized=$(echo "$1" | sed -e "s/\.po$//")
localized=$(echo "$localized" | sed -e "s/\.po$//")
# Set up the path to the original manpage
master="../upstream/$localized"
master="../upstream/$distribution/$localized"
# Cannot generate manpage if the original could not be found
if [ ! -f "$master" ]; then
echo "The original manpage for '$localized' could not be found." >&2
echo "The original manpage for '$localized' could not be found in '$distribution'." >&2
exit
fi
......@@ -40,10 +43,21 @@ fi
# Set up the filename of the translation
translation="$localized.po"
# Append the output directory
localized="$distribution/$localized"
# Create the addendum for this manpage
addendum=$(mktemp)
./generate-addendum.sh "$translation" "$addendum"
# Create a separate .po file for this distribution,
# otherwise po4a will emit really a lot of warnings
# about an outdated translation, because the number
# of translations in the (internally generated) pot
# and po file do not match.
pofile=$(mktemp)
msggrep --location="$distribution" $translation > $pofile
# Actual translation
po4a-translate \
-f man \
......@@ -53,7 +67,7 @@ po4a-translate \
--option unknown_macros=untranslated \
-m "$master" \
-M "$coding" \
-p "$translation" \
-p "$pofile" \
-a "$addendum" \
-a "../lizenz.add" \
-L UTF-8 \
......@@ -75,3 +89,5 @@ if [ -f "$localized" ]; then
mv "$manpage" "$localized"
rm "$encoding"
fi
rm -f "$addendum" "$pofile"
#!/bin/sh
#
# Copyright © 2010-2017 Dr. Tobias Quathamer <toddy@debian.org>
# Copyright © 2010-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
......@@ -28,10 +28,6 @@ templatedir="../templates"
potfile="$templatedir/$1""t"
if [ ! -f "$potfile" ]; then
echo "The potfile '$potfile' could not be found." >&2
echo >&2
echo "Please go to the templates directory and run './update-templates.sh'." >&2
echo "$ cd ../templates" >&2
echo "$ ./update-templates.sh" >&2
exit 1
fi
......@@ -39,12 +35,9 @@ fi
backup=$(mktemp)
cp "$1" "$backup"
# Determine the translation level, primary or secondary
level=$(echo "$1" | cut -d/ -f1 | cut -d- -f1)
# Generate compendium
compendium=$(mktemp)
./generate-compendium.sh "$1" "$compendium" "$level"
./generate-compendium.sh "$1" "$compendium"
# Update .po file from .pot file
tmppo=$(mktemp)
......@@ -55,29 +48,9 @@ msgattrib --no-obsolete "$tmppo" > "$1"
# Translate dates, if possible
./translate-dates.pl < "$1" > "$tmppo"
mv "$tmppo" "$1"
# If this is a secondary translation, use the primary .po
# file as a reference, too. This way, typo fixes and better
# wordings in the primary translation will automatically
# migrate to all secondary translations.
if [ "x$level" = "xsecondary" ]; then
# Construct the path by removing the first directory
primary=$(echo "$1" | cut -d/ -f2-)
primary="primary/$primary"
# Make sure the corresponding file in primary exists,
# otherwise msgmerge will fail and then remove the
# .po file which should be updated.
if [ -f "$primary" ]; then
# Prefer the translations from the primary .po file
msgmerge --previous --compendium "$primary" --no-fuzzy-matching /dev/null "$1" > "$tmppo"
mv "$tmppo" "$1"
fi
fi
# Prefer the translations from the compendium
msgmerge --compendium "$compendium" --no-fuzzy-matching /dev/null "$1" > "$tmppo"
mv "$tmppo" "$1"
msgmerge --compendium "$compendium" --no-fuzzy-matching /dev/null "$tmppo" > "$1"
# Determine if the only change is the "POT-Creation-Date:" header
# If so, copy back the backup to revert that change
......
......@@ -15,14 +15,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# 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
echo "Processing directory '$directory'"
translations=$(find "$directory"/man* -name "*.po" | LC_ALL=C sort)
for translation in $translations; do
echo $(basename "$translation")
./update-po.sh "$translation"
done
translations=$(find man* -name "*.po" | LC_ALL=C sort)
for translation in $translations; do
echo $(basename "$translation")
./update-po.sh "$translation"
done
#!/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
......@@ -15,9 +15,24 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Clean all generated files
rm -f *html
# Create header, using MET/MEST
timestamp=$(TZ='Europe/Berlin' date "+%d.%m.%Y, %H:%M Uhr")
cat<<-END_OF_HEADER
# Determine distribution names from upstream directory.
distributions=$(find ../upstream -maxdepth 1 -type d | cut -d/ -f3 | LC_ALL=C sort)
distribution_count=$(echo "$distributions" | wc --words)
# Determine manpage section names
manpage_sections=$(find ../po/man* -maxdepth 1 -type d | cut -d/ -f3 | LC_ALL=C sort)
# Use a tempfile for stats generation
tmppo=$(mktemp)
# Create the index file
cat > index.html <<-END_OF_HEADER
<!doctype html>
<html lang="en">
<head>
......@@ -27,119 +42,114 @@ cat<<-END_OF_HEADER
<title>Deutsche Übersetzung der Handbuchseiten</title>
</head>
<body>
<div class="container-fluid">
<div class="container-fluid">
<h1>Liste der Dateien, die nicht vollständig übersetzt sind</h1>
<p>Stand: $timestamp</p>
<p>
<a class="btn btn-primary" href="https://salsa.debian.org/manpages-de-team/manpages-de">Git-Repository ansehen</a>
</p>
END_OF_HEADER
# Determine directory names from upstream directory.
directories=$(find ../upstream -maxdepth 1 -type d | cut -d/ -f3- | LC_ALL=C sort)
# Set up files for each distribution
for distribution in $distributions; do
echo "<p><a class=\"btn btn-primary\" href=\"$distribution.html\">$distribution</a></p>" >> index.html
total_count=0
for directory in $directories; do
echo "<h2>Distribution: $directory</h2>"
distribution_count=0
previous_section=""
section_count=0
translations_tmp=$(find "../po/$directory"/man* -name "*.po" | LC_ALL=C sort)
translations="$translations_tmp ../po/$directory/man1/cat.1.po"
for translation in $translations; do
man_name=$(basename $translation)
man_section=$(echo "$translation" | cut -d/ -f4)
if [ "$previous_section" != "$man_section" ]; then
# We start a new man section, so create a new table
if [ $section_count -gt 0 ]; then
cat<<-EOF_TABLE
<table class="table table-striped table-bordered table-sm">
<thead class="thead-dark">
<tr>
<th scope="col" width="25%">Name</th>
<th scope="col" width="10%">Prozent</th>
<th scope="col" width="15%">Übersetzungen bis 80%</th>
<th scope="col" width="50%">Statistik</th>
</tr>
</thead>
<tbody>
EOF_TABLE
echo $section_table_rows
echo "</tbody>"
echo "</table>"
echo '<div class="alert alert-primary" role="alert">'
if [ $section_count -eq 1 ]; then
echo "1 Datei ist nicht vollständig übersetzt."
else
echo "$section_count Dateien sind nicht vollständig übersetzt."
fi
echo "</div>"
fi
distribution_count=$(($distribution_count+$section_count))
previous_section=$man_section
section_table_rows=""
section_count=0
fi
# Determine the stats
stats=$(msgfmt -cv -o /dev/null $translation 2>&1)
fuzzy_or_untranslated=$(echo $stats | grep "[0-9]\+[^0-9]\+[0-9]\+")
if [ -n "$fuzzy_or_untranslated" ]; then
# Remove the last text part
all=$(echo $stats | sed -e "s/[^0-9]\+$//")
# Replace all remaining text parts with the plus sign
all=$(echo $all | sed -e "s/[^0-9]\+/+/g")