瀏覽代碼

include translation status check

pull/918/head
Max Mehl 6 月之前
父節點
當前提交
bbfdc9012e
簽署人: max.mehl <max.mehl@fsfe.org> GPG Key ID: 2704E4AB371E2E92
共有 2 個文件被更改,包括 23 次插入5 次删除
  1. 4
    0
      tools/check-translation-status.sh
  2. 19
    5
      tools/encoding-convert.sh

+ 4
- 0
tools/check-translation-status.sh 查看文件

@@ -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")

+ 19
- 5
tools/encoding-convert.sh 查看文件

@@ -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}"

Loading…
取消
儲存