From 46edaf01ed580702442d8a682c487d5c16de4bce Mon Sep 17 00:00:00 2001 From: Divyansh013 Date: Tue, 10 Jun 2025 01:03:11 +0530 Subject: [PATCH 1/7] Test: Add documentation line to circle.mdx for translation tracker testing --- src/content/reference/en/p5/circle.mdx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/content/reference/en/p5/circle.mdx b/src/content/reference/en/p5/circle.mdx index 5d60fbb3cc..3501fcc5a5 100644 --- a/src/content/reference/en/p5/circle.mdx +++ b/src/content/reference/en/p5/circle.mdx @@ -6,6 +6,8 @@ file: src/core/shape/2d_primitives.js description: >

Draws a circle.

+

This is a test modification for the translation tracker.

+

A circle is a round shape defined by the x, y, and d parameters. From ba9b4ee119e225f6b6a3b99d2e636a0f6e6f54fd Mon Sep 17 00:00:00 2001 From: Divyansh013 Date: Tue, 10 Jun 2025 01:16:13 +0530 Subject: [PATCH 2/7] Add Week 1 translation tracker implementation --- .github/actions/translation-tracker/index.js | 236 ++++++++++++++++++ .../actions/translation-tracker/package.json | 26 ++ .../actions/translation-tracker/test-local.js | 39 +++ .github/workflows/translation-sync.yml | 34 +++ 4 files changed, 335 insertions(+) create mode 100644 .github/actions/translation-tracker/index.js create mode 100644 .github/actions/translation-tracker/package.json create mode 100755 .github/actions/translation-tracker/test-local.js create mode 100644 .github/workflows/translation-sync.yml diff --git a/.github/actions/translation-tracker/index.js b/.github/actions/translation-tracker/index.js new file mode 100644 index 0000000000..f897582e90 --- /dev/null +++ b/.github/actions/translation-tracker/index.js @@ -0,0 +1,236 @@ +const { execSync } = require('child_process'); +const fs = require('fs'); +const path = require('path'); + + +const SUPPORTED_LANGUAGES = ['es', 'hi', 'ko', 'zh-Hans']; +const REFERENCE_PATH = 'src/content/reference'; +const ENGLISH_PATH = path.join(REFERENCE_PATH, 'en'); + + +function getChangedFiles() { + try { + console.log('πŸ” Detecting changed files...'); + + + const gitCommand = process.env.GITHUB_EVENT_NAME === 'pull_request' + ? 'git diff --name-only HEAD~1 HEAD' + : 'git diff --name-only HEAD~1 HEAD'; + + const changedFilesOutput = execSync(gitCommand, { encoding: 'utf8' }); + const allChangedFiles = changedFilesOutput.trim().split('\n').filter(file => file.length > 0); + + + const changedEnglishFiles = allChangedFiles.filter(file => + file.startsWith(ENGLISH_PATH) && file.endsWith('.mdx') + ); + + console.log(`πŸ“ Total changed files: ${allChangedFiles.length}`); + console.log(`πŸ‡ΊπŸ‡Έ Changed English reference files: ${changedEnglishFiles.length}`); + + if (changedEnglishFiles.length > 0) { + console.log('πŸ“„ Changed English files:'); + changedEnglishFiles.forEach(file => console.log(` - ${file}`)); + } + + return changedEnglishFiles; + } catch (error) { + console.error('❌ Error getting changed files:', error.message); + return []; + } +} + + +function getTranslationPath(englishFilePath, language) { + return englishFilePath.replace('/en/', `/${language}/`); +} + +/** + * Check if a file exists + */ +function fileExists(filePath) { + try { + return fs.existsSync(filePath); + } catch (error) { + return false; + } +} + + +function getFileModTime(filePath) { + try { + return fs.statSync(filePath).mtime; + } catch (error) { + return null; + } +} + + +function checkTranslationStatus(changedEnglishFiles) { + console.log('\n🌐 Checking translation status...'); + + const translationStatus = { + needsUpdate: [], + missing: [], + upToDate: [] + }; + + changedEnglishFiles.forEach(englishFile => { + console.log(`\nπŸ“– Analyzing: ${englishFile}`); + + const englishModTime = getFileModTime(englishFile); + if (!englishModTime) { + console.log(` ⚠️ Could not get modification time for English file`); + return; + } + + SUPPORTED_LANGUAGES.forEach(language => { + const translationPath = getTranslationPath(englishFile, language); + const exists = fileExists(translationPath); + + if (!exists) { + console.log(` ❌ ${language}: Missing translation`); + translationStatus.missing.push({ + englishFile, + language, + translationPath, + status: 'missing' + }); + } else { + const translationModTime = getFileModTime(translationPath); + const isOutdated = translationModTime < englishModTime; + + if (isOutdated) { + console.log(` πŸ”„ ${language}: Needs update (English: ${englishModTime.toISOString()}, Translation: ${translationModTime.toISOString()})`); + translationStatus.needsUpdate.push({ + englishFile, + language, + translationPath, + status: 'outdated', + englishModTime, + translationModTime + }); + } else { + console.log(` βœ… ${language}: Up to date`); + translationStatus.upToDate.push({ + englishFile, + language, + translationPath, + status: 'up-to-date' + }); + } + } + }); + }); + + return translationStatus; +} + + +function displaySummary(translationStatus) { + console.log('\nπŸ“Š TRANSLATION STATUS SUMMARY'); + console.log('═══════════════════════════════'); + + console.log(`πŸ†• Missing translations: ${translationStatus.missing.length}`); + if (translationStatus.missing.length > 0) { + translationStatus.missing.forEach(item => { + console.log(` - ${item.language}: ${item.englishFile}`); + }); + } + + console.log(`πŸ”„ Outdated translations: ${translationStatus.needsUpdate.length}`); + if (translationStatus.needsUpdate.length > 0) { + translationStatus.needsUpdate.forEach(item => { + console.log(` - ${item.language}: ${item.englishFile}`); + }); + } + + console.log(`βœ… Up-to-date translations: ${translationStatus.upToDate.length}`); + + console.log('\nπŸ’‘ Next steps for Week 2+:'); + if (translationStatus.missing.length > 0) { + console.log(' - Create GitHub issues for missing translations'); + } + if (translationStatus.needsUpdate.length > 0) { + console.log(' - Create GitHub issues for outdated translations'); + } + console.log(' - Implement automated issue creation'); + console.log(' - Set up notification system for translation teams'); +} + +function exploreRepoStructure() { + console.log('\nπŸ” REPOSITORY STRUCTURE ANALYSIS'); + console.log('═══════════════════════════════════'); + + try { + const referencePath = REFERENCE_PATH; + console.log(`πŸ“ Reference path: ${referencePath}`); + + if (fs.existsSync(referencePath)) { + const languages = fs.readdirSync(referencePath) + .filter(item => fs.statSync(path.join(referencePath, item)).isDirectory()) + .filter(item => !item.startsWith('.')); + + console.log(`🌐 Available languages: ${languages.join(', ')}`); + + // Count files in each language + languages.forEach(lang => { + const langPath = path.join(referencePath, lang); + try { + const subdirs = fs.readdirSync(langPath) + .filter(item => fs.statSync(path.join(langPath, item)).isDirectory()); + + let totalFiles = 0; + subdirs.forEach(subdir => { + const subdirPath = path.join(langPath, subdir); + const files = fs.readdirSync(subdirPath) + .filter(file => file.endsWith('.mdx')); + totalFiles += files.length; + }); + + console.log(` ${lang}: ${totalFiles} files across ${subdirs.length} categories`); + } catch (error) { + console.log(` ${lang}: Error reading directory - ${error.message}`); + } + }); + } else { + console.log(` Reference path does not exist: ${referencePath}`); + } + } catch (error) { + console.error(' Error exploring repository structure:', error.message); + } +} + + +function main() { + console.log('p5.js Translation Sync Tracker - Week 1 Prototype'); + console.log('════════════════════════════════════════════════════'); + console.log(`πŸ“… Event: ${process.env.GITHUB_EVENT_NAME || 'local'}`); + console.log(`🏠 Working directory: ${process.cwd()}`); + console.log(`🎯 Tracking languages: ${SUPPORTED_LANGUAGES.join(', ')}`); + + + exploreRepoStructure(); + + + const changedEnglishFiles = getChangedFiles(); + + if (changedEnglishFiles.length === 0) { + console.log(' No changes detected in English reference files.'); + console.log(' Nothing to track for translations in this commit!'); + return; + } + + + const translationStatus = checkTranslationStatus(changedEnglishFiles); + + + displaySummary(translationStatus); + + +} + +// Run the main function +if (require.main === module) { + main(); +} \ No newline at end of file diff --git a/.github/actions/translation-tracker/package.json b/.github/actions/translation-tracker/package.json new file mode 100644 index 0000000000..b0630b623e --- /dev/null +++ b/.github/actions/translation-tracker/package.json @@ -0,0 +1,26 @@ +{ + "name": "p5js-translation-tracker", + "version": "1.0.0", + "description": "GitHub Action to track translation status for p5.js reference documentation", + "main": "index.js", + "scripts": { + "start": "node index.js", + "test": "node index.js" + }, + "keywords": [ + "p5.js", + "translation", + "documentation", + "github-actions", + "automation" + ], + "author": "Divyansh Srivastava", + "license": "LGPL-2.1", + "engines": { + "node": ">=18.0.0" + }, + "dependencies": { + "@actions/core": "^1.10.0", + "@actions/github": "^5.1.1" + } +} \ No newline at end of file diff --git a/.github/actions/translation-tracker/test-local.js b/.github/actions/translation-tracker/test-local.js new file mode 100755 index 0000000000..c605389af7 --- /dev/null +++ b/.github/actions/translation-tracker/test-local.js @@ -0,0 +1,39 @@ +#!/usr/bin/env node + +/** + * Local test script for the translation tracker + * This simulates the GitHub Action environment for testing + */ + +const { execSync } = require('child_process'); +const path = require('path'); + +process.env.GITHUB_EVENT_NAME = 'push'; +process.env.GITHUB_WORKSPACE = process.cwd(); + +console.log('πŸ§ͺ LOCAL TEST: Translation Tracker'); +console.log('═══════════════════════════════════'); +console.log(`πŸ“ Working directory: ${process.cwd()}`); + +// Navigate to repository root +const repoRoot = path.resolve(__dirname, '../../..'); +process.chdir(repoRoot); + +console.log(`πŸ“ Changed to repository root: ${process.cwd()}`); + +try { + const gitLogOutput = execSync('git log --oneline -5', { encoding: 'utf8' }); + console.log(' Recent commits:'); + console.log(gitLogOutput); +} catch (error) { + console.log(' No git history available or not in a git repository'); +} + +console.log(' Running translation tracker...\n'); + +try { + require('./index.js'); +} catch (error) { + console.error('❌ Error running translation tracker:', error.message); + console.error(error.stack); +} \ No newline at end of file diff --git a/.github/workflows/translation-sync.yml b/.github/workflows/translation-sync.yml new file mode 100644 index 0000000000..b3bbe43440 --- /dev/null +++ b/.github/workflows/translation-sync.yml @@ -0,0 +1,34 @@ +name: Translation Sync Tracker + +on: + push: + branches: [main] + paths: + - 'src/content/reference/en/**' + pull_request: + branches: [main] + paths: + - 'src/content/reference/en/**' + +jobs: + track-translation-changes: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 2 # Fetch previous commit to compare changes + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '18' + + - name: Install dependencies + run: npm ci + + - name: Run translation tracker + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: node .github/actions/translation-tracker/index.js \ No newline at end of file From cd94f245555d86ae4cc33b4f2bd815cc7a2eba30 Mon Sep 17 00:00:00 2001 From: Divyansh013 Date: Tue, 10 Jun 2025 01:16:47 +0530 Subject: [PATCH 3/7] Test: Modify triangle.mdx for translation testing --- src/content/reference/en/p5/triangle.mdx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/content/reference/en/p5/triangle.mdx b/src/content/reference/en/p5/triangle.mdx index 02740d2d1b..7534675583 100644 --- a/src/content/reference/en/p5/triangle.mdx +++ b/src/content/reference/en/p5/triangle.mdx @@ -6,6 +6,8 @@ file: src/core/shape/2d_primitives.js description: >

Draws a triangle.

+

Test modification for translation tracker testing.

+

A triangle is a three-sided shape defined by three points. The first two parameters specify the triangle's first point (x1, y1). From ddebbf3a65c9812a857c8a915a13e75a0ec7ef75 Mon Sep 17 00:00:00 2001 From: Divyansh013 Date: Tue, 10 Jun 2025 01:17:33 +0530 Subject: [PATCH 4/7] Test: Modify accelerationX.mdx to test missing translation detection --- src/content/reference/en/p5/accelerationX.mdx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/content/reference/en/p5/accelerationX.mdx b/src/content/reference/en/p5/accelerationX.mdx index 14edb024b5..839003bd00 100644 --- a/src/content/reference/en/p5/accelerationX.mdx +++ b/src/content/reference/en/p5/accelerationX.mdx @@ -8,6 +8,8 @@ description: > device along the x axis. Value is represented as meters per second squared.

+ +

Test modification to demonstrate missing translation detection.

line: 23 isConstructor: false itemtype: property From 1e132870fe3788fb3d0ee9489e1af68af5f22b1b Mon Sep 17 00:00:00 2001 From: Divyansh013 Date: Tue, 10 Jun 2025 01:22:25 +0530 Subject: [PATCH 5/7] removed testing logs --- .github/actions/translation-tracker/index.js | 24 +++++++------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/.github/actions/translation-tracker/index.js b/.github/actions/translation-tracker/index.js index f897582e90..c22a9f4408 100644 --- a/.github/actions/translation-tracker/index.js +++ b/.github/actions/translation-tracker/index.js @@ -10,7 +10,7 @@ const ENGLISH_PATH = path.join(REFERENCE_PATH, 'en'); function getChangedFiles() { try { - console.log('πŸ” Detecting changed files...'); + const gitCommand = process.env.GITHUB_EVENT_NAME === 'pull_request' @@ -25,8 +25,8 @@ function getChangedFiles() { file.startsWith(ENGLISH_PATH) && file.endsWith('.mdx') ); - console.log(`πŸ“ Total changed files: ${allChangedFiles.length}`); - console.log(`πŸ‡ΊπŸ‡Έ Changed English reference files: ${changedEnglishFiles.length}`); + console.log(` Total changed files: ${allChangedFiles.length}`); + console.log(` Changed English reference files: ${changedEnglishFiles.length}`); if (changedEnglishFiles.length > 0) { console.log('πŸ“„ Changed English files:'); @@ -35,7 +35,7 @@ function getChangedFiles() { return changedEnglishFiles; } catch (error) { - console.error('❌ Error getting changed files:', error.message); + console.error(' Error getting changed files:', error.message); return []; } } @@ -67,7 +67,7 @@ function getFileModTime(filePath) { function checkTranslationStatus(changedEnglishFiles) { - console.log('\n🌐 Checking translation status...'); + const translationStatus = { needsUpdate: [], @@ -76,11 +76,11 @@ function checkTranslationStatus(changedEnglishFiles) { }; changedEnglishFiles.forEach(englishFile => { - console.log(`\nπŸ“– Analyzing: ${englishFile}`); + const englishModTime = getFileModTime(englishFile); if (!englishModTime) { - console.log(` ⚠️ Could not get modification time for English file`); + console.log(`Could not get modification time for English file`); return; } @@ -148,15 +148,7 @@ function displaySummary(translationStatus) { console.log(`βœ… Up-to-date translations: ${translationStatus.upToDate.length}`); console.log('\nπŸ’‘ Next steps for Week 2+:'); - if (translationStatus.missing.length > 0) { - console.log(' - Create GitHub issues for missing translations'); - } - if (translationStatus.needsUpdate.length > 0) { - console.log(' - Create GitHub issues for outdated translations'); - } - console.log(' - Implement automated issue creation'); - console.log(' - Set up notification system for translation teams'); -} + function exploreRepoStructure() { console.log('\nπŸ” REPOSITORY STRUCTURE ANALYSIS'); From 875a77cd3db85f6baa6a705f5ca63338efb42955 Mon Sep 17 00:00:00 2001 From: Divyansh013 Date: Thu, 12 Jun 2025 23:19:54 +0530 Subject: [PATCH 6/7] small fix --- .github/actions/translation-tracker/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/actions/translation-tracker/index.js b/.github/actions/translation-tracker/index.js index c22a9f4408..d4f3c04160 100644 --- a/.github/actions/translation-tracker/index.js +++ b/.github/actions/translation-tracker/index.js @@ -149,7 +149,7 @@ function displaySummary(translationStatus) { console.log('\nπŸ’‘ Next steps for Week 2+:'); - +} function exploreRepoStructure() { console.log('\nπŸ” REPOSITORY STRUCTURE ANALYSIS'); console.log('═══════════════════════════════════'); @@ -225,4 +225,4 @@ function main() { // Run the main function if (require.main === module) { main(); -} \ No newline at end of file +} From 5170eb676a71c2b467e97d372de64b9b1ea4978c Mon Sep 17 00:00:00 2001 From: Divyansh013 Date: Fri, 13 Jun 2025 15:49:36 +0530 Subject: [PATCH 7/7] post review changes --- .github/actions/translation-tracker/index.js | 145 ++++++++++-------- .../actions/translation-tracker/package.json | 4 +- .../actions/translation-tracker/test-local.js | 47 ++---- .../00_Shape_Primitives/description.mdx | 2 +- src/content/reference/en/p5/accelerationX.mdx | 2 - src/content/reference/en/p5/circle.mdx | 2 - src/content/reference/en/p5/triangle.mdx | 2 - 7 files changed, 95 insertions(+), 109 deletions(-) diff --git a/.github/actions/translation-tracker/index.js b/.github/actions/translation-tracker/index.js index d4f3c04160..fe1ba04807 100644 --- a/.github/actions/translation-tracker/index.js +++ b/.github/actions/translation-tracker/index.js @@ -2,17 +2,19 @@ const { execSync } = require('child_process'); const fs = require('fs'); const path = require('path'); - const SUPPORTED_LANGUAGES = ['es', 'hi', 'ko', 'zh-Hans']; -const REFERENCE_PATH = 'src/content/reference'; -const ENGLISH_PATH = path.join(REFERENCE_PATH, 'en'); -function getChangedFiles() { +function getChangedFiles(testFiles = null) { + // Allow passing test files for local development + if (testFiles) { + console.log('πŸ§ͺ Using provided test files for local testing'); + return testFiles.filter(file => + file.startsWith('src/content/examples/en') && file.endsWith('.mdx') + ); + } + try { - - - const gitCommand = process.env.GITHUB_EVENT_NAME === 'pull_request' ? 'git diff --name-only HEAD~1 HEAD' : 'git diff --name-only HEAD~1 HEAD'; @@ -20,31 +22,25 @@ function getChangedFiles() { const changedFilesOutput = execSync(gitCommand, { encoding: 'utf8' }); const allChangedFiles = changedFilesOutput.trim().split('\n').filter(file => file.length > 0); - - const changedEnglishFiles = allChangedFiles.filter(file => - file.startsWith(ENGLISH_PATH) && file.endsWith('.mdx') + const changedExampleFiles = allChangedFiles.filter(file => + file.startsWith('src/content/examples/en') && file.endsWith('.mdx') ); - console.log(` Total changed files: ${allChangedFiles.length}`); - console.log(` Changed English reference files: ${changedEnglishFiles.length}`); + console.log(`πŸ“Š Total changed files: ${allChangedFiles.length}`); + console.log(`πŸ“– Changed English example files: ${changedExampleFiles.length}`); - if (changedEnglishFiles.length > 0) { - console.log('πŸ“„ Changed English files:'); - changedEnglishFiles.forEach(file => console.log(` - ${file}`)); + if (changedExampleFiles.length > 0) { + console.log('πŸ“„ Changed English example files:'); + changedExampleFiles.forEach(file => console.log(` - ${file}`)); } - return changedEnglishFiles; + return changedExampleFiles; } catch (error) { - console.error(' Error getting changed files:', error.message); + console.error('❌ Error getting changed files:', error.message); return []; } } - -function getTranslationPath(englishFilePath, language) { - return englishFilePath.replace('/en/', `/${language}/`); -} - /** * Check if a file exists */ @@ -66,26 +62,24 @@ function getFileModTime(filePath) { } -function checkTranslationStatus(changedEnglishFiles) { - - +function checkTranslationStatus(changedExampleFiles) { const translationStatus = { needsUpdate: [], missing: [], upToDate: [] }; - changedEnglishFiles.forEach(englishFile => { - + changedExampleFiles.forEach(englishFile => { + console.log(`\nπŸ“ Checking translations for: ${englishFile}`); const englishModTime = getFileModTime(englishFile); if (!englishModTime) { - console.log(`Could not get modification time for English file`); + console.log(`⚠️ Could not get modification time for English file`); return; } SUPPORTED_LANGUAGES.forEach(language => { - const translationPath = getTranslationPath(englishFile, language); + const translationPath = englishFile.replace('/en/', `/${language}/`); const exists = fileExists(translationPath); if (!exists) { @@ -147,82 +141,99 @@ function displaySummary(translationStatus) { console.log(`βœ… Up-to-date translations: ${translationStatus.upToDate.length}`); - console.log('\nπŸ’‘ Next steps for Week 2+:'); - + } + +/** + * Explore repository structure (focusing on examples as requested) + */ function exploreRepoStructure() { console.log('\nπŸ” REPOSITORY STRUCTURE ANALYSIS'); console.log('═══════════════════════════════════'); try { - const referencePath = REFERENCE_PATH; - console.log(`πŸ“ Reference path: ${referencePath}`); + const examplesPath = 'src/content/examples'; + console.log(`πŸ“ Examples path: ${examplesPath}`); - if (fs.existsSync(referencePath)) { - const languages = fs.readdirSync(referencePath) - .filter(item => fs.statSync(path.join(referencePath, item)).isDirectory()) - .filter(item => !item.startsWith('.')); + if (fs.existsSync(examplesPath)) { + const languages = fs.readdirSync(examplesPath) + .filter(item => fs.statSync(path.join(examplesPath, item)).isDirectory()) + .filter(item => !item.startsWith('.') && item !== 'images'); console.log(`🌐 Available languages: ${languages.join(', ')}`); - // Count files in each language + // Count example files in each language languages.forEach(lang => { - const langPath = path.join(referencePath, lang); + const langPath = path.join(examplesPath, lang); try { - const subdirs = fs.readdirSync(langPath) + let totalFiles = 0; + const categories = fs.readdirSync(langPath) .filter(item => fs.statSync(path.join(langPath, item)).isDirectory()); - let totalFiles = 0; - subdirs.forEach(subdir => { - const subdirPath = path.join(langPath, subdir); - const files = fs.readdirSync(subdirPath) - .filter(file => file.endsWith('.mdx')); - totalFiles += files.length; + categories.forEach(category => { + const categoryPath = path.join(langPath, category); + const countFilesRecursively = (dir) => { + const items = fs.readdirSync(dir); + let count = 0; + items.forEach(item => { + const itemPath = path.join(dir, item); + if (fs.statSync(itemPath).isDirectory()) { + count += countFilesRecursively(itemPath); + } else if (item.endsWith('.mdx')) { + count++; + } + }); + return count; + }; + totalFiles += countFilesRecursively(categoryPath); }); - console.log(` ${lang}: ${totalFiles} files across ${subdirs.length} categories`); + console.log(` ${lang}: ${totalFiles} example files across ${categories.length} categories`); } catch (error) { console.log(` ${lang}: Error reading directory - ${error.message}`); } }); } else { - console.log(` Reference path does not exist: ${referencePath}`); + console.log(`❌ Examples path does not exist: ${examplesPath}`); } } catch (error) { - console.error(' Error exploring repository structure:', error.message); + console.error('❌ Error exploring repository structure:', error.message); } } -function main() { - console.log('p5.js Translation Sync Tracker - Week 1 Prototype'); - console.log('════════════════════════════════════════════════════'); +function main(testFiles = null) { + console.log('🎯 p5.js Example Translation Tracker - Week 1 Prototype'); + console.log('═══════════════════════════════════════════════════════'); console.log(`πŸ“… Event: ${process.env.GITHUB_EVENT_NAME || 'local'}`); console.log(`🏠 Working directory: ${process.cwd()}`); - console.log(`🎯 Tracking languages: ${SUPPORTED_LANGUAGES.join(', ')}`); - - + console.log(`🌍 Tracking languages: ${SUPPORTED_LANGUAGES.join(', ')}`); + exploreRepoStructure(); + // Get changed files (supports both git and test files) + const changedExampleFiles = getChangedFiles(testFiles); - const changedEnglishFiles = getChangedFiles(); - - if (changedEnglishFiles.length === 0) { - console.log(' No changes detected in English reference files.'); - console.log(' Nothing to track for translations in this commit!'); + if (changedExampleFiles.length === 0) { + console.log('\n✨ No changes detected in English example files.'); + console.log('πŸ“ Nothing to track for translations in this commit!'); return; } - - const translationStatus = checkTranslationStatus(changedEnglishFiles); - - + const translationStatus = checkTranslationStatus(changedExampleFiles); + displaySummary(translationStatus); - - } -// Run the main function +// Export for testing +module.exports = { + main, + getChangedFiles, + checkTranslationStatus, + exploreRepoStructure +}; + + if (require.main === module) { main(); } diff --git a/.github/actions/translation-tracker/package.json b/.github/actions/translation-tracker/package.json index b0630b623e..7284cba02a 100644 --- a/.github/actions/translation-tracker/package.json +++ b/.github/actions/translation-tracker/package.json @@ -1,7 +1,7 @@ { "name": "p5js-translation-tracker", - "version": "1.0.0", - "description": "GitHub Action to track translation status for p5.js reference documentation", + "version": "0.1.1", + "description": "GitHub Action to track translation status for p5.js examples and documentation", "main": "index.js", "scripts": { "start": "node index.js", diff --git a/.github/actions/translation-tracker/test-local.js b/.github/actions/translation-tracker/test-local.js index c605389af7..79cd71a5e0 100755 --- a/.github/actions/translation-tracker/test-local.js +++ b/.github/actions/translation-tracker/test-local.js @@ -1,39 +1,20 @@ -#!/usr/bin/env node -/** - * Local test script for the translation tracker - * This simulates the GitHub Action environment for testing - */ -const { execSync } = require('child_process'); -const path = require('path'); +const { main } = require('./index.js'); -process.env.GITHUB_EVENT_NAME = 'push'; -process.env.GITHUB_WORKSPACE = process.cwd(); +// Test scenarios using actual example files that exist +const testFiles = [ + 'src/content/examples/en/01_Shapes_And_Color/00_Shape_Primitives/description.mdx', + 'src/content/examples/en/02_Animation_And_Variables/00_Drawing_Lines/description.mdx', + 'src/content/examples/en/03_Imported_Media/00_Words/description.mdx' +]; -console.log('πŸ§ͺ LOCAL TEST: Translation Tracker'); -console.log('═══════════════════════════════════'); -console.log(`πŸ“ Working directory: ${process.cwd()}`); +console.log('πŸ§ͺ Testing Example Translation Tracker Locally'); +console.log('===============================================\n'); -// Navigate to repository root -const repoRoot = path.resolve(__dirname, '../../..'); -process.chdir(repoRoot); +// Run the main function with test files +main(testFiles); -console.log(`πŸ“ Changed to repository root: ${process.cwd()}`); - -try { - const gitLogOutput = execSync('git log --oneline -5', { encoding: 'utf8' }); - console.log(' Recent commits:'); - console.log(gitLogOutput); -} catch (error) { - console.log(' No git history available or not in a git repository'); -} - -console.log(' Running translation tracker...\n'); - -try { - require('./index.js'); -} catch (error) { - console.error('❌ Error running translation tracker:', error.message); - console.error(error.stack); -} \ No newline at end of file +console.log('\nπŸ’‘ This demonstrates local testing capability as requested by mentor'); +console.log('πŸ”§ The git logic is now separated and modular for easier testing'); +console.log('πŸ“– Now tracking examples instead of tutorials as requested'); \ No newline at end of file diff --git a/src/content/examples/en/01_Shapes_And_Color/00_Shape_Primitives/description.mdx b/src/content/examples/en/01_Shapes_And_Color/00_Shape_Primitives/description.mdx index 428f348709..6d2b99d0e7 100644 --- a/src/content/examples/en/01_Shapes_And_Color/00_Shape_Primitives/description.mdx +++ b/src/content/examples/en/01_Shapes_And_Color/00_Shape_Primitives/description.mdx @@ -9,7 +9,7 @@ relatedReference: --- This program demonstrates the use of the basic shape -primitive functions +primitive functions (sample change for testing) square(), rect(), ellipse(), diff --git a/src/content/reference/en/p5/accelerationX.mdx b/src/content/reference/en/p5/accelerationX.mdx index 839003bd00..14edb024b5 100644 --- a/src/content/reference/en/p5/accelerationX.mdx +++ b/src/content/reference/en/p5/accelerationX.mdx @@ -8,8 +8,6 @@ description: > device along the x axis. Value is represented as meters per second squared.

- -

Test modification to demonstrate missing translation detection.

line: 23 isConstructor: false itemtype: property diff --git a/src/content/reference/en/p5/circle.mdx b/src/content/reference/en/p5/circle.mdx index 3501fcc5a5..5d60fbb3cc 100644 --- a/src/content/reference/en/p5/circle.mdx +++ b/src/content/reference/en/p5/circle.mdx @@ -6,8 +6,6 @@ file: src/core/shape/2d_primitives.js description: >

Draws a circle.

-

This is a test modification for the translation tracker.

-

A circle is a round shape defined by the x, y, and d parameters. diff --git a/src/content/reference/en/p5/triangle.mdx b/src/content/reference/en/p5/triangle.mdx index 7534675583..02740d2d1b 100644 --- a/src/content/reference/en/p5/triangle.mdx +++ b/src/content/reference/en/p5/triangle.mdx @@ -6,8 +6,6 @@ file: src/core/shape/2d_primitives.js description: >

Draws a triangle.

-

Test modification for translation tracker testing.

-

A triangle is a three-sided shape defined by three points. The first two parameters specify the triangle's first point (x1, y1).