nowo-tech / translation-yaml-tools-bundle
Symfony console tools for YAML translations: nested tree conversion, key sorting, and machine translation for missing keys (Google, DeepL, LibreTranslate; pluggable).
Package info
github.com/nowo-tech/TranslationYamlToolsBundle
Type:symfony-bundle
pkg:composer/nowo-tech/translation-yaml-tools-bundle
Requires
- php: >=8.1 <8.6
- symfony/config: ^6.0 || ^7.0 || ^8.0
- symfony/console: ^6.0 || ^7.0 || ^8.0
- symfony/dependency-injection: ^6.0 || ^7.0 || ^8.0
- symfony/framework-bundle: ^6.0 || ^7.0 || ^8.0
- symfony/http-client: ^6.0 || ^7.0 || ^8.0
- symfony/http-kernel: ^6.0 || ^7.0 || ^8.0
- symfony/translation: ^6.0 || ^7.0 || ^8.0
- symfony/yaml: ^6.0 || ^7.0 || ^8.0
Requires (Dev)
- doctrine/doctrine-bundle: ^2.10
- doctrine/orm: ^2.16 || ^3.0
- friendsofphp/php-cs-fixer: ^3.0
- phpstan/extension-installer: ^1.4
- phpstan/phpstan: ^2.0
- phpstan/phpstan-phpunit: ^2.0
- phpstan/phpstan-symfony: ^2.0
- phpunit/phpunit: ^10.0
- rector/rector: ^2.0
- symfony/browser-kit: ^6.0 || ^7.0 || ^8.0
- symfony/messenger: ^6.0 || ^7.0 || ^8.0
- symfony/security-csrf: ^6.0 || ^7.0 || ^8.0
- symfony/twig-bundle: ^6.0 || ^7.0 || ^8.0
Suggests
- doctrine/doctrine-bundle: Required to use missing_translation_log (entity mapping is prepended when the feature is enabled)
- doctrine/orm: Required with doctrine/doctrine-bundle to use missing_translation_log (runtime DB table for missing keys)
- symfony/flex: For automatic recipe installation (config and bundles.php)
- symfony/messenger: Optional: missing_translation_log.async_persist dispatches MissingTranslationBufferMessage; route it to an async transport to avoid in-process DB writes after flush
- symfony/security-csrf: Required for csrf_token() in the missing-log Twig UI (with framework.csrf_protection)
- symfony/twig-bundle: Required for missing_translation_log.web_ui (HTML list and mark-added forms)
README
⭐ Found this useful? Install from Packagist and consider starring the repository.
Symfony developer tools for YAML translation files: discover configured translation directories, convert flat dot-keys to a nested tree (with structural validation), flatten nested maps back to dot-keys at the file root, sort keys alphabetically, and fill missing keys in a target locale using Google Cloud Translation, DeepL, or LibreTranslate (pluggable MachineTranslatorInterface). The default source locale follows Symfony’s translator / kernel default locale (see docs/CONFIGURATION.md) unless you set nowo_translation_yaml_tools.default_locale.
Features
- Resolves translation paths from
translator.default_pathand fromconfig/packages/**/translation.yaml(framework.translator.default_pathandpaths). - Interactive console flow (arrow keys) to pick domain and locale, with non-interactive
--domain/--localeflags. nowo:translation-yaml:tree— validates that dot-keys can be represented as a tree; on failure prints the conflicting prefix.nowo:translation-yaml:flatten— writes a one-level map with dot-separated keys (inverse of the tree layout).nowo:translation-yaml:sort— recursive alphabetical sort of associative keys.nowo:translation-yaml:fill-missing— merges missing keys into a target locale using the configured machine translator (Google, DeepL, or LibreTranslate); optional--treeoutput with the same validation as the tree command.nowo:translation-yaml:audit— read-only report: tree-safe YAML, alphabetical key order, missing keys vs source locale; compact OK line per domain when everything passes.- Configurable YAML indent (
yaml_tree_indent) for dumps.
Requirements
- PHP
>=8.1 <8.6 - Symfony
^6.0 || ^7.0 || ^8.0(FrameworkBundle, Console, HttpClient, Yaml, …) - For fill-missing: enable
framework.http_client: true, choosemachine_translatorin config, and setGOOGLE_TRANSLATE_API_KEY(Google) orDEEPL_AUTH_KEY(DeepL) when using those backends; LibreTranslate needs no paid key for open instances (seedocs/CONFIGURATION.md).
Quick install
composer require --dev nowo-tech/translation-yaml-tools-bundle
Register the bundle in config/bundles.php for dev (Flex recipe does this). See Installation.
Demos (Symfony 7 & 8)
FrankenPHP sample apps live under demo/: Web Profiler, Twig Inspector (nowo-tech/twig-inspector-bundle), explicit framework.enabled_locales / translator configuration, two translation directories (translations/ + translations_extra/), and a web page at / that summarizes default locale, enabled locales, YAML paths, missing files per domain, and missing keys vs the default locale. In dev, the demos also enable missing_translation_log (SQLite, event_dispatcher flush strategy, optional Web UI) — see demo/README.md.
make -C demo up-symfony7 # default PORT 8037 — see demo/symfony7/.env.example make -C demo up-symfony8 # default PORT 8038
FrankenPHP worker mode: Supported in production Caddyfile; development uses Caddyfile.dev without worker (see docs/DEMO-FRANKENPHP.md).
Documentation
Additional documentation
Tests and coverage
- PHP: run
make test-coverageand read the finalGlobal PHP coverage (Lines): …line in the output. - TS/JS: N/A
- Python: N/A
Version information
See SECURITY POLICY for supported versions.
License
This bundle is released under the MIT License. See LICENSE.