feat: add workflow to check for missing i18n keys in translation files
This commit is contained in:
57
.github/workflows/i18n-check.yaml
vendored
Normal file
57
.github/workflows/i18n-check.yaml
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
name: Check Missing i18n Keys
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- "src/locales/en.json"
|
||||
- "src/locales/*.json"
|
||||
- ".github/workflows/i18n-check.yml"
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
check-i18n:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
|
||||
- name: Install jq
|
||||
run: sudo apt-get install -y jq
|
||||
|
||||
- name: Check missing i18n keys
|
||||
id: check-missing
|
||||
run: |
|
||||
mkdir -p i18n-missing
|
||||
EN_KEYS=$(jq -r 'keys[]' src/locales/en.json | sort)
|
||||
for file in src/locales/*.json; do
|
||||
[ "$file" = "src/locales/en.json" ] && continue
|
||||
LANG=$(basename "$file" .json)
|
||||
jq -r 'keys[]' "$file" | sort > tmp_keys.txt
|
||||
comm -23 <(echo "$EN_KEYS") tmp_keys.txt > i18n-missing/$LANG.txt || true
|
||||
if [ -s i18n-missing/$LANG.txt ]; then
|
||||
echo "Missing keys in $LANG:"
|
||||
cat i18n-missing/$LANG.txt
|
||||
fi
|
||||
done
|
||||
|
||||
- name: Create PR if missing keys found
|
||||
uses: peter-evans/create-pull-request@v6
|
||||
if: |
|
||||
always() && (hashFiles('i18n-missing/*.txt') != '')
|
||||
with:
|
||||
commit-message: "chore(i18n): report missing translation keys"
|
||||
title: "chore(i18n): report missing translation keys"
|
||||
body: |
|
||||
The following language files are missing keys compared to en.json:
|
||||
|
||||
${{ steps.check-missing.outputs.summary }}
|
||||
|
||||
Each file in `i18n-missing/` lists the missing keys for that language.
|
||||
branch: i18n/missing-keys-report
|
||||
add-paths: |
|
||||
i18n-missing/*.txt
|
||||
Reference in New Issue
Block a user