Skip to content

Latest commit

Β 

History

History
122 lines (87 loc) Β· 4.84 KB

README.md

File metadata and controls

122 lines (87 loc) Β· 4.84 KB

Composer Translation DeepL

Coverage CGL Tests Supported PHP Versions

Autofill missing translations using the DeepL API.

A lightweight Composer package that automatically completes missing translations in your project translation files.

Warning

This package is in early development stage and may change significantly in the future. I am working steadily to release a stable version as soon as possible.

✨ Features

  • Automatic Translation - Uses DeepL API to fill missing translation keys
  • Batch Processing - Translates up to 50 keys per API request for optimal performance
  • Multiple Formats - XLIFF, YAML, JSON, PHP support
  • TYPO3 Compatible - Works with TYPO3 XLIFF format
  • Symfony/Laravel Ready - Supports standard translation file structures
  • Dry-Run Mode - Preview changes before applying
  • Progress Tracking - Visual progress bar and detailed statistics
  • API Usage Display - Shows your DeepL character usage
  • XLIFF Marking - State marking for auto-translated content

Note

This package is a feature addon for finding missing translations with the composer-translation-validator plugin.

πŸ”₯ Installation

Prerequisites

Composer

Packagist Packagist Downloads

composer require move-elevator/composer-translation-deepl

πŸ“Š Usage

Basic Usage

# Set your DeepL API key
export DEEPL_API_KEY=your-api-key-here

# Translate to German
vendor/bin/autotranslate translations/ -t de
# Or via Composer
composer autotranslate translations/ -- -t de
# Or direct PHP execution
php bin/autotranslate -t de

Advanced Options

# Translate a single file
vendor/bin/autotranslate translations/messages.en.xlf -t de

# Translate to multiple languages
vendor/bin/autotranslate translations/ -t de -t fr -t es

# Custom source locale
vendor/bin/autotranslate -s en-US -t de-DE

# Specific format
vendor/bin/autotranslate -t de -f yaml

# Custom domain
vendor/bin/autotranslate -t de --domain validators

Command Options

vendor/bin/autotranslate <path> [options]
Option Short Description Default
path Path to translation file or directory translations/
--source-locale -s Source locale en
--target-locales -t Target locales (multiple) required
--api-key -k DeepL API key DEEPL_API_KEY env
--format -f File format (xliff, yaml, json, php) xliff
--domain - Translation domain messages
--dry-run -d Simulate without writing false
--force - Overwrite without confirmation false
--no-mark-auto-translated - Disable XLIFF state marking false (marking enabled)
--verbose -v Detailed output false
--quiet -q Only errors false

Supported File Formats

Translation files are detected and processed based on their format:

Format Frameworks Example files
XLIFF TYPO3 CMS, Symfony locallang.xlf, de.locallang.xlf, messages.de.xlf
YAML Symfony messages.en.yaml, messages.de.yaml
JSON Laravel, Symfony messages.en.json, messages.de.json
PHP Laravel en/messages.php, messages.en.php

πŸ§‘β€πŸ’» Contributing

Please have a look at CONTRIBUTING.md.

⭐ License

This project is licensed under GNU General Public License 3.0 (or later).