Skip to content

Conversation

@0xsatoshi99
Copy link
Contributor

Summary

Provides automated translation tools to translate JavaGuide documentation to multiple languages, addressing the 5-year-old request in issue #1494 for English and other language versions.

Changes

3 files added (876 lines total)

Files:

  1. translate_repo.py (318 lines) - Python implementation
  2. TranslateRepo.java (386 lines) - Java implementation
  3. TRANSLATION_TOOLS.md (172 lines) - Comprehensive documentation

Features

Core Functionality:

  • ✅ Batch translates ALL .md files in docs/ folder + README.md
  • ✅ Supports 20 languages (English, Spanish, French, German, Japanese, Korean, etc.)
  • ✅ Preserves directory structure: docs/docs_en/
  • ✅ File naming: file.mdfile.en.md
  • ✅ Free Google Translate API (no API key required)

Smart Features:

  • Progress tracking - Saves to .translation_progress.json
  • Resume capability - Skips already translated files
  • Rate limiting - Avoids API throttling (1 sec delay)
  • Smart chunking - Handles large files (4000 char chunks)
  • Format preservation - Maintains markdown and code blocks

Usage

Python Version:

pip install deep-translator
python3 translate_repo.py
# Select language (1-20)
# Confirm translation

Java Version:

# Download gson-2.10.1.jar
javac -cp gson-2.10.1.jar TranslateRepo.java
java -cp .:gson-2.10.1.jar TranslateRepo
# Select language (1-20)
# Confirm translation

Output Structure

Before:

docs/
├── java/
│   └── basics.md
README.md

After (English translation):

docs_en/
├── java/
│   └── basics.en.md
README.en.md

Performance

  • Speed: ~1 file per 5-10 seconds
  • JavaGuide: 292 files ≈ 2-3 hours total
  • Tested: Successfully translated README.md and sample docs files

Supported Languages (20)

  1. English (en)
  2. Chinese Simplified (zh)
  3. Spanish (es)
  4. French (fr)
  5. Portuguese (pt)
  6. German (de)
  7. Japanese (ja)
  8. Korean (ko)
  9. Russian (ru)
  10. Italian (it)
  11. Arabic (ar)
  12. Hindi (hi)
  13. Turkish (tr)
  14. Vietnamese (vi)
  15. Polish (pl)
  16. Dutch (nl)
  17. Indonesian (id)
  18. Thai (th)
  19. Swedish (sv)
  20. Greek (el)

Benefits

  1. Global Accessibility: Makes JavaGuide available to non-Chinese speakers
  2. Community Friendly: Anyone can run the tool and contribute translations
  3. Maintainable: Easy to regenerate translations when docs update
  4. Consistent: Automated process ensures uniform translation quality
  5. Scalable: Can translate to any of 20 languages with one command

Why Both Python and Java?

  • Python: Easy to use, popular for automation
  • Java: Native to JavaGuide project, no external dependencies (except Gson)
  • Choice: Contributors can use whichever they prefer

Next Steps

After merging, contributors can:

  1. Run the translation tool for their preferred language
  2. Review and refine automated translations
  3. Submit PRs with translated documentation
  4. Help maintain translations as docs evolve

Testing

Tested successfully:

  • ✅ README.md → README.en.md (26KB)
  • ✅ docs/system-design/framework/netty.md → docs_en/system-design/framework/netty.en.md
  • ✅ Directory structure preserved
  • ✅ Markdown formatting maintained
  • ✅ Translation quality verified

Addresses #1494

Provides automated translation tools to translate JavaGuide documentation
to multiple languages, addressing the 5-year-old request in issue Snailclimb#1494.

Features:
- Python and Java implementations (876 lines total)
- Supports 20 languages including English, Spanish, French, etc.
- Batch translates all markdown files in docs/ folder + README.md
- Preserves directory structure (docs/ -> docs_en/)
- File naming: file.md -> file.en.md
- Progress tracking with JSON (.translation_progress.json)
- Skips already translated files
- Rate limiting to avoid API throttling
- Free Google Translate API (no key required)
- Handles large files with smart chunking (4000 chars)
- Preserves markdown formatting and code blocks

Files added:
- translate_repo.py (318 lines) - Python implementation
- TranslateRepo.java (386 lines) - Java implementation
- TRANSLATION_TOOLS.md (172 lines) - Comprehensive documentation

Usage:
  Python: python3 translate_repo.py
  Java: javac -cp gson.jar TranslateRepo.java && java -cp .:gson.jar TranslateRepo

Output structure:
  docs/ -> docs_en/ (for English)
  README.md -> README.en.md

Performance:
  ~1 file per 5-10 seconds
  JavaGuide (292 files) ≈ 2-3 hours

This enables the community to easily create translations for any of the
20 supported languages, making JavaGuide accessible to developers worldwide.

Addresses Snailclimb#1494
@0xsatoshi99
Copy link
Contributor Author

@Snailclimb Please check this translate script. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant