craue/translations-tests
Shared test utilities for Symfony translation files. Provides a base YamlTranslationsTest to validate YAML translations across your project. Configure default locale and translation file paths, then run in your test suite to catch missing keys and locale issues early.
Resources/translations/, Symfony’s Translation component, and framework.yaml configuration). Laravel’s translation system (JSON/YAML/array files in resources/lang/, TranslationServiceProvider, and trans() helper) is fundamentally different, making direct integration impossible without refactoring.spatie/laravel-translation-loader or custom Pest/PHPUnit tests for similar validation, but a Laravel-native adaptation could fill a gap if existing solutions are insufficient.symfony/translation and configuring it alongside Laravel’s system would create architectural pollution and conflict risks (e.g., duplicate translation files, service provider collisions).glob(__DIR__ . '/../../Resources/translations/*.yml')) would need complete rewrites to target Laravel’s resources/lang/ structure.JsonLoader, ArrayLoader).en → es → default).trans() with dynamic keys).spatie/laravel-translation-loader, custom Pest tests) insufficient? If not, this package adds no value.resources/lang/ files in <1 hour:
test('all translation files are valid JSON/YAML')
->files(app()->langPath())
->each(function ($file) {
$content = file_get_contents($file);
// Validate syntax, missing keys, etc.
});
Resources/translations/, Laravel → resources/lang/.framework.yaml, Laravel → config/app.php.translator service vs. Laravel’s trans() facade.Translation component, which Laravel does not use.symfony/translation installed manually), the package might work for Symfony-specific translations only, but this is non-standard and unsupported.resources/lang/ for all supported formats (JSON/YAML/PHP).File facade or Storage to read files.// tests/TranslationValidator.php
use Pest\TestCase;
use Illuminate\Support\Facades\File;
test('all translation files are valid', function () {
$files = File::allFiles(app()->langPath());
foreach ($files as $file) {
$content = File::get($file);
$locale = $file->getRelativePathname();
// Custom validation (e.g., check for untranslated keys)
expect($content)->toBeValidYaml(); // Or JSON/PHP
}
});
laravel-translation-validator) with:
symfony/translation manually:
composer require symfony/translation
Translation component in config/services.php:
$this->app->register(\Symfony\Component\Translation\TranslationServiceProvider::class);
resources/lang/ files.lang:validate command for CLI checks.// app/Console/Commands/ValidateTranslations.php
use Illuminate\Console\Command;
use Illuminate\Support\Facades\File;
class ValidateTranslations extends Command
{
public function handle()
{
$files = File::allFiles(app()->langPath());
foreach ($files as $file) {
$content = File::get($file);
if (!is_valid_yaml($content)) {
$this->error("Invalid YAML in {$file->getPathname()}");
}
}
}
}
How can I help you explore Laravel packages today?