-
Notifications
You must be signed in to change notification settings - Fork 172
[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
Divyansh013
wants to merge
22
commits into
processing:main
Choose a base branch
from
Divyansh013:week2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,747
−2
Open
Changes from 19 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
46edaf0
Test: Add documentation line to circle.mdx for translation tracker te…
Divyansh013 ba9b4ee
Add Week 1 translation tracker implementation
Divyansh013 cd94f24
Test: Modify triangle.mdx for translation testing
Divyansh013 ddebbf3
Test: Modify accelerationX.mdx to test missing translation detection
Divyansh013 1e13287
removed testing logs
Divyansh013 875a77c
small fix
Divyansh013 5170eb6
post review changes
Divyansh013 56abeec
Week 2: Translation tracker with GitHub API and Hindi focus
Divyansh013 d9c98c6
Test: Update English example for translation tracker testing
Divyansh013 1976d9d
Fix: Add automatic branch detection to translation tracker
Divyansh013 71e7049
week 2 complete
Divyansh013 94159c8
Week 3: Test automated translation tracking
Divyansh013 f03b60d
Add manual trigger support to translation tracker workflow
Divyansh013 dea5e7c
Test: Manual trigger detection test
Divyansh013 486aded
Simplify translation tracker - clean output
Divyansh013 63753de
Add scan all files option to index.js
Divyansh013 9f63c9d
final fix
Divyansh013 8de0a67
temp commit
Divyansh013 18bd739
basic version complete
Divyansh013 7fb683c
readme updated and simplified scanning
Divyansh013 034694a
review fix
Divyansh013 7f55a56
updated manifest
Divyansh013 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,266 @@ | ||
# p5.js Translation Tracker | ||
|
||
A comprehensive GitHub Action and command-line tool to track translation status across multiple languages in the p5.js website examples. | ||
|
||
## 🚀 Overview | ||
|
||
This tool helps maintain translation consistency by: | ||
- **Week 1**: Basic file-based change detection using Git | ||
- **Week 2**: GitHub API integration for accurate commit tracking and automated issue creation | ||
- **Week 3**: Multi-language support with single issues per file and manual scanning capabilities | ||
|
||
## 📋 Features | ||
|
||
### ✅ Week 1 Features (File-based tracking) | ||
- Git-based change detection for English example files | ||
- File modification time comparison | ||
- Support for all languages: Spanish (es), Hindi (hi), Korean (ko), Chinese Simplified (zh-Hans) | ||
ksen0 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- Local testing capabilities | ||
|
||
### ✅ Week 2 Features (GitHub API integration) | ||
- Real commit-based comparison using GitHub API | ||
- Automated GitHub issue creation for outdated translations | ||
- Enhanced issue templates with helpful links and timelines | ||
- Branch detection (auto-detects current branch) | ||
- Backward compatibility with Week 1 | ||
|
||
### ✅ Week 3 Features (Multi-language & refinement) | ||
- **Single issue per file**: Creates one issue covering all affected languages instead of separate issues per language | ||
- **Enhanced labeling**: Uses "needs translation" base label + specific language labels (e.g., "lang-es", "lang-ko") | ||
ksen0 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- **Manual scanning**: Can scan all English example files to find outdated/missing translations | ||
- **Comprehensive issue format**: Detailed status for each language with links and action checklists | ||
- **Batched language updates**: Groups all translation issues by file for better organization | ||
|
||
## 🎯 Supported Languages | ||
|
||
- **es**: Spanish (Español) | ||
- **hi**: Hindi (हिन्दी) | ||
- **ko**: Korean (한국어) | ||
- **zh-Hans**: Chinese Simplified (简体中文) | ||
|
||
## 📁 File Structure | ||
|
||
``` | ||
.github/actions/translation-tracker/ | ||
├── index.js # Main implementation (Week 1 + 2 + 3) | ||
├── package.json # Dependencies | ||
├── test-local.js # Testing script with examples | ||
└── README.md # This documentation | ||
``` | ||
|
||
## 🛠 Usage | ||
|
||
### Basic Usage (Week 1 Mode) | ||
|
||
```bash | ||
# Run locally with file-based tracking | ||
node .github/actions/translation-tracker/index.js | ||
``` | ||
|
||
### GitHub API Mode (Week 2 Mode) | ||
|
||
```bash | ||
# Run with GitHub token for commit-based tracking | ||
GITHUB_TOKEN=your_token node .github/actions/translation-tracker/index.js | ||
``` | ||
|
||
### Manual Scanning (Week 3 Feature) | ||
|
||
```bash | ||
# Scan all English example files | ||
GITHUB_TOKEN=token node -e " | ||
const { main } = require('./.github/actions/translation-tracker/index.js'); | ||
main(null, { scanAll: true, createIssues: false }); | ||
" | ||
``` | ||
|
||
### Create Issues (Week 2 + 3 Feature) | ||
|
||
```bash | ||
# Create GitHub issues for outdated translations | ||
GITHUB_TOKEN=token node -e " | ||
const { main } = require('./.github/actions/translation-tracker/index.js'); | ||
main(null, { scanAll: true, createIssues: true }); | ||
" | ||
``` | ||
|
||
## 🧪 Testing | ||
|
||
The project includes a comprehensive test suite: | ||
|
||
```bash | ||
# Run all tests | ||
node .github/actions/translation-tracker/test-local.js | ||
|
||
# Manual scan test | ||
node .github/actions/translation-tracker/test-local.js manual | ||
|
||
# Week 2 features with GitHub API | ||
GITHUB_TOKEN=token node .github/actions/translation-tracker/test-local.js week2 | ||
|
||
# Create test issues | ||
GITHUB_TOKEN=token node .github/actions/translation-tracker/test-local.js issues | ||
``` | ||
|
||
## 📝 Issue Format (Week 3) | ||
|
||
The tool creates comprehensive GitHub issues with: | ||
|
||
### 🔖 Labels | ||
- `needs translation` (base label) | ||
- `help wanted` | ||
- Language-specific labels: `lang-es`, `lang-hi`, `lang-ko`, `lang-zh-Hans` | ||
|
||
### 📄 Issue Content | ||
- **Timeline**: Shows when English and translation files were last updated | ||
- **Outdated Translations**: Lists languages that need updates with commit comparison links | ||
- **Missing Translations**: Lists languages where translation files don't exist | ||
- **Action Checklist**: Step-by-step guide for translators | ||
- **Quick Links**: Direct links to files and comparison views | ||
|
||
### Example Issue Structure: | ||
```markdown | ||
## 🌍 Translation Update Needed | ||
|
||
**File**: `src/content/examples/en/01_Shapes_And_Color/00_Shape_Primitives/description.mdx` | ||
**Branch**: `week2` | ||
|
||
### 📅 Timeline | ||
- **Latest English update**: 6/22/2025 by p5js-contributor | ||
|
||
### 🔄 Outdated Translations | ||
|
||
- **Spanish (Español)**: Last updated 6/9/2025 by spanish-translator | ||
- [📝 View file](https://github.com/owner/repo/blob/week2/src/content/examples/es/...) | ||
- [🔍 Compare changes](https://github.com/owner/repo/compare/abc123...def456) | ||
|
||
### ✅ Action Checklist | ||
|
||
**For translators / contributors:** | ||
|
||
- [ ] Review the recent English file changes and the current translations | ||
- [ ] Confirm if translation already reflects the update — close the issue if so | ||
- [ ] Update the translation files accordingly | ||
- [ ] Maintain structure, code blocks, and formatting | ||
- [ ] Ensure translation is accurate and culturally appropriate | ||
``` | ||
|
||
## 🔧 Configuration | ||
|
||
### Environment Variables | ||
|
||
- `GITHUB_TOKEN`: Required for Week 2+ features (API access and issue creation) | ||
- `GITHUB_REPOSITORY`: Auto-detected in GitHub Actions (format: `owner/repo`) | ||
- `GITHUB_EVENT_NAME`: Auto-detected in GitHub Actions | ||
- `GITHUB_REF_NAME`: Auto-detected branch name | ||
|
||
### Options Object | ||
|
||
```javascript | ||
{ | ||
enableWeek2: boolean, // Force Week 2 mode | ||
ksen0 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
githubToken: string, // GitHub token for API access | ||
createIssues: boolean, // Whether to create GitHub issues | ||
scanAll: boolean // Scan all files instead of just changed files | ||
} | ||
``` | ||
|
||
## 📊 Output Example | ||
|
||
``` | ||
🎯 p5.js Translation Tracker - Week 2 Mode | ||
═══════════════════════════════════════════════════════ | ||
📅 Event: local | ||
🏠 Working directory: /Users/user/p5.js-website-new | ||
🌍 Tracking languages: es, hi, ko, zh-Hans | ||
🔍 Scan mode: All files | ||
|
||
🔍 REPOSITORY STRUCTURE ANALYSIS | ||
═══════════════════════════════════ | ||
📁 Examples path: src/content/examples | ||
🌐 Available languages: en, es, hi, ko, zh-Hans | ||
en: 61 example files across 15 categories | ||
es: 61 example files across 15 categories | ||
hi: 61 example files across 15 categories | ||
ko: 61 example files across 15 categories | ||
zh-Hans: 61 example files across 15 categories | ||
|
||
📝 Checking translations for: src/content/examples/en/01_Shapes_And_Color/00_Shape_Primitives/description.mdx | ||
🔄 es: Needs update | ||
✅ hi: Up to date | ||
🔄 ko: Needs update | ||
🔄 zh-Hans: Needs update | ||
|
||
📝 Creating GitHub issue for src/content/examples/en/01_Shapes_And_Color/00_Shape_Primitives/description.mdx... | ||
✅ Created issue #123: Update translations for description.mdx | ||
|
||
📊 TRANSLATION STATUS SUMMARY (Week 2) | ||
═══════════════════════════════════════ | ||
🆕 Missing translations: 0 | ||
🔄 Outdated translations: 3 | ||
✅ Up-to-date translations: 1 | ||
🎫 Issues created: 1 | ||
- Issue #123: description.mdx (Affected: es, ko, zh-Hans) | ||
``` | ||
|
||
## 🚀 GitHub Actions Integration | ||
|
||
Create `.github/workflows/translation-tracker.yml`: | ||
|
||
```yaml | ||
name: Translation Tracker | ||
|
||
on: | ||
push: | ||
paths: | ||
- 'src/content/examples/en/**/*.mdx' | ||
schedule: | ||
- cron: '0 0 * * 1' # Weekly scan | ||
|
||
jobs: | ||
track-translations: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: '18' | ||
|
||
- name: Install dependencies | ||
run: cd .github/actions/translation-tracker && npm install | ||
|
||
- name: Track translation status | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: node .github/actions/translation-tracker/index.js | ||
``` | ||
|
||
## 🔄 Migration from Previous Versions | ||
|
||
- **Week 1 → Week 2**: Fully backward compatible, automatically detects GitHub token | ||
- **Week 2 → Week 3**: Automatically creates single issues instead of multiple issues per language | ||
- **Legacy Mode**: Will continue working in Week 1 mode if no GitHub token is provided | ||
|
||
## 💡 Key Improvements in Week 3 | ||
|
||
1. **Single Issue Per File**: Instead of creating separate issues for each language, creates one issue that covers all affected languages for a specific file | ||
2. **Better Organization**: Issues are grouped by file rather than scattered by language | ||
3. **Enhanced Labels**: Uses "needs translation" + specific language labels for better filtering | ||
4. **Manual Scanning**: Ability to scan all files on demand rather than just changed files | ||
5. **Improved Issue Format**: More detailed and actionable issue templates | ||
|
||
## 🤝 Contributing | ||
|
||
The translation tracker is modular and extensible: | ||
|
||
- Add new languages by updating `SUPPORTED_LANGUAGES` array | ||
- Modify issue templates in `formatMultiLanguageIssueBody()` method | ||
- Extend file scanning logic in `getAllEnglishExampleFiles()` function | ||
- Add new detection modes by extending the `main()` function options | ||
|
||
## 📚 Dependencies | ||
|
||
- `@actions/core`: GitHub Actions integration | ||
- `@actions/github`: GitHub API wrapper | ||
- `@octokit/rest`: GitHub REST API client | ||
- Node.js built-in modules: `fs`, `path`, `child_process` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.