EzLang is a command-line tool that automates the translation of PO (Portable Object) files using AWS Translate. It helps developers and translators manage internationalization by automatically translating untranslated entries, handling fuzzy translations, and maintaining proper PO file formatting.
- 🌍 Automatic translation using AWS Translate
- 🔄 Handles fuzzy translations (removes fuzzy flags and retranslates)
- 📝 Preserves PO file structure and formatting
- 🔀 Supports plural forms
- 📄 Handles multi-line translations
- ⚙️ Configuration via YAML file
- 🚀 High performance with proper error handling
- Go 1.16 or higher
- AWS Account with Translate service access
- AWS Access Key ID and Secret Access Key
- AWS Region where the Translate service is available
- Clone the repository:
git clone https://github.com/yourusername/ezlang.git
cd ezlang- Install dependencies:
go mod download- Build the application:
go build -o ezlang cmd/cli/main.goSet up your AWS credentials using environment variables:
export AWS_ACCESS_KEY_ID=your_access_key_here
export AWS_SECRET_ACCESS_KEY=your_secret_key_here
export AWS_REGION=ap-south-1 # or your preferred regionAlternatively, you can use AWS credentials file (~/.aws/credentials):
[default]
aws_access_key_id = your_access_key_here
aws_secret_access_key = your_secret_key_hereCreate a .ezlang.yml file in your project root:
files:
- path: "locale/en/LC_MESSAGES/django.po"
lang: "en"
- path: "locale/sv/LC_MESSAGES/django.po"
lang: "sv"Run with default configuration (.ezlang.yml):
./ezlangRun with custom configuration:
./ezlang --config custom-config.yml./ezlang [options]
Options:
--config string Path to configuration file (default ".ezlang.yml")
--rewrite string Rewrite main file. Default is false
--help Show help message# Translate PO files defined in .ezlang.yml
./ezlang
# Use custom configuration
./ezlang --config translations.yml
# Override output directory
./ezlang --rewrite- Reads PO Files: Parses PO files while preserving their structure
- Identifies Translations: Finds empty msgstr entries and fuzzy translations
- Translates Content: Uses AWS Translate to translate msgid to target language
- Preserves Formatting: Maintains original file structure, comments, and metadata
- Handles Special Cases: Properly processes plural forms and multi-line strings
- Removes Fuzzy Flags: Cleans up fuzzy markers after translation
ezlang/
├── .ezlang.yml
├── .gitignore
├── LICENSE
├── README.md
├── cmd
│ └── cli
│ └── main.go
├── go.mod
├── go.sum
├── internal
│ ├── application
│ │ └── services
│ │ └── file_service.go
│ └── config
│ └── config.go
└── pkg
├── po
│ └── po.go
└── translation
└── translation.go
Not implemented yet.
go test ./...# Build for current platform
go build -o ezlang cmd/cli/main.go
# Cross-compile for different platforms
GOOS=linux GOARCH=amd64 go build -o ezlang-linux cmd/cli/main.go
GOOS=darwin GOARCH=amd64 go build -o ezlang-mac cmd/cli/main.go
GOOS=windows GOARCH=amd64 go build -o ezlang.exe cmd/cli/main.go- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- AWS Translate for providing the translation service
- The Go community for excellent libraries and tools
For support, please open an issue in the GitHub repository or contact the maintainers.