include translation status check
This commit is contained in:
parent
4e64bdfa22
commit
bbfdc9012e
|
@ -54,6 +54,10 @@ fi
|
|||
A=$(echo "$FILE" | sed -E "s/\.[a-z][a-z]\.$EXT//")
|
||||
# get change date of English file
|
||||
EN=$A.en.$EXT
|
||||
if [ ! -e "$EN" ]; then
|
||||
out "English file does not exist. Aborting. ($EN)"
|
||||
exit 2
|
||||
fi
|
||||
endate=$(git log --pretty="%cd" --date=raw -1 "$EN"|cut -d' ' -f1)
|
||||
# Convert to YYYY-MM-DD
|
||||
ymd=$(date +"%Y-%m-%d" --date="@$endate")
|
||||
|
|
|
@ -1,15 +1,29 @@
|
|||
#!/bin/bash
|
||||
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||
|
||||
# Select files
|
||||
#FILES=$(git grep -i -l "<\?xml.*encoding=\"iso" .)
|
||||
FILES=$(find . -type f)
|
||||
|
||||
while read -r file; do
|
||||
enc=$(file --mime-encoding ${file} | cut -d" " -f2)
|
||||
# Only run if not correct encoding, and if XML, XHTML, or XSL file
|
||||
if [ "${enc}" != "utf-8" ] && [ "${enc}" != "us-ascii" ] && [ $(echo $file | grep -qoE "(\.xml$|\.xhtml$|\.xsl$)"; echo $?) -eq 0 ]; then
|
||||
iconv -f ${enc} -t UTF-8 ${file} -o ${file}.utf8
|
||||
sed -Ei "s@(<?xml.*)($enc|iso-8859-1|iso-8859-2|iso8859-1)@\1UTF-8@I" ${file}.utf8
|
||||
mv ${file}.utf8 ${file}
|
||||
enc_new=$(file --mime-encoding ${file} | cut -d" " -f2)
|
||||
echo "Converted $file from $enc to $enc_new"
|
||||
# Only run if file is not outdated
|
||||
trstatus=$(tools/check-translation-status.sh -f "$file" -q; echo $?)
|
||||
if [ $trstatus = 0 ]; then
|
||||
# Convert to UTF-8
|
||||
iconv -f ${enc} -t UTF-8 ${file} -o ${file}.utf8
|
||||
# Replace XML encoding in first line
|
||||
sed -Ei "s@^<\?xml.*($enc|iso-8859-1|iso-8859-2|iso8859-1).*@<?xml version=\"1.0\" encoding=\"UTF-8\" ?>@I" ${file}.utf8
|
||||
# Move edited file to original location
|
||||
mv ${file}.utf8 ${file}
|
||||
# Status report
|
||||
enc_new=$(file --mime-encoding ${file} | cut -d" " -f2)
|
||||
echo "Converted $file from $enc to $enc_new"
|
||||
elif [ $trstatus = 1 ]; then
|
||||
echo "WARNING: $file is outdated"
|
||||
fi
|
||||
fi
|
||||
done <<< "${FILES}"
|
||||
|
|
Caricamento…
Fai riferimento in un nuovo problema