Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

https://translationproject.org/extra/sendpo.sh #4

Open
asdz520asdz opened this issue Jan 19, 2023 · 0 comments
Open

https://translationproject.org/extra/sendpo.sh #4

asdz520asdz opened this issue Jan 19, 2023 · 0 comments

Comments

@asdz520asdz
Copy link
Owner

"#!/bin/慶典

將給定文件發送到 TP 機器人的腳本。

USERLANG="" # 默認語言代碼,當文件名中沒有時。
STAMP="false" # 是否適配 PO-Revision-Date 字段。

[ -n "$USERLANG" ] || { echo "首先編輯腳本並設置 USERLANG。"; 出口 1;}

[ "$1" == "--now" -o "$1" == "-n" ] && { STAMP="true"; 轉移; }

[ "$1" == "--help" -o "$1" == "-h" -o -z "$1" ] && { echo "
用法:$0 [--now|-n] POFILE

選項 --now 或 -n 將 PO-Revision-Date 設置為當前日期和時間。

POFILE 可以是 <package_name>-..po
或 <package_name>-.po.
"; 退出 1; }

[ -z "$2" ] || { echo "參數太多。"; 出口 1;}

文件=“$1”

[ -f "$文件"] || { echo "沒有這樣的文件:$file"; 出口 1;}

[ "${file##*.}" == "po" ] || { echo "參數不是 *.po 文件。"; 出口 1;}

msgfmt --檢查$文件|| { echo "先修復錯誤。"; 出口 1;}

名稱=${文件##/}
base=${name%.po}
裸=${base%.[[:alpha:]_]
}
lang=${base##*.}

filename不包含默認語言代碼時填寫。

[ "$bare" == "$base" ] && { lang=$USERLANG; name=$bare.$lang.po; }

將 Project-Id-Version 與文件名進行比較。

project=$(sed -n -e '/^"項目-Id-版本:/{
s/.: ([Gg][Nn][Uu] )(.)\n"/\2/
s/ /-/克
p;q;}' $文件)
[ "$name" != "$project.$lang.po" ] && {
echo "Project-Id-Version '${project/-/ }' 與文件名不匹配。"
出口 1;
}

[ "$郵票" == "真"] && {
# 將修訂日期設置為此時此刻。
NEWFIELD="採購訂單修訂日期:$(日期 +"%F %R%z")";
sed -i'' -e "s/^"PO-修訂日期:.*"$/"$NEWFIELD\\n"/" $file;
}

將壓縮的 PO 文件發送給 TP 機器人。

gzip <$文件 | uuencode -m $名稱.gz |
mail -s "TP-robot $name" [email protected]
"
https://translationproject.org/extra/sendpo.sh#:~:text=%23!/bin/%E6%85%B6%E5%85%B8,robot%40translationproject.org

Repository owner locked and limited conversation to collaborators Jan 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant