Skip to content

Commit 57b6844

Browse files
authored
Merge pull request #958 from Divyansh013/action-only-clean
[GSOC 2025] Translation Tracker github action
2 parents e1d02aa + 9e455ab commit 57b6844

File tree

6 files changed

+1422
-0
lines changed

6 files changed

+1422
-0
lines changed
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
# p5.js Translation Tracker
2+
3+
Automatically tracks translation status for p5.js website examples, creates GitHub issues for outdated translations, and shows banners on the website.
4+
5+
## Features
6+
7+
- Detects outdated/missing translations using Git commit comparison (currently focused on Examples content)
8+
- Creates GitHub issues with diff snippets and action checklists
9+
- Shows localized banners on outdated translation pages
10+
- Supports Spanish, Hindi, Korean, and Chinese Simplified
11+
12+
## File Structure
13+
14+
```
15+
.github/actions/translation-tracker/
16+
β”œβ”€β”€ index.js # Main tracker logic
17+
β”œβ”€β”€ package.json # Dependencies
18+
β”œβ”€β”€ test-local.js # Local testing
19+
20+
src/layouts/ExampleLayout.astro # Banner integration
21+
src/components/OutdatedTranslationBanner/ # Banner component
22+
public/translation-status/examples.json # Generated status (build artifact)
23+
```
24+
25+
## Usage
26+
27+
### Local Testing
28+
```bash
29+
cd .github/actions/translation-tracker && npm install
30+
node test-local.js
31+
```
32+
33+
### Scan All Files (File-based)
34+
```bash
35+
node .github/actions/translation-tracker/index.js
36+
```
37+
38+
### Scan All Files (GitHub API + Create Issues)
39+
```bash
40+
GITHUB_TOKEN=your_token GITHUB_REPOSITORY=owner/repo node .github/actions/translation-tracker/index.js
41+
```
42+
43+
### GitHub Actions Workflow
44+
Create `.github/workflows/translation-sync.yml`:
45+
46+
```yaml
47+
name: Translation Sync Tracker
48+
49+
on:
50+
push:
51+
branches: [main, week2]
52+
paths: ['src/content/examples/en/**']
53+
workflow_dispatch:
54+
55+
jobs:
56+
track-translation-changes:
57+
runs-on: ubuntu-latest
58+
steps:
59+
- name: Checkout repository
60+
uses: actions/checkout@v4
61+
with:
62+
fetch-depth: 2
63+
64+
- name: Setup Node.js
65+
uses: actions/setup-node@v4
66+
with:
67+
node-version: '18'
68+
69+
- name: Install dependencies
70+
run: npm ci
71+
72+
- name: Install translation tracker dependencies
73+
run: cd .github/actions/translation-tracker && npm install
74+
75+
- name: Run translation tracker
76+
env:
77+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
78+
run: node .github/actions/translation-tracker/index.js
79+
```
80+
81+
## Environment Variables
82+
83+
- `GITHUB_TOKEN` - Required for GitHub API and issue creation
84+
- `GITHUB_REPOSITORY` - Format: `owner/repo` (auto-detected in Actions)
85+
86+
## What It Does
87+
88+
1. **Scans** English example files for changes
89+
2. **Compares** with translation files using Git commits
90+
3. **Creates** GitHub issues for outdated translations with:
91+
- Diff snippets showing what changed
92+
- Links to files and comparisons
93+
- Action checklist for translators
94+
- Proper labels (`needs translation`, `lang-es`, etc.)
95+
4. **Generates** manifest file for website banner system
96+
5. **Shows** localized banners on outdated translation pages
97+
98+
## Sample Output
99+
100+
```
101+
πŸ“ Checking 61 English example file(s)
102+
103+
πŸ“Š Translation Status Summary:
104+
πŸ”„ Outdated: 48
105+
❌ Missing: 0
106+
βœ… Up-to-date: 196
107+
108+
🎫 GitHub issues created: 12
109+
- Issue #36: Spanish, Hindi, Korean, Chinese Simplified need updates
110+
- URL: https://github.com/owner/repo/issues/36
111+
112+
πŸ—‚οΈ Wrote translation manifest: public/translation-status/examples.json
113+
```
114+
115+
## Dependencies
116+
117+
- `@actions/core`, `@actions/github`, `@octokit/rest`
118+
- Node.js built-ins: `fs`, `path`, `child_process`

0 commit comments

Comments
Β (0)