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.
This repository contains just some common code for testing translations in your Symfony project.
Let Composer download and install the bundle by running
composer require --dev craue/translations-tests
in a shell.
// src/app/Tests/TranslationsTest.php
namespace Application\Tests;
use Craue\TranslationsTests\YamlTranslationsTest;
/**
* @group unit
*/
class TranslationsTest extends YamlTranslationsTest {
// only add this method to override the default implementation returning "en"
protected function defineDefaultLocale() : string {
return 'de';
}
// specify all locations with translation files
protected function defineTranslationFiles() : array {
return array_merge(
glob(__DIR__ . '/../../Resources/translations/*.yml'),
glob(__DIR__ . '/../../Resources/*Bundle/translations/*.yml'),
glob(__DIR__ . '/../../../src/*/*Bundle/Resources/translations/*.yml')
);
}
}
How can I help you explore Laravel packages today?