Contributing to Jta

October 24, 2025 ยท View on GitHub

Thank you for your interest in contributing to Jta! This document provides guidelines and instructions for contributing.

๐ŸŒŸ Ways to Contribute

There are many ways to contribute to Jta:

  • ๐Ÿ› Report bugs: Found an issue? Let us know!
  • ๐Ÿ’ก Suggest features: Have an idea? We'd love to hear it!
  • ๐Ÿ“– Improve documentation: Help others understand Jta better
  • ๐Ÿ”ง Fix bugs: Pick an issue and submit a PR
  • โœจ Add features: Implement new capabilities
  • ๐Ÿงช Write tests: Improve test coverage
  • ๐ŸŒ Translate: Help translate Jta's own messages

๐Ÿš€ Getting Started

Prerequisites

Development Setup

  1. Fork the repository

    Click the "Fork" button on GitHub to create your own copy.

  2. Clone your fork

    git clone https://github.com/YOUR_USERNAME/jta.git
    cd jta
    
  3. Add upstream remote

    git remote add upstream https://github.com/hikanner/jta.git
    
  4. Install dependencies

    go mod download
    
  5. Set up environment variables

    export OPENAI_API_KEY=sk-...
    # Or use .env file (not tracked in git)
    echo "OPENAI_API_KEY=sk-..." > .env
    
  6. Run tests

    go test ./...
    
  7. Build the project

    go build -o jta cmd/jta/main.go
    
  8. Try it out

    ./jta examples/en.json --to zh
    

๐Ÿ“ Development Workflow

Creating a Feature Branch

Always create a new branch for your work:

git checkout -b feature/your-feature-name
# or
git checkout -b fix/your-bug-fix

Branch naming conventions:

  • feature/ - New features
  • fix/ - Bug fixes
  • docs/ - Documentation changes
  • test/ - Test additions or modifications
  • refactor/ - Code refactoring
  • perf/ - Performance improvements

Making Changes

  1. Write clean, readable code

    • Follow Go conventions and best practices
    • Use meaningful variable and function names
    • Add comments for complex logic
    • Keep functions focused and small
  2. Add tests

    • Write unit tests for new functions
    • Ensure existing tests still pass
    • Aim for high test coverage (target: 60%+)
  3. Update documentation

    • Update README.md if adding user-facing features
    • Add godoc comments for exported functions
    • Update CHANGELOG.md (if exists)

Code Style

We follow standard Go formatting:

# Format your code
gofmt -w .

# Run linter
golangci-lint run

# Check for common issues
go vet ./...

Testing

Running Tests

# Run all tests
go test ./...

# Run tests with coverage
go test -cover ./...

# Run tests with detailed coverage
go test -coverprofile=coverage.out ./...
go tool cover -html=coverage.out

# Run specific package tests
go test ./internal/translator/...

# Run with verbose output
go test -v ./...

Writing Tests

Follow these guidelines:

  1. Test file naming: *_test.go
  2. Test function naming: Test<FunctionName>
  3. Table-driven tests for multiple scenarios:
func TestTranslate(t *testing.T) {
    tests := []struct {
        name     string
        input    string
        expected string
        wantErr  bool
    }{
        {
            name:     "simple translation",
            input:    "Hello",
            expected: "ไฝ ๅฅฝ",
            wantErr:  false,
        },
        // More test cases...
    }

    for _, tt := range tests {
        t.Run(tt.name, func(t *testing.T) {
            result, err := Translate(tt.input)
            if (err != nil) != tt.wantErr {
                t.Errorf("Translate() error = %v, wantErr %v", err, tt.wantErr)
                return
            }
            if result != tt.expected {
                t.Errorf("Translate() = %v, want %v", result, tt.expected)
            }
        })
    }
}

Committing Changes

We follow Conventional Commits:

<type>(<scope>): <subject>

<body>

<footer>

Types:

  • feat: New feature
  • fix: Bug fix
  • docs: Documentation changes
  • test: Adding or updating tests
  • refactor: Code refactoring
  • perf: Performance improvements
  • chore: Maintenance tasks
  • ci: CI/CD changes

Examples:

# Feature
git commit -m "feat(translator): add support for custom prompts"

# Bug fix
git commit -m "fix(format): preserve markdown bold syntax in translations"

# Documentation
git commit -m "docs(readme): add troubleshooting section"

# Multiple changes
git commit -m "feat(reflection): optimize quality check algorithm

- Reduce API calls by 30%
- Add batch processing for issues
- Improve error handling

Closes #123"

Submitting a Pull Request

  1. Update your branch

    git fetch upstream
    git rebase upstream/main
    
  2. Push to your fork

    git push origin feature/your-feature-name
    
  3. Create Pull Request

    • Go to the original repository on GitHub
    • Click "New Pull Request"
    • Select your fork and branch
    • Fill in the PR template
  4. PR Checklist

    • Tests pass (go test ./...)
    • Code is formatted (gofmt -w .)
    • Documentation is updated
    • Commit messages follow conventions
    • PR description explains changes clearly
    • Linked to related issues (if any)

PR Review Process

  1. Automated checks run (tests, linting)
  2. Maintainers review your code
  3. Address feedback if requested
  4. Approval by at least one maintainer
  5. Merge by maintainer

๐Ÿ—๏ธ Project Structure

Understanding the codebase:

jta/
โ”œโ”€โ”€ cmd/
โ”‚   โ””โ”€โ”€ jta/
โ”‚       โ””โ”€โ”€ main.go          # CLI entry point
โ”œโ”€โ”€ internal/
โ”‚   โ”œโ”€โ”€ cli/                 # Command-line interface
โ”‚   โ”‚   โ”œโ”€โ”€ app.go           # Main application logic
โ”‚   โ”‚   โ””โ”€โ”€ root.go          # Cobra root command
โ”‚   โ”œโ”€โ”€ domain/              # Domain models
โ”‚   โ”‚   โ”œโ”€โ”€ language.go      # Language definitions
โ”‚   โ”‚   โ”œโ”€โ”€ terminology.go   # Terminology models
โ”‚   โ”‚   โ””โ”€โ”€ translation.go   # Translation models
โ”‚   โ”œโ”€โ”€ provider/            # AI provider implementations
โ”‚   โ”‚   โ”œโ”€โ”€ openai.go        # OpenAI integration
โ”‚   โ”‚   โ”œโ”€โ”€ anthropic.go     # Anthropic integration
โ”‚   โ”‚   โ””โ”€โ”€ google.go        # Google Gemini integration
โ”‚   โ”œโ”€โ”€ translator/          # Translation engine
โ”‚   โ”‚   โ”œโ”€โ”€ engine.go        # Core translation logic
โ”‚   โ”‚   โ”œโ”€โ”€ batch.go         # Batch processor
โ”‚   โ”‚   โ””โ”€โ”€ reflection.go    # Reflection mechanism โญ
โ”‚   โ”œโ”€โ”€ terminology/         # Terminology management
โ”‚   โ”‚   โ”œโ”€โ”€ manager.go       # Terminology manager
โ”‚   โ”‚   โ”œโ”€โ”€ detector.go      # LLM-based detection
โ”‚   โ”‚   โ””โ”€โ”€ repository.go    # JSON storage
โ”‚   โ”œโ”€โ”€ format/              # Format protection
โ”‚   โ”‚   โ””โ”€โ”€ protector.go     # Format element preservation
โ”‚   โ”œโ”€โ”€ incremental/         # Incremental translation
โ”‚   โ”‚   โ””โ”€โ”€ translator.go    # Diff analysis
โ”‚   โ”œโ”€โ”€ keyfilter/           # Key filtering
โ”‚   โ”‚   โ”œโ”€โ”€ filter.go        # Filter logic
โ”‚   โ”‚   โ””โ”€โ”€ matcher.go       # Pattern matching
โ”‚   โ”œโ”€โ”€ rtl/                 # RTL language support
โ”‚   โ”‚   โ””โ”€โ”€ processor.go     # Bidirectional text handling
โ”‚   โ”œโ”€โ”€ ui/                  # Terminal UI
โ”‚   โ”‚   โ”œโ”€โ”€ styles.go        # Lipgloss styles
โ”‚   โ”‚   โ””โ”€โ”€ printer.go       # Styled output
โ”‚   โ””โ”€โ”€ utils/               # Utilities
โ”‚       โ””โ”€โ”€ json.go          # JSON helpers
โ”œโ”€โ”€ examples/                # Example files
โ”‚   โ””โ”€โ”€ en.json              # Sample source file
โ”œโ”€โ”€ go.mod                   # Go modules
โ”œโ”€โ”€ go.sum                   # Dependencies
โ”œโ”€โ”€ README.md                # Main documentation
โ”œโ”€โ”€ CONTRIBUTING.md          # This file
โ”œโ”€โ”€ LICENSE                  # MIT License
โ””โ”€โ”€ EXECUTION_PLAN.md        # Development roadmap

๐ŸŽฏ Areas Needing Help

Current priorities:

High Priority

  • Provider tests: Add unit tests for AI provider implementations
  • Terminology tests: Test terminology detection and management
  • Integration tests: End-to-end translation workflows
  • Error handling: Improve error messages and recovery

Medium Priority

  • Performance optimization: Profile and optimize hot paths
  • Memory efficiency: Reduce memory usage for large files
  • Better progress indicators: Real-time translation progress
  • Configuration file support: YAML/TOML config files

Low Priority

  • Additional providers: Azure OpenAI, local models
  • Alternative formats: YAML, XML, PO file support
  • Translation memory: TMX integration
  • Web UI: Browser-based interface

๐Ÿ› Bug Reports

Before Submitting

  1. Search existing issues to avoid duplicates
  2. Try the latest version to see if it's already fixed
  3. Collect information:
    • Jta version (jta --version)
    • Go version (go version)
    • Operating system
    • Steps to reproduce
    • Expected vs actual behavior
    • Error messages and logs

Bug Report Template

## Bug Description
A clear description of what the bug is.

## To Reproduce
Steps to reproduce the behavior:
1. Run command '...'
2. With file '...'
3. See error

## Expected Behavior
What you expected to happen.

## Actual Behavior
What actually happened.

## Environment
- Jta version: x.y.z
- Go version: 1.25.0
- OS: macOS 14.0
- Provider: OpenAI GPT-4o

## Logs

Paste relevant error messages or logs here


## Additional Context
Any other context about the problem.

๐Ÿ’ก Feature Requests

Before Requesting

  1. Search existing issues to see if it's already requested
  2. Consider if it fits the project's goals
  3. Think about implementation complexity

Feature Request Template

## Feature Description
A clear description of the feature you'd like.

## Use Case
Explain why this feature would be useful.
Example scenarios where you'd use it.

## Proposed Solution
How you envision this working.

## Alternatives Considered
Other approaches you've thought about.

## Additional Context
Mockups, examples, or references.

๐Ÿ“š Documentation

Documentation improvements are always welcome!

Types of Documentation

  • README.md: User-facing documentation
  • Code comments: Inline documentation (godoc)
  • Wiki: Detailed guides and tutorials
  • Examples: Sample code and usage patterns

Writing Guidelines

  • Use clear, simple language
  • Include code examples
  • Add screenshots/GIFs for UI features
  • Keep it up-to-date with code changes

๐Ÿค Code Review

For Contributors

  • Be patient and respectful
  • Be open to feedback
  • Ask questions if unclear
  • Don't take criticism personally
  • Learn from the review process

For Reviewers

  • Be constructive and helpful
  • Explain why changes are needed
  • Suggest alternatives
  • Acknowledge good work
  • Be timely in responses

๐Ÿ“œ Code of Conduct

Our Standards

  • Be respectful: Treat everyone with respect
  • Be inclusive: Welcome diverse perspectives
  • Be collaborative: Work together constructively
  • Be professional: Maintain professionalism

Unacceptable Behavior

  • Harassment or discrimination
  • Trolling or insulting comments
  • Personal or political attacks
  • Publishing private information
  • Other unprofessional conduct

Enforcement

Violations may result in:

  1. Warning
  2. Temporary ban
  3. Permanent ban

Report issues to: conduct@example.com

๐ŸŽ“ Learning Resources

Go Programming

AI/LLM Integration

Testing

๐Ÿ’ฌ Communication

Channels

  • GitHub Issues: Bug reports and feature requests
  • GitHub Discussions: General questions and ideas
  • Pull Requests: Code contributions and reviews

Getting Help

๐Ÿ™ Thank You!

Every contribution, no matter how small, helps make Jta better. We appreciate your time and effort!


Questions? Feel free to ask in Discussions

Happy Contributing! ๐ŸŽ‰