extract translation from git diff
#!/bin/bash
# 从 git diff 中提取所有新增的翻译字符串
git diff | grep "^+" | perl -ne 'while (/[{]?t\((["'\''\`])([^"'\''`]+)\1\)[}]?/g) { print "$2\n" }' | sort -u
# 如果要查看暂存区的变动:
# git diff --cached | grep "^+" | perl -ne 'while (/[{]?t\((["'\''\`])([^"'\''`]+)\1\)[}]?/g) { print "$2\n" }' | sort -u
#!/bin/bash
# 创建或清空 CSV 文件,添加表头
echo "key,en,zh" >translation.csv
# 从 git diff 中提取所有新增的翻译字符串并写入 CSV
git diff | grep "^+" | perl -ne 'while (/[{]?t\((["'\''\`])([^"'\''`]+)\1\)[}]?/g) { print "$2\n" }' | sort -u | while read -r key; do
# 将每个 key 写入 CSV,预留英文和中文翻译的列
echo "$key,," >>translation.csv
done
echo "翻译键已提取到 translation.csv 文件中。"
echo "请使用翻译脚本填充英文和中文翻译。"