Skip to content

Conversation

@lyzno1
Copy link
Collaborator

@lyzno1 lyzno1 commented Aug 10, 2025

What & Why

What: Optimize CI/CD workflows and internationalization (i18n) translation system
Why: Simplify overly complex CI logic, fix translation API issues, and improve workflow reliability

Fixes #203

Pre-PR Checklist

Run these:

  • pnpm type-check
  • pnpm format:check
  • pnpm lint (existing issues unrelated to changes)
  • pnpm build (verified locally, skipped for PR creation)
  • pnpm i18n:check (now handled by separate workflow)

Type

  • 🐛 Bug fix
  • ✨ Feature
  • 💥 Breaking change
  • 📚 Docs
  • ♻️ Refactor
  • ⚡ Performance

Changes Made

🚀 CI/CD Workflow Improvements

  • Simplified test logic: Removed complex 40+ line bash script for file matching → direct pnpm test
  • Added timeout protection: 5-10 minute timeouts on all CI jobs to prevent hanging
  • Removed i18n validation: Translation checks moved to dedicated workflow, no longer block code merges
  • Improved reliability: Eliminated error-prone file pattern matching logic

🌐 i18n Translation System Enhancements

  • Fixed API integration: Corrected MyMemory Translation API calls and error handling
  • Language code consistency: Updated Chinese mapping from 'zh-CN': 'zh' to 'zh-CN': 'zh-Hans' for clarity
  • Removed dangerous functionality: Eliminated translate:full to protect existing manual translations
  • Standardized script calls: All workflows now use pnpm commands consistently
  • Created dedicated workflow: New auto-i18n-translation.yml automatically handles translation updates

📋 Code Quality & Maintenance

  • Reduced code complexity: Net reduction of 81 lines of code across workflows
  • Improved maintainability: Clearer separation of concerns between CI and i18n processes
  • Enhanced error handling: Better API error detection and recovery mechanisms

Workflow Logic

CI Workflow (.github/workflows/ci.yml)

Purpose: Validate code quality and prevent regressions

  • Code formatting & linting → TypeScript validation → Build verification → Testing → Security scanning

i18n Workflow (.github/workflows/auto-i18n-translation.yml)

Purpose: Automate translation updates

  • Triggers on messages/en-US.json changes → Clean extra keys → Translate missing keys only → Create PR

Impact

  • Faster CI: Simplified logic reduces execution time and failure points
  • Better translations: Only new keys translated, preserving manual improvements
  • Reduced maintenance: Less complex bash scripting, more reliable operations
  • Clearer separation: CI focuses on code quality, i18n handles translations independently

Testing

  • Verified type checking passes
  • Confirmed linting tools still function (existing issues unrelated to changes)
  • Validated workflow YAML syntax
  • Tested translation script improvements locally

lyzno1 added 6 commits August 10, 2025 13:42
- Create auto-gen-i18n.js script for automated translation
- Support dynamic language loading from lib/config/language-config.ts
- Add comprehensive CLI argument parsing with short/long options
- Include help system with usage examples and supported languages
- Add new pnpm scripts: i18n:translate, i18n:translate:full, i18n:translate:dry, i18n:translate:help
- Update .gitignore to allow the new script
- Update ESLint config to ignore the translation script
- Use MyMemory translation API with intelligent content filtering
- Support incremental and full translation modes with dry-run preview
…o-remove functionality

- Add compare_keys() method for numerical baseline comparison against English
- Add remove_extra_keys() method with dry-run support for safe key removal
- Display quantitative differences as 0, +N (extra), -N (missing) format
- Support detailed breakdown showing separate missing/extra key counts
- Add new pnpm scripts: i18n:compare, i18n:compare:details, i18n:remove-extra, i18n:remove-extra:dry
- Enable intelligent key management with preview and validation modes
- Simplify CI test logic, remove complex bash file matching (40+ lines → direct pnpm test)
- Add timeout protection to all CI jobs (5-10 min limits)
- Fix i18n translation API calls and Chinese language mapping (zh-CN → zh-Hans)
- Remove dangerous translate:full functionality to preserve existing translations
- Standardize all workflow scripts to use pnpm commands consistently
- Ensure only missing keys are translated, protecting manual translation improvements

Addresses workflow complexity and translation quality issues
- Remove i18n-validation job from CI workflow
- Remove i18n checks from final status validation
- Translation issues now handled by dedicated auto-i18n workflow
- Prevents translation inconsistencies from blocking code merges
@dosubot dosubot bot added size:XXL This PR changes 1000+ lines, ignoring generated files. type:feature Request for a brand-new capability. type:refactor Internal code improvements without behavior change. labels Aug 10, 2025
@lyzno1 lyzno1 requested review from Copilot and zhangxuhe1 August 10, 2025 07:20

This comment was marked as outdated.

zhangxuhe1
zhangxuhe1 previously approved these changes Aug 10, 2025
@dosubot dosubot bot added the lgtm Looks good to me; approved by a reviewer. label Aug 10, 2025
lyzno1 added 2 commits August 10, 2025 15:32
- Update Chinese language codes to use API-compatible format (zh-CN, zh-TW)
- Replace incorrect email with project contact license@iflabx.com
- Enhance rate limiting with exponential backoff for better API reliability
- Increase base delay from 100ms to 200ms to reduce API pressure

Addresses Copilot review suggestions for better API integration.
lyzno1 and others added 3 commits August 10, 2025 15:38
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
- Remove gitignore restrictions on scripts/ directory for easier development
- Delete unused scripts: labels-reset.sh, lint-unused.js,
  security-vulnerability-demo.js, test_dify_file_flow.py
- Keep only essential scripts: auto-gen-i18n.js, i18n-refactor-helper.py,
  validate-i18n-consistency.py
@lyzno1 lyzno1 requested a review from Copilot August 10, 2025 07:42
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR optimizes CI/CD workflows and internationalization (i18n) translation system to improve reliability and maintainability. The changes simplify complex CI logic, fix translation API issues, and enhance workflow separation of concerns.

  • Simplified CI test execution by removing complex file matching logic in favor of direct pnpm test
  • Enhanced i18n translation system with fixed API integration and new automation capabilities
  • Replaced browser confirmation dialogs with reusable ConfirmDialog components across admin interfaces

Reviewed Changes

Copilot reviewed 14 out of 15 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
.github/workflows/ci.yml Simplified test logic, added timeouts, removed i18n validation from CI pipeline
.github/workflows/auto-i18n-translation.yml New dedicated workflow for automated translation updates
scripts/auto-gen-i18n.js New translation script with MyMemory API integration and improved error handling
scripts/i18n-refactor-helper.py Added key comparison and extra key removal functionality
package.json Added new i18n npm scripts for translation management
Admin components Replaced window.confirm() with consistent ConfirmDialog usage
Translation files Updated with new confirmation dialog keys
Comments suppressed due to low confidence (1)

scripts/i18n-refactor-helper.py:43

  • The comment in the PR description mentions updating Chinese mapping from 'zh-CN': 'zh' to 'zh-CN': 'zh-Hans' for clarity, but this line appears to be in a fallback configuration. Consider adding a comment explaining why 'zh-Hans' is used here versus other mappings.
            if not match:

@lyzno1 lyzno1 requested a review from zhangxuhe1 August 10, 2025 07:45
@lyzno1
Copy link
Collaborator Author

lyzno1 commented Aug 10, 2025

Update on Copilot Review Suggestions

Thanks for the review suggestions! Here's the status of each recommendation:

✅ Implemented Manually

  • Language code mapping: Fixed Chinese language codes to use MyMemory API-compatible format (zh-CN, zh-TW) instead of zh-Hans/zh-Hant
  • Email address: Replaced incorrect claude@agentifui.com with project contact license@iflabx.com
  • Rate limiting: Enhanced with exponential backoff mechanism and increased base delay to 200ms

✅ Ready to Accept

  • #2265152078: GitHub Actions format improvement - can be directly committed
  • #2265152082: Verbose logging optimization - can be directly committed

❌ Should Not Accept

  • #2265159374: This suggestion would revert our API compatibility fix. We verified that MyMemory API supports zh-CN/zh-TW format, so the current mapping is correct.

🧹 Additional Cleanup

  • Removed scripts directory restrictions from .gitignore for easier development
  • Cleaned up unused development scripts (4 files removed)
  • Kept only essential i18n scripts: auto-gen-i18n.js, i18n-refactor-helper.py, validate-i18n-consistency.py

All changes have been tested and validated. The i18n automation workflow is now more robust and API-compatible.

@zhangxuhe1 zhangxuhe1 merged commit 3906eb8 into main Aug 10, 2025
15 checks passed
@lyzno1 lyzno1 deleted the feat/optimize-ci-and-i18n-workflows branch August 10, 2025 09:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm Looks good to me; approved by a reviewer. size:XXL This PR changes 1000+ lines, ignoring generated files. type:feature Request for a brand-new capability. type:refactor Internal code improvements without behavior change.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add i18n automatic translation scripts

3 participants