Skip to content

[GSOC 2025]: Github action for translation tracker #895

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

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
118 changes: 118 additions & 0 deletions .github/actions/translation-tracker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
# p5.js Translation Tracker

Automatically tracks translation status for p5.js website examples, creates GitHub issues for outdated translations, and shows banners on the website.

## Features

- Detects outdated/missing translations using Git commit comparison
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very minor: add a note here please that it currently focuses on Examples content

- Creates GitHub issues with diff snippets and action checklists
- Shows localized banners on outdated translation pages
- Supports Spanish, Hindi, Korean, and Chinese Simplified

## File Structure

```
.github/actions/translation-tracker/
├── index.js # Main tracker logic
├── package.json # Dependencies
├── test-local.js # Local testing

src/layouts/ExampleLayout.astro # Banner integration
src/components/OutdatedTranslationBanner/ # Banner component
public/translation-status/examples.json # Generated status (build artifact)
```

## Usage

### Local Testing
```bash
cd .github/actions/translation-tracker && npm install
node test-local.js
```

### Scan All Files (File-based)
```bash
node .github/actions/translation-tracker/index.js
```

### Scan All Files (GitHub API + Create Issues)
```bash
GITHUB_TOKEN=your_token GITHUB_REPOSITORY=owner/repo node .github/actions/translation-tracker/index.js
```

### GitHub Actions Workflow
Create `.github/workflows/translation-sync.yml`:

```yaml
name: Translation Sync Tracker

on:
push:
branches: [main, week2]
paths: ['src/content/examples/en/**']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This already looks generalized, which is great

workflow_dispatch:

jobs:
track-translation-changes:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 2

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'

- name: Install dependencies
run: npm ci

- name: Install translation tracker dependencies
run: cd .github/actions/translation-tracker && npm install

- name: Run translation tracker
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: node .github/actions/translation-tracker/index.js
```

## Environment Variables

- `GITHUB_TOKEN` - Required for GitHub API and issue creation
- `GITHUB_REPOSITORY` - Format: `owner/repo` (auto-detected in Actions)

## What It Does

1. **Scans** English example files for changes
2. **Compares** with translation files using Git commits
3. **Creates** GitHub issues for outdated translations with:
- Diff snippets showing what changed
- Links to files and comparisons
- Action checklist for translators
- Proper labels (`needs translation`, `lang-es`, etc.)
4. **Generates** manifest file for website banner system
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks so much for the README updates! As one last thing, please include here or ~line 112 a short explanation/example of the translation-status format.

5. **Shows** localized banners on outdated translation pages

## Sample Output

```
📝 Checking 61 English example file(s)

📊 Translation Status Summary:
🔄 Outdated: 48
❌ Missing: 0
✅ Up-to-date: 196

🎫 GitHub issues created: 12
- Issue #36: Spanish, Hindi, Korean, Chinese Simplified need updates
- URL: https://github.com/owner/repo/issues/36

🗂️ Wrote translation manifest: public/translation-status/examples.json
```

## Dependencies

- `@actions/core`, `@actions/github`, `@octokit/rest`
- Node.js built-ins: `fs`, `path`, `child_process`
Loading
Loading