|
| 1 | +# Contributing to LocaleSync |
| 2 | + |
| 3 | +Thank you for your interest in contributing! This document provides guidelines and information for contributors. |
| 4 | + |
| 5 | +## Getting Started |
| 6 | + |
| 7 | +### Prerequisites |
| 8 | + |
| 9 | +- Python 3.12 or higher |
| 10 | +- Git |
| 11 | + |
| 12 | +### Setting Up the Development Environment |
| 13 | + |
| 14 | +```bash |
| 15 | +# 1. Clone the repository |
| 16 | +git clone https://github.com/polprog-tech/LocaleSync.git |
| 17 | +cd LocaleSync |
| 18 | + |
| 19 | +# 2. (Recommended) Create a virtual environment |
| 20 | +python3 -m venv .venv |
| 21 | +source .venv/bin/activate # Linux/macOS |
| 22 | +# .venv\Scripts\activate # Windows |
| 23 | + |
| 24 | +# 3. Install in editable mode with dev dependencies |
| 25 | +pip install -e ".[dev]" |
| 26 | + |
| 27 | +# 4. Verify the installation |
| 28 | +locale-sync --version |
| 29 | +pytest |
| 30 | +``` |
| 31 | + |
| 32 | +## Development Workflow |
| 33 | + |
| 34 | +### Running Tests |
| 35 | + |
| 36 | +```bash |
| 37 | +# All tests |
| 38 | +pytest |
| 39 | + |
| 40 | +# With verbose output |
| 41 | +pytest -v |
| 42 | + |
| 43 | +# With coverage |
| 44 | +pytest --cov=locale_sync --cov-report=term-missing |
| 45 | + |
| 46 | +# Specific test file or class |
| 47 | +pytest tests/unit/domain/test_models.py |
| 48 | +pytest tests/unit/domain/test_models.py::TestLocaleKey |
| 49 | +``` |
| 50 | + |
| 51 | +### Linting |
| 52 | + |
| 53 | +```bash |
| 54 | +ruff check src/ tests/ |
| 55 | +ruff format --check src/ tests/ |
| 56 | + |
| 57 | +# Auto-fix |
| 58 | +ruff check --fix src/ tests/ |
| 59 | +ruff format src/ tests/ |
| 60 | +``` |
| 61 | + |
| 62 | +### Testing with the Playground |
| 63 | + |
| 64 | +```bash |
| 65 | +locale-sync scan playground/locales |
| 66 | +locale-sync check playground/locales |
| 67 | +locale-sync sync playground/locales --dry-run |
| 68 | +``` |
| 69 | + |
| 70 | +## Architecture |
| 71 | + |
| 72 | +Please read [docs/architecture.md](docs/architecture.md) before making changes. Key principles: |
| 73 | + |
| 74 | +1. **Domain layer** (`src/locale_sync/domain/`) has zero external dependencies |
| 75 | +2. **Application layer** orchestrates but does not import infrastructure directly at module level |
| 76 | +3. **Infrastructure layer** implements domain contracts (Protocols) |
| 77 | +4. **CLI layer** is a thin adapter between user input and application use cases |
| 78 | + |
| 79 | +### Where to Put New Code |
| 80 | + |
| 81 | +| What | Where | |
| 82 | +|------|-------| |
| 83 | +| New model/value object | `domain/models.py` | |
| 84 | +| New contract/interface | `domain/contracts.py` | |
| 85 | +| New exception type | `domain/exceptions.py` | |
| 86 | +| New file format parser | `infrastructure/parsers/` | |
| 87 | +| New file format writer | `infrastructure/writers/` | |
| 88 | +| New translation provider | `infrastructure/translators/` | |
| 89 | +| New report format | `infrastructure/reporters/` | |
| 90 | +| New CLI command | `cli/commands/` | |
| 91 | +| New use case | `application/` | |
| 92 | + |
| 93 | +### Adding a Translation Provider |
| 94 | + |
| 95 | +See [docs/extensibility.md](docs/extensibility.md) for detailed guidance. |
| 96 | + |
| 97 | +## Pull Request Process |
| 98 | + |
| 99 | +1. Fork the repository and create a feature branch from `main` |
| 100 | +2. Make your changes following the architecture guidelines |
| 101 | +3. Add tests for new functionality |
| 102 | +4. Ensure all tests pass: `pytest` |
| 103 | +5. Ensure linting passes: `ruff check src/ tests/` |
| 104 | +6. Update documentation if needed |
| 105 | +7. Submit a pull request using the PR template |
| 106 | + |
| 107 | +### Commit Messages |
| 108 | + |
| 109 | +Use conventional commit style: |
| 110 | + |
| 111 | +``` |
| 112 | +feat: add YAML format support |
| 113 | +fix: handle empty nested objects in JSON parser |
| 114 | +docs: update extensibility guide with YAML example |
| 115 | +test: add edge case tests for placeholder detection |
| 116 | +refactor: extract common file resolution logic |
| 117 | +``` |
| 118 | + |
| 119 | +## Code Style |
| 120 | + |
| 121 | +- Full type hints on all function signatures |
| 122 | +- Docstrings on public classes and functions |
| 123 | +- Use `from __future__ import annotations` in all modules |
| 124 | +- Follow existing patterns in the codebase |
| 125 | +- Let `ruff` handle formatting |
| 126 | + |
| 127 | +## Reporting Issues |
| 128 | + |
| 129 | +Use the GitHub issue templates: |
| 130 | +- **Bug reports** — include reproduction steps, expected vs actual behavior, and environment details |
| 131 | +- **Feature requests** — describe the problem, proposed solution, and alternatives considered |
| 132 | + |
| 133 | +## License |
| 134 | + |
| 135 | +By contributing, you agree that your contributions will be licensed under the same license as the project (MIT). |
0 commit comments