DAILY DOCDAILY DOC
Rust
Node
Notes
Ubuntu
Leetcode
  • it-tools
  • excalidraw
  • linux-command
Rust
Node
Notes
Ubuntu
Leetcode
  • it-tools
  • excalidraw
  • linux-command
  • linux
  • bash alias
  • chmod
  • linux useful command
  • date
  • extract translation from git diff
  • fail2ban
  • globbing
  • localhost
  • mail
  • memo 内存测试
  • nohup(no hang up)
  • setup env
  • ssh

    • ssh 教程
    • github clone
    • ssh.localhost.run 端口转发
    • ssh 安全
  • systemd service
  • 分析ubuntu系统登录日志文件
  • vpn

    • vpn 教程
    • Algo
    • clashX
    • firezone
    • lantern
    • pac 代理配置
    • Setup vpn
    • shadowsocks
    • VPN
    • VPN 速度优化
    • wireguard cron
    • 修改wireguard端口
  • webhook

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 "请使用翻译脚本填充英文和中文翻译。"
Last Updated:
Contributors: rosendo
Prev
date
Next
fail2ban