#974 WIP: Use sidecar files for identifying outdated translations

Atvērta
ulf vēlas sapludināt 6 revīzijas no ulf/fsfe-website:fix#64_2 uz master

+ 1
- 0
.gitignore Parādīt failu

@@ -6,6 +6,7 @@ d_day.en.xml
tools/.texts-??.xml
.fundraising.??.xml
.*.xmllist
.*.outdated-translations
tags/tagged-*.en.xhtml
tags/.tags.??.xml
events/????/index.??.xhtml

+ 18
- 0
Makefile Parādīt failu

@@ -172,3 +172,21 @@ default_xsl:
all: xmllists
xmllists: $(SUBDIRS)
tools/update_xmllists.sh


# -----------------------------------------------------------------------------
# Update sidecar files with outdated translations
# -----------------------------------------------------------------------------

# For each en.xhtml file write its outdated translations into a
# sidecar file (e.g. "about/.about.en.xhtml.outdated-translations").

SIDECAR_FILES := $(shell find . -name '*.en.xhtml' | grep -v ./tags | sort | sed 's,\(.*/\)\(.*\),\1.\2.outdated-translations,g')

.PHONY: outdatedtranslations
all: outdatedtranslations $(SIDECAR_FILES)
outdatedtranslations:
echo "* Updating lists of outdated files"
.%.en.xhtml.outdated-translations: %.??.xhtml
echo "* Updating $@"
tools/find-outdated-translations "$<" > "$@"

+ 1
- 0
build/makerules.sh Parādīt failu

@@ -203,6 +203,7 @@ COPY_SRC_FILES := \$(shell find "\$(INPUTDIR)" -type f \
-not -name '*.xhtml' \
-not -name '*.xml' \
-not -name '*.xsl' \
-not -name '*.outdated-translations' \
)

# The same as above, but moved to the output directory

+ 9
- 2
build/scaffold.sh Parādīt failu

@@ -23,8 +23,15 @@ build_xmlstream(){
outdated=no

if [ -f "${shortname}.${lang}.xhtml" ]; then
act_lang="$lang"
[ "${shortname}.${olang}.xhtml" -nt "${shortname}.${lang}.xhtml" ] && outdated=yes
act_lang="$lang"
basename=${shortname/*\/}
outdatedtranslations="${dirname}.${basename}.en.xhtml.outdated-translations"
if [ -f "${outdatedtranslations}" ]; then
grep -q "${lang}.xhtml" "${outdatedtranslations}" && outdated=yes
else
echo "* Sidecar file ${outdatedtranslations} is missing" >&2
[ "${shortname}.${olang}.xhtml" -nt "${shortname}.${lang}.xhtml" ] && outdated=yes
fi
else
act_lang="$olang"
fi

+ 23
- 0
tools/find-outdated-translations Parādīt failu

@@ -0,0 +1,23 @@
#!/usr/bin/env bash

# Find outdated translations for the given file.

# File must have extension ".??.xhtml". All files with the same
# basename and the same extension pattern that are newer than the
# given one, according to git commit date, are returned.

filename=$1
bn=${filename%.??.xhtml}
siblings=`ls ${bn}.??.xhtml`
translations=${siblings/${filename}}
if [ ! -z "$translations" ]; then
outdated="${translations}"
ct=`git log -1 --format="%ct" "$filename"`
updatedfiles=`git log --since=$ct --format="%ct" --name-only "${bn}.??.xhtml" | grep xhtml | sort -u`
if [ ! -z "$updatedfiles" ]; then
for u in ${updatedfiles}; do
outdated=${outdated/*$u}
done
fi
echo $outdated
fi

Notiek ielāde…
Atcelt
Saglabāt