prefix stringlengths 512 512 | suffix stringlengths 256 256 | middle stringlengths 14 229 | meta dict |
|---|---|---|---|
ponent\Console\Command\Command;
use Symfony\Component\Console\Completion\CompletionInput;
use Symfony\Component\Console\Completion\CompletionSuggestions;
use Symfony\Component\Console\Exception\RuntimeException;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use S... | halas@gmail.com>
* @author Javier Eguiluz <javier.eguiluz@gmail.com>
*/
#[AsCommand(name: 'lint:xliff', description: 'Lint an XLIFF file and outputs encountered errors')]
class XliffLintCommand extends Command
{
private string $format;
private bo | InvalidArgumentException;
use Symfony\Component\Translation\Util\XliffUtils;
/**
* Validates XLIFF files syntax and outputs encountered errors.
*
* @author Grégoire Pineau <lyrixx@lyrixx.info>
* @author Robin Chalas <robin.c | {
"filepath": "src/Symfony/Component/Translation/Command/XliffLintCommand.php",
"language": "php",
"file_size": 11091,
"cut_index": 921,
"middle_length": 229
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation\Tests;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Translation\DataCollectorTranslator;
use Symfony\Component\Translation\Loader\Arra... | count%' => 0]);
$collector->trans('bar_ru');
$collector->trans('bar_ru', ['foo' => 'bar']);
$expectedMessages = [];
$expectedMessages[] = [
'id' => 'foo',
'translation' => 'foo (en)',
'lo | ectMessages()
{
$collector = $this->createCollector();
$collector->setFallbackLocales(['fr', 'ru']);
$collector->trans('foo');
$collector->trans('bar');
$collector->trans('choice', ['% | {
"filepath": "src/Symfony/Component/Translation/Tests/DataCollectorTranslatorTest.php",
"language": "php",
"file_size": 3791,
"cut_index": 614,
"middle_length": 229
} |
n Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation\Tests;
use Symfony\Component\Translation\IdentityTranslator;
use Symfony\Contracts\Translation\Test\TranslatorT... | cale = \Locale::getDefault();
\Locale::setDefault('en');
}
protected function tearDown(): void
{
parent::tearDown();
\Locale::setDefault($this->defaultLocale);
}
public function getTranslator(): TranslatorInte | {
parent::setUp();
$this->defaultLo | {
"filepath": "src/Symfony/Component/Translation/Tests/IdentityTranslatorTest.php",
"language": "php",
"file_size": 951,
"cut_index": 582,
"middle_length": 52
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation\Tests;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Translation\Exception\InvalidArgume... | InvalidArgumentException::class);
(new LocaleFallbackProvider())->computeFallbackLocales('invalid locale!');
}
public function testComputeFallbackLocalesShortensSubTags()
{
$provider = new LocaleFallbackProvider();
$t | $this->expectException(InvalidArgumentException::class);
new LocaleFallbackProvider(['en', 'invalid locale!']);
}
public function testComputeFallbackLocalesValidatesLocale()
{
$this->expectException( | {
"filepath": "src/Symfony/Component/Translation/Tests/LocaleFallbackProviderTest.php",
"language": "php",
"file_size": 4034,
"cut_index": 614,
"middle_length": 229
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation\Tests;
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Routing\RequestContext;
use... | blic function testCanSwitchLocale()
{
\Locale::setDefault('en');
$service = new DummyLocaleAware('en');
$switcher = new LocaleSwitcher('en', [$service]);
$this->assertSame('en', \Locale::getDefault());
$this->a | string $intlLocale;
protected function setUp(): void
{
$this->intlLocale = \Locale::getDefault();
}
protected function tearDown(): void
{
\Locale::setDefault($this->intlLocale);
}
pu | {
"filepath": "src/Symfony/Component/Translation/Tests/LocaleSwitcherTest.php",
"language": "php",
"file_size": 3129,
"cut_index": 614,
"middle_length": 229
} |
ony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation\Tests;
use PHPUnit\Framework\TestCase;
use Psr\Log\LoggerInterface;
use Symfony\Component\Translation\LoggingTranslator;
use Symfony\Co... | 1))
->method('warning')
->with('Translation not found.')
;
$translator = new Translator('ar');
$loggableTranslator = new LoggingTranslator($translator, $logger);
$loggableTranslator->trans('bar');
| ce::class);
$logger->expects($this->exactly( | {
"filepath": "src/Symfony/Component/Translation/Tests/LoggingTranslatorTest.php",
"language": "php",
"file_size": 920,
"cut_index": 606,
"middle_length": 52
} |
Exception\LogicException;
use Symfony\Component\Translation\MessageCatalogue;
class MessageCatalogueTest extends TestCase
{
public function testGetLocale()
{
$catalogue = new MessageCatalogue('en');
$this->assertEquals('en', $catalogue->getLocale());
}
public function testGetDomains()... | sertEquals(['foo' => 'foo'], $catalogue->all('domain1'));
$this->assertEquals([], $catalogue->all('domain88'));
$this->assertEquals($messages, $catalogue->all());
$messages = ['domain1+intl-icu' => ['foo' => 'bar']] + $messages + [ | 2', 'domain3'], $catalogue->getDomains());
}
public function testAll()
{
$catalogue = new MessageCatalogue('en', $messages = ['domain1' => ['foo' => 'foo'], 'domain2' => ['bar' => 'bar']]);
$this->as | {
"filepath": "src/Symfony/Component/Translation/Tests/MessageCatalogueTest.php",
"language": "php",
"file_size": 10469,
"cut_index": 921,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\Translation\Tests;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Translation\IdentityTranslator;
use Symfony\Component\Translation\PseudoLocalizationTranslator;
final class PseudoLocalizationTranslator... | AR</p>'], // Test defaults
['before <div data-label="fcy"><a href="#" title="bar" data-content="ccc">foo</a></div> after', 'before <div data-label="fcy"><a href="#" title="bar" data-content="ccc">foo</a></div> after', self::getIsolatedOptions([ | rtSame($expected, (new PseudoLocalizationTranslator(new IdentityTranslator(), $options))->trans($input));
}
public static function provideTrans(): array
{
return [
['[ƒöö⭐ ≤þ≥ƁÅŔ≤⁄þ≥]', 'foo⭐ <p>B | {
"filepath": "src/Symfony/Component/Translation/Tests/PseudoLocalizationTranslatorTest.php",
"language": "php",
"file_size": 6112,
"cut_index": 716,
"middle_length": 229
} |
ony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation\Tests;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Translation\Loader\ArrayLoader;
use Symfony\Component\Translation\StaticMe... | $translator->addResource('array', [
'Symfony is great!' => 'Symfony est super !',
], 'fr', '');
$translatable = new StaticMessage('Symfony is great!');
$this->assertSame('Symfony is great!', $translatable->trans($tr | slator->addLoader('array', new ArrayLoader());
| {
"filepath": "src/Symfony/Component/Translation/Tests/StaticMessageTest.php",
"language": "php",
"file_size": 940,
"cut_index": 606,
"middle_length": 52
} |
ge.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation\Tests;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Sy... | dLoader('array', new ArrayLoader());
$translator->addResource('array', $translation, $locale, $translatable->getDomain());
$this->assertSame($expected, $translatable->trans($translator, $locale));
}
#[DataProvider('getFlattenedTra | #[DataProvider('getTransTests')]
public function testTrans(string $expected, TranslatableMessage $translatable, array $translation, string $locale)
{
$translator = new Translator('en');
$translator->ad | {
"filepath": "src/Symfony/Component/Translation/Tests/TranslatableTest.php",
"language": "php",
"file_size": 2833,
"cut_index": 563,
"middle_length": 229
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation;
use Symfony\Component\HttpKernel\CacheWarmer\WarmableInterface;
use Symfony\Contracts\Service\ResetInterface;
use Symfony\Contracts\Translatio... | private array $messages = [];
public function __construct(
private TranslatorInterface&TranslatorBagInterface&LocaleAwareInterface $translator,
) {
}
public function reset(): void
{
$this->messages = [];
}
pu | TranslatorInterface, TranslatorBagInterface, LocaleAwareInterface, WarmableInterface, ResetInterface
{
public const MESSAGE_DEFINED = 0;
public const MESSAGE_MISSING = 1;
public const MESSAGE_EQUALS_FALLBACK = 2;
| {
"filepath": "src/Symfony/Component/Translation/DataCollectorTranslator.php",
"language": "php",
"file_size": 4305,
"cut_index": 614,
"middle_length": 229
} |
ge.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation;
use Symfony\Component\Routing\RequestContext;
use Symfony\Contracts\Translation\LocaleAware... | efaultLocale = $locale;
}
public function setLocale(string $locale): void
{
// Silently ignore if the intl extension is not loaded
try {
if (class_exists(\Locale::class, false)) {
\Locale::setDefault | rface[] $localeAwareServices
*/
public function __construct(
private string $locale,
private iterable $localeAwareServices,
private ?RequestContext $requestContext = null,
) {
$this->d | {
"filepath": "src/Symfony/Component/Translation/LocaleSwitcher.php",
"language": "php",
"file_size": 2071,
"cut_index": 563,
"middle_length": 229
} |
hor Fabien Potencier <fabien@symfony.com>
*/
class MessageCatalogue implements MessageCatalogueInterface, MetadataAwareInterface, CatalogueMetadataAwareInterface
{
private array $metadata = [];
private array $catalogueMetadata = [];
private array $resources = [];
private ?MessageCatalogueInterface $fal... | foreach ($this->messages as $domain => $messages) {
if (str_ends_with($domain, self::INTL_DOMAIN_SUFFIX)) {
$domain = substr($domain, 0, -\strlen(self::INTL_DOMAIN_SUFFIX));
}
$domains[$domain] = $dom | te string $locale,
private array $messages = [],
) {
}
public function getLocale(): string
{
return $this->locale;
}
public function getDomains(): array
{
$domains = [];
| {
"filepath": "src/Symfony/Component/Translation/MessageCatalogue.php",
"language": "php",
"file_size": 10028,
"cut_index": 921,
"middle_length": 229
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation;
use Symfony\Component\Config\Resource\ResourceInterface;
/**
* MessageCatalogueInterface.
*
* @author Fabien Potencier <fabien@symfony.com... | ring $domain = null): array;
/**
* Sets a message translation.
*
* @param string $id The message id
* @param string $translation The messages translation
* @param string $domain The domain name
*/
public | /**
* Gets the domains.
*/
public function getDomains(): array;
/**
* Gets the messages within a given domain.
*
* If $domain is null, it returns all messages.
*/
public function all(?st | {
"filepath": "src/Symfony/Component/Translation/MessageCatalogueInterface.php",
"language": "php",
"file_size": 3352,
"cut_index": 614,
"middle_length": 229
} |
This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation;
use Symfony\Contracts\Translation\TranslatableInterf... | public function getParameters(): array
{
return $this->parameters;
}
public function getDomain(): ?string
{
return $this->domain;
}
public function trans(TranslatorInterface $translator, ?string $locale = null): st | _construct(
private string $message,
private array $parameters = [],
private ?string $domain = null,
) {
}
public function getMessage(): string
{
return $this->message;
}
| {
"filepath": "src/Symfony/Component/Translation/TranslatableMessage.php",
"language": "php",
"file_size": 1363,
"cut_index": 524,
"middle_length": 229
} |
ranslator should only be used in a development environment.
*/
final class PseudoLocalizationTranslator implements TranslatorInterface, TranslatorBagInterface
{
private const EXPANSION_CHARACTER = '~';
private bool $accents;
private float $expansionFactor;
private bool $brackets;
private bool $par... | t
* default: 1
* validation: it must be greater than or equal to 1
* description: expand the translated string by the given factor with spaces and tildes
* example: if 2, "foo" => "~foo ~"
*
* * brackets:
| true
* description: replace ASCII characters of the translated string with accented versions or similar characters
* example: if true, "foo" => "ƒöö".
*
* * expansion_factor:
* type: floa | {
"filepath": "src/Symfony/Component/Translation/PseudoLocalizationTranslator.php",
"language": "php",
"file_size": 12097,
"cut_index": 921,
"middle_length": 229
} |
n Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation\Exception;
use Symfony\Contracts\HttpClient\ResponseInterface;
/**
* @author Fabien Potencier <fabien@symfony... | ode = 0,
?\Exception $previous = null,
) {
$this->debug = $response->getInfo('debug') ?? '';
parent::__construct($message, $code, $previous);
}
public function getResponse(): ResponseInterface
{
return $thi | private ResponseInterface $response,
int $c | {
"filepath": "src/Symfony/Component/Translation/Exception/ProviderException.php",
"language": "php",
"file_size": 992,
"cut_index": 582,
"middle_length": 52
} |
ge.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation\Exception;
use Symfony\Component\Translation\Bridge;
use Symfony\Component\Translation\Provi... | r',
],
'lokalise' => [
'class' => Bridge\Lokalise\LokaliseProviderFactory::class,
'package' => 'symfony/lokalise-translation-provider',
],
'phrase' => [
'class' => Bridge\Phrase\PhraseProv | ory::class,
'package' => 'symfony/crowdin-translation-provider',
],
'loco' => [
'class' => Bridge\Loco\LocoProviderFactory::class,
'package' => 'symfony/loco-translation-provide | {
"filepath": "src/Symfony/Component/Translation/Exception/UnsupportedSchemeException.php",
"language": "php",
"file_size": 2064,
"cut_index": 563,
"middle_length": 229
} |
part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation\Provider;
use Symfony\Component\Translation\TranslatorBag;
use Sym... | mains = [],
) {
$this->locales = array_filter($locales);
}
public function __toString(): string
{
return (string) $this->provider;
}
public function write(TranslatorBagInterface $translatorBag): void
{
| ano <msantostefano@protonmail.com>
*/
class FilteringProvider implements ProviderInterface
{
public function __construct(
private ProviderInterface $provider,
private array $locales,
private array $do | {
"filepath": "src/Symfony/Component/Translation/Provider/FilteringProvider.php",
"language": "php",
"file_size": 1585,
"cut_index": 537,
"middle_length": 229
} |
is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation\Provider;
use Symfony\Component\Translation\Exception\Unsupporte... | n->getScheme()) {
return new NullProvider();
}
throw new UnsupportedSchemeException($dsn, 'null', $this->getSupportedSchemes());
}
protected function getSupportedSchemes(): array
{
return ['null'];
}
}
| : ProviderInterface
{
if ('null' === $ds | {
"filepath": "src/Symfony/Component/Translation/Provider/NullProviderFactory.php",
"language": "php",
"file_size": 843,
"cut_index": 535,
"middle_length": 52
} |
This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation\Provider;
use Symfony\Component\Translation\Exception... | roviders : iterator_to_array($providers);
}
public function __toString(): string
{
return '['.implode(',', array_keys($this->providers)).']';
}
public function has(string $name): bool
{
return isset($this->provider | ce>
*/
private array $providers;
/**
* @param array<string, ProviderInterface> $providers
*/
public function __construct(iterable $providers)
{
$this->providers = \is_array($providers) ? $p | {
"filepath": "src/Symfony/Component/Translation/Provider/TranslationProviderCollection.php",
"language": "php",
"file_size": 1401,
"cut_index": 524,
"middle_length": 229
} |
ge.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation\Writer;
use Symfony\Component\Translation\Dumper\DumperInterface;
use Symfony\Component\Tran... | [];
/**
* Adds a dumper to the writer.
*/
public function addDumper(string $format, DumperInterface $dumper): void
{
$this->dumpers[$format] = $dumper;
}
/**
* Obtains the list of supported formats.
*/
| ranslation messages.
*
* @author Michel Salib <michelsalib@hotmail.com>
*/
class TranslationWriter implements TranslationWriterInterface
{
/**
* @var array<string, DumperInterface>
*/
private array $dumpers = | {
"filepath": "src/Symfony/Component/Translation/Writer/TranslationWriter.php",
"language": "php",
"file_size": 2131,
"cut_index": 563,
"middle_length": 229
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation\DataCollector;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Da... | ivate DataCollectorTranslator $translator,
) {
}
public function lateCollect(): void
{
$messages = $this->sanitizeCollectedMessages($this->translator->getCollectedMessages());
$this->data += $this->computeCount($messages); | \Cloner\Data;
/**
* @author Abdellatif Ait boudad <a.aitboudad@gmail.com>
*
* @final
*/
class TranslationDataCollector extends DataCollector implements LateDataCollectorInterface
{
public function __construct(
pr | {
"filepath": "src/Symfony/Component/Translation/DataCollector/TranslationDataCollector.php",
"language": "php",
"file_size": 4551,
"cut_index": 614,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\Translation\Util;
use Symfony\Component\Translation\Exception\InvalidArgumentException;
use Symfony\Component\Translation\Exception\InvalidResourceException;
/**
* Provides some utility methods for XLIFF translation files, such as validating
* their cont... | ('xliff') as $xliff) {
$version = $xliff->attributes->getNamedItem('version');
if ($version) {
return $version->nodeValue;
}
$namespace = $xliff->attributes->getNamedItem('xmlns');
| *
* Defaults to 1.2 for backwards compatibility.
*
* @throws InvalidArgumentException
*/
public static function getVersionNumber(\DOMDocument $dom): string
{
foreach ($dom->getElementsByTagName | {
"filepath": "src/Symfony/Component/Translation/Util/XliffUtils.php",
"language": "php",
"file_size": 6060,
"cut_index": 716,
"middle_length": 229
} |
This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation\Loader;
use Symfony\Component\Translation\MessageCata... |
return $catalogue;
}
/**
* Flattens an nested array of translations.
*
* The scheme used is:
* 'key' => ['key2' => ['key3' => 'value']]
* Becomes:
* 'key.key2.key3' => 'value'
*/
private functio | mixed $resource, string $locale, string $domain = 'messages'): MessageCatalogue
{
$resource = $this->flatten($resource);
$catalogue = new MessageCatalogue($locale);
$catalogue->add($resource, $domain); | {
"filepath": "src/Symfony/Component/Translation/Loader/ArrayLoader.php",
"language": "php",
"file_size": 1487,
"cut_index": 524,
"middle_length": 229
} |
part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\PropertyAccess\Tests\Fixtures;
/**
* This class is a hand written simplified ... | $offset, $this->array);
}
public function offsetGet($offset): mixed
{
return $this->array[$offset];
}
public function offsetSet($offset, $value): void
{
if (null === $offset) {
$this->array[] = $value;
| te, \Countable
{
private $array;
public function __construct(?array $array = null)
{
$this->array = $array ?: [];
}
public function offsetExists($offset): bool
{
return \array_key_exists( | {
"filepath": "src/Symfony/Component/PropertyAccess/Tests/Fixtures/TraversableArrayObject.php",
"language": "php",
"file_size": 1571,
"cut_index": 537,
"middle_length": 229
} |
ge.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation;
use Symfony\Component\Translation\Exception\InvalidArgumentException;
/**
* Derives fallb... | *
* @throws InvalidArgumentException If a locale contains invalid characters
*/
public function __construct(
private array $localeFallbacks = [],
) {
foreach ($localeFallbacks as $locale) {
self::validateLoc | lidation.
*
* @author Matthias Pigulla <mp@webfactory.de>
*/
final class LocaleFallbackProvider
{
/**
* @param string[] $localeFallbacks List of fallback locales to add _after_ the ones derived from ICU information
| {
"filepath": "src/Symfony/Component/Translation/LocaleFallbackProvider.php",
"language": "php",
"file_size": 2833,
"cut_index": 563,
"middle_length": 229
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation;
use Symfony\Component\Translation\Catalogue\AbstractOperation;
use Symfony\Component\Translation\Catalogue\TargetOperation;
final class Trans... |
public function addBag(TranslatorBagInterface $bag): void
{
foreach ($bag->getCatalogues() as $catalogue) {
$this->addCatalogue($catalogue);
}
}
public function getCatalogue(?string $locale = null): MessageCata | if (null !== $existingCatalogue = $this->getCatalogue($catalogue->getLocale())) {
$catalogue->addCatalogue($existingCatalogue);
}
$this->catalogues[$catalogue->getLocale()] = $catalogue;
}
| {
"filepath": "src/Symfony/Component/Translation/TranslatorBag.php",
"language": "php",
"file_size": 3127,
"cut_index": 614,
"middle_length": 229
} |
ony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation;
use Symfony\Component\Translation\Exception\InvalidArgumentException;
/**
* @author Abdellatif Ait boudad <a.aitboudad@gmail.com>
*... | cters
*/
public function getCatalogue(?string $locale = null): MessageCatalogueInterface;
/**
* Returns all catalogues of the instance.
*
* @return MessageCatalogueInterface[]
*/
public function getCatalogues(): array; | gumentException If the locale contains invalid chara | {
"filepath": "src/Symfony/Component/Translation/TranslatorBagInterface.php",
"language": "php",
"file_size": 917,
"cut_index": 606,
"middle_length": 52
} |
he Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation\Provider;
use Symfony\Component\Translation\TranslatorBag;
use Symfony\Compo... | public function write(TranslatorBagInterface $translatorBag, bool $override = false): void
{
}
public function read(array $domains, array $locales): TranslatorBag
{
return new TranslatorBag();
}
public function delete(Tran | g(): string
{
return 'null';
}
| {
"filepath": "src/Symfony/Component/Translation/Provider/NullProvider.php",
"language": "php",
"file_size": 910,
"cut_index": 547,
"middle_length": 52
} |
ony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation\Provider;
use Symfony\Component\Translation\TranslatorBag;
use Symfony\Component\Translation\TranslatorBagInterface;
interface Provide... | ble on the provider only must be kept.
*/
public function write(TranslatorBagInterface $translatorBag): void;
public function read(array $domains, array $locales): TranslatorBag;
public function delete(TranslatorBagInterface $translatorB | * must be overwritten.
* Translations availa | {
"filepath": "src/Symfony/Component/Translation/Provider/ProviderInterface.php",
"language": "php",
"file_size": 927,
"cut_index": 606,
"middle_length": 52
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation\Util;
/**
* ArrayConverter generates tree like structure from a message catalogue.
* e.g. this
* 'foo.bar1' => 'test1',
* 'foo.bar2' =>... | ToTree(array $messages): array
{
$tree = [];
foreach ($messages as $id => $value) {
$referenceToElement = &self::getElementByPath($tree, self::getKeyParts($id));
$referenceToElement = $value;
unset | essages array to tree-like array.
* For example: ['foo.bar' => 'value'] will be converted to ['foo' => ['bar' => 'value']].
*
* @param array $messages Linear messages array
*/
public static function expand | {
"filepath": "src/Symfony/Component/Translation/Util/ArrayConverter.php",
"language": "php",
"file_size": 3760,
"cut_index": 614,
"middle_length": 229
} |
This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation;
/**
* This interface is used to get, set, and delet... |
*
* @return mixed The value that was set or an array with the domains/keys or null
*/
public function getCatalogueMetadata(string $key = '', string $domain = 'messages'): mixed;
/**
* Adds catalogue metadata to a message domai | .
*
* Passing an empty domain will return an array with all catalogue metadata indexed by
* domain and then by key. Passing an empty key will return an array with all
* catalogue metadata for the given domain. | {
"filepath": "src/Symfony/Component/Translation/CatalogueMetadataAwareInterface.php",
"language": "php",
"file_size": 1454,
"cut_index": 524,
"middle_length": 229
} |
This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation;
/**
* This interface is used to get, set, and delet... | n mixed The value that was set or an array with the domains/keys or null
*/
public function getMetadata(string $key = '', string $domain = 'messages'): mixed;
/**
* Adds metadata to a message domain.
*/
public function setMetada |
*
* Passing an empty domain will return an array with all metadata indexed by
* domain and then by key. Passing an empty key will return an array with all
* metadata for the given domain.
*
* @retur | {
"filepath": "src/Symfony/Component/Translation/MetadataAwareInterface.php",
"language": "php",
"file_size": 1376,
"cut_index": 524,
"middle_length": 229
} |
Config\ConfigCacheInterface;
use Symfony\Component\Translation\Exception\InvalidArgumentException;
use Symfony\Component\Translation\Exception\NotFoundResourceException;
use Symfony\Component\Translation\Exception\RuntimeException;
use Symfony\Component\Translation\Formatter\IntlFormatterInterface;
use Symfony\Componen... | gue::class);
/**
* @author Fabien Potencier <fabien@symfony.com>
*/
class Translator implements TranslatorInterface, TranslatorBagInterface, LocaleAwareInterface
{
/**
* @var MessageCatalogueInterface[]
*/
protected array $catalogues = | \Translation\LocaleAwareInterface;
use Symfony\Contracts\Translation\TranslatableInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
// Help opcache.preload discover always-needed symbols
class_exists(MessageCatalo | {
"filepath": "src/Symfony/Component/Translation/Translator.php",
"language": "php",
"file_size": 14064,
"cut_index": 921,
"middle_length": 229
} |
ge.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation\Provider;
use Symfony\Component\Translation\Exception\InvalidArgumentException;
use Symfony\... |
public function __construct(#[\SensitiveParameter] string $dsn)
{
$this->originalDsn = $dsn;
if (false === $params = parse_url($dsn)) {
throw new InvalidArgumentException('The translation provider DSN is invalid.');
| private ?string $scheme;
private ?string $host;
private ?string $user;
private ?string $password;
private ?int $port;
private ?string $path;
private array $options = [];
private string $originalDsn; | {
"filepath": "src/Symfony/Component/Translation/Provider/Dsn.php",
"language": "php",
"file_size": 2927,
"cut_index": 563,
"middle_length": 229
} |
part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation\Provider;
use Symfony\Component\Translation\Exception\UnsupportedS... | {
$providers = [];
foreach ($config as $name => $currentConfig) {
$providers[$name] = $this->fromDsnObject(
new Dsn($currentConfig['dsn']),
!$currentConfig['locales'] ? $this->enabledLocales : $cu | ace> $factories
*/
public function __construct(
private iterable $factories,
private array $enabledLocales,
) {
}
public function fromConfig(array $config): TranslationProviderCollection
| {
"filepath": "src/Symfony/Component/Translation/Provider/TranslationProviderCollectionFactory.php",
"language": "php",
"file_size": 1591,
"cut_index": 537,
"middle_length": 229
} |
part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation\Loader;
use Symfony\Component\Translation\Exception\NotFoundResour... | (\RuntimeException $e) {
throw new NotFoundResourceException(\sprintf('Error opening file "%s".', $resource), 0, $e);
}
$file->setFlags(\SplFileObject::READ_CSV | \SplFileObject::SKIP_EMPTY | \SplFileObject::DROP_NEW_LINE);
| iter = ';';
private string $enclosure = '"';
protected function loadResource(string $resource): array
{
$messages = [];
try {
$file = new \SplFileObject($resource, 'rb');
} catch | {
"filepath": "src/Symfony/Component/Translation/Loader/CsvFileLoader.php",
"language": "php",
"file_size": 1659,
"cut_index": 537,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\Translation\Tests\Provider;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Translation\Exception\InvalidArgumentException;
use Symfony\Component\Translation\Exception\MissingRequiredOptionException;
use ... | ;
$this->assertSame($scheme, $dsn->getScheme());
$this->assertSame($host, $dsn->getHost());
$this->assertSame($user, $dsn->getUser());
$this->assertSame($password, $dsn->getPassword());
$this->assertSame($port, $dsn | , string $host, ?string $user = null, ?string $password = null, ?int $port = null, array $options = [], ?string $path = null)
{
$dsn = new Dsn($dsnString);
$this->assertSame($dsnString, $dsn->getOriginalDsn()) | {
"filepath": "src/Symfony/Component/Translation/Tests/Provider/DsnTest.php",
"language": "php",
"file_size": 7272,
"cut_index": 716,
"middle_length": 229
} |
This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation\Tests\Loader;
use PHPUnit\Framework\TestCase;
use Sym... | $catalogue = $loader->load($resource, 'en', 'domain1');
$this->assertEquals(['foo' => 'bar'], $catalogue->all('domain1'));
$this->assertEquals('en', $catalogue->getLocale());
$this->assertEquals([new FileResource($resource)] | mfony\Component\Translation\Loader\PhpFileLoader;
class PhpFileLoaderTest extends TestCase
{
public function testLoad()
{
$loader = new PhpFileLoader();
$resource = __DIR__.'/../Fixtures/resources.php';
| {
"filepath": "src/Symfony/Component/Translation/Tests/Loader/PhpFileLoaderTest.php",
"language": "php",
"file_size": 1504,
"cut_index": 524,
"middle_length": 229
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation\Tests\Loader;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\Resource\FileResource;
use Symfony\Component\Translation\Exception\N... | this->assertEquals('en', $catalogue->getLocale());
$this->assertEquals([new FileResource($resource)], $catalogue->getResources());
}
public function testLoadPlurals()
{
$loader = new PoFileLoader();
$resource = __DIR__. | der();
$resource = __DIR__.'/../Fixtures/resources.po';
$catalogue = $loader->load($resource, 'en', 'domain1');
$this->assertEquals(['foo' => 'bar', 'bar' => 'foo'], $catalogue->all('domain1'));
$ | {
"filepath": "src/Symfony/Component/Translation/Tests/Loader/PoFileLoaderTest.php",
"language": "php",
"file_size": 4319,
"cut_index": 614,
"middle_length": 229
} |
ge.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation\Tests\Loader;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\Resource\FileReso... | , 'en', 'resources');
$this->assertEquals([
'foo' => 'bar',
'foo_bar' => 'foobar',
'bar_foo' => 'barfoo',
], $catalogue->all('resources'));
$this->assertEquals('en', $catalogue->getLocale());
| leLoader;
class QtFileLoaderTest extends TestCase
{
public function testLoad()
{
$loader = new QtFileLoader();
$resource = __DIR__.'/../Fixtures/resources.ts';
$catalogue = $loader->load($resource | {
"filepath": "src/Symfony/Component/Translation/Tests/Loader/QtFileLoaderTest.php",
"language": "php",
"file_size": 2132,
"cut_index": 563,
"middle_length": 229
} |
$resource = __DIR__.'/../Fixtures/resources.xlf';
$catalogue = $loader->load($resource, 'en', 'domain1');
$this->assertEquals('en', $catalogue->getLocale());
$this->assertEquals([new FileResource($resource)], $catalogue->getResources());
$this->assertSame([], libxml_get_errors());
... | y>
<trans-unit id="1">
<source>foo</source>
<target>bar</target>
</trans-unit>
<trans-unit id="2">
<source>extra</source>
</ | <?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2">
<file source-language="en" datatype="plaintext" original="file.ext">
<bod | {
"filepath": "src/Symfony/Component/Translation/Tests/Loader/XliffFileLoaderTest.php",
"language": "php",
"file_size": 22920,
"cut_index": 1331,
"middle_length": 229
} |
ge.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation\Tests\Loader;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\Resource\FileReso... | esource, 'en', 'domain1');
$this->assertEquals(['foo' => 'bar'], $catalogue->all('domain1'));
$this->assertEquals('en', $catalogue->getLocale());
$this->assertEquals([new FileResource($resource)], $catalogue->getResources());
} | FileLoader;
class YamlFileLoaderTest extends TestCase
{
public function testLoad()
{
$loader = new YamlFileLoader();
$resource = __DIR__.'/../Fixtures/resources.yml';
$catalogue = $loader->load($r | {
"filepath": "src/Symfony/Component/Translation/Tests/Loader/YamlFileLoaderTest.php",
"language": "php",
"file_size": 2664,
"cut_index": 563,
"middle_length": 229
} |
ge.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation\Tests\Catalogue;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Translation\Exception... | >getDomains()
);
}
public function testGetMergedDomains()
{
$this->assertEquals(
['a', 'b', 'c'],
$this->createOperation(
new MessageCatalogue('en', ['a' => [], 'b' => []]),
| public function testGetEmptyDomains()
{
$this->assertEquals(
[],
$this->createOperation(
new MessageCatalogue('en'),
new MessageCatalogue('en')
)- | {
"filepath": "src/Symfony/Component/Translation/Tests/Catalogue/AbstractOperationTestCase.php",
"language": "php",
"file_size": 2458,
"cut_index": 563,
"middle_length": 229
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation\Tests\Catalogue;
use Symfony\Component\Translation\Catalogue\MergeOperation;
use Symfony\Component\Translation\MessageCatalogue;
use Symfony\Co... | ssertEquals(
['a' => 'old_a', 'b' => 'old_b', 'c' => 'new_c'],
$operation->getMessages('messages')
);
$this->assertEquals(
['c' => 'new_c'],
$operation->getNewMessages('messages')
);
| his->createOperation(
new MessageCatalogue('en', ['messages' => ['a' => 'old_a', 'b' => 'old_b']]),
new MessageCatalogue('en', ['messages' => ['a' => 'new_a', 'c' => 'new_c']])
);
$this->a | {
"filepath": "src/Symfony/Component/Translation/Tests/Catalogue/MergeOperationTest.php",
"language": "php",
"file_size": 4634,
"cut_index": 614,
"middle_length": 229
} |
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation\Tests\Catalogue;
use PHPUnit\Framework\TestCas... | = ['metadata' => 'value'];
$mc->setMetadata('a', $metadata, 'messages+intl-icu');
$this->assertEquals($metadata, $mc->getMetadata('a', 'messages'));
$this->assertEquals($metadata, $mc->getMetadata('a', 'messages+intl-icu'));
}
} | 'messages' => ['a' => 'new_a']]);
$metadata | {
"filepath": "src/Symfony/Component/Translation/Tests/Catalogue/MessageCatalogueTest.php",
"language": "php",
"file_size": 826,
"cut_index": 517,
"middle_length": 52
} |
buted with this source code.
*/
namespace Symfony\Component\Translation\Tests\Catalogue;
use Symfony\Component\Translation\Catalogue\TargetOperation;
use Symfony\Component\Translation\MessageCatalogue;
use Symfony\Component\Translation\MessageCatalogueInterface;
class TargetOperationTest extends AbstractOperationTe... | ages')
);
$this->assertEquals(
['c' => 'new_c'],
$operation->getNewMessages('messages')
);
$this->assertEquals(
['b' => 'old_b'],
$operation->getObsoleteMessages('messages')
| 'old_b']]),
new MessageCatalogue('en', ['messages' => ['a' => 'new_a', 'c' => 'new_c']])
);
$this->assertEquals(
['a' => 'old_a', 'c' => 'new_c'],
$operation->getMessages('mess | {
"filepath": "src/Symfony/Component/Translation/Tests/Catalogue/TargetOperationTest.php",
"language": "php",
"file_size": 6092,
"cut_index": 716,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\Translation\Tests\Command;
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Tester\CommandTester;
u... | $translator->addResource('array', ['hello' => 'Hello!'], 'en', 'messages');
$translator->addResource('array', [
'hello_name' => 'Hello {name}!',
'num_of_apples' => <<<ICU
{apples, plural,
| tCommandTest extends TestCase
{
#[RequiresPhpExtension('intl')]
public function testLintCorrectTranslations()
{
$translator = new Translator('en');
$translator->addLoader('array', new ArrayLoader());
| {
"filepath": "src/Symfony/Component/Translation/Tests/Command/TranslationLintCommandTest.php",
"language": "php",
"file_size": 6837,
"cut_index": 716,
"middle_length": 229
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation\Tests\Command;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Translation\Provider\Filterin... | protected function setUp(): void
{
$this->defaultLocale = \Locale::getDefault();
\Locale::setDefault('en');
$this->fs = new Filesystem();
$this->translationAppDir = tempnam(sys_get_temp_dir(), 'sf_translation_');
| tefano@protonmail.com>
*/
abstract class TranslationProviderTestCase extends TestCase
{
protected Filesystem $fs;
protected string $translationAppDir;
protected array $files;
protected string $defaultLocale;
| {
"filepath": "src/Symfony/Component/Translation/Tests/Command/TranslationProviderTestCase.php",
"language": "php",
"file_size": 4477,
"cut_index": 614,
"middle_length": 229
} |
on\Loader\XliffFileLoader;
use Symfony\Component\Translation\Loader\YamlFileLoader;
use Symfony\Component\Translation\Provider\ProviderInterface;
use Symfony\Component\Translation\Reader\TranslationReader;
use Symfony\Component\Translation\TranslatorBag;
use Symfony\Component\Translation\Writer\TranslationWriter;
/**
... | putenv($this->colSize ? 'COLUMNS='.$this->colSize : 'COLUMNS');
}
public function testPullNewXlf12Messages()
{
$arrayLoader = new ArrayLoader();
$filenameEn = $this->createFile();
$filenameEnIcu = $this->createF | tion setUp(): void
{
$this->colSize = getenv('COLUMNS');
putenv('COLUMNS='.(119 + \strlen(\PHP_EOL)));
parent::setUp();
}
protected function tearDown(): void
{
parent::tearDown();
| {
"filepath": "src/Symfony/Component/Translation/Tests/Command/TranslationPullCommandTest.php",
"language": "php",
"file_size": 32608,
"cut_index": 1331,
"middle_length": 229
} |
nt\Translation\Provider\TranslationProviderCollection;
use Symfony\Component\Translation\Reader\TranslationReader;
use Symfony\Component\Translation\TranslatorBag;
/**
* @author Mathieu Santostefano <msantostefano@protonmail.com>
*/
class TranslationPushCommandTest extends TranslationProviderTestCase
{
private s... | ew ArrayLoader();
$xliffLoader = new XliffFileLoader();
$locales = ['en', 'fr'];
$domains = ['messages'];
// Simulate existing messages on Provider
$providerReadTranslatorBag = new TranslatorBag();
$provider | }
protected function tearDown(): void
{
parent::tearDown();
putenv($this->colSize ? 'COLUMNS='.$this->colSize : 'COLUMNS');
}
public function testPushNewMessages()
{
$arrayLoader = n | {
"filepath": "src/Symfony/Component/Translation/Tests/Command/TranslationPushCommandTest.php",
"language": "php",
"file_size": 17758,
"cut_index": 1331,
"middle_length": 229
} |
ation;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Tester\CommandCompletionTester;
use Symfony\Component\Console\Tester\CommandTester;
use Symfony\Component\Translation\Command\XliffLintCommand;
/**
* Tests the XliffLintCommand.
*... | );
$tester->assertCommandIsSuccessful('Returns 0 in case of success');
$this->assertStringContainsString('OK', trim($tester->getDisplay()));
}
public function testLintCorrectFiles()
{
$tester = $this->createComm | er = $this->createCommandTester();
$filename = $this->createFile();
$tester->execute(
['filename' => $filename],
['verbosity' => OutputInterface::VERBOSITY_VERBOSE, 'decorated' => false]
| {
"filepath": "src/Symfony/Component/Translation/Tests/Command/XliffLintCommandTest.php",
"language": "php",
"file_size": 11583,
"cut_index": 921,
"middle_length": 229
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation\Tests\Formatter;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
use PHPUnit\Framework\Te... | s($expected, trim((new IntlFormatter())->formatIntl($message, 'en', $arguments)));
}
public function testInvalidFormat()
{
$this->expectException(InvalidArgumentException::class);
(new IntlFormatter())->formatIntl('{foo', 'en', | erInterface;
#[RequiresPhpExtension('intl')]
class IntlFormatterTest extends TestCase
{
#[DataProvider('provideDataForFormat')]
public function testFormat($expected, $message, $arguments)
{
$this->assertEqual | {
"filepath": "src/Symfony/Component/Translation/Tests/Formatter/IntlFormatterTest.php",
"language": "php",
"file_size": 4091,
"cut_index": 614,
"middle_length": 229
} |
This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation\Tests\Formatter;
use PHPUnit\Framework\Attributes\Dat... | ages()
{
return [
[
'There is one apple',
'There is one apple',
],
[
'There are 5 apples',
'There are %count% apples',
['%count% | public function testFormat($expected, $message, $parameters = [])
{
$this->assertEquals($expected, $this->getMessageFormatter()->format($message, 'en', $parameters));
}
public static function getTransMess | {
"filepath": "src/Symfony/Component/Translation/Tests/Formatter/MessageFormatterTest.php",
"language": "php",
"file_size": 1296,
"cut_index": 524,
"middle_length": 229
} |
p
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation\Tests\Dumper;
use PHPUnit\Framework\TestCase;... | en');
$catalogue->add(['foo' => 'bar', 'bar' => 'foo
foo', 'foo;foo' => 'bar']);
$dumper = new CsvFileDumper();
$this->assertStringEqualsFile(__DIR__.'/../Fixtures/valid.csv', $dumper->formatCatalogue($catalogue, 'messages'));
| ()
{
$catalogue = new MessageCatalogue(' | {
"filepath": "src/Symfony/Component/Translation/Tests/Dumper/CsvFileDumperTest.php",
"language": "php",
"file_size": 829,
"cut_index": 516,
"middle_length": 52
} |
ge.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation\Tests\Dumper;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Translation\Dumper\FileD... | es.en.concrete');
@unlink($tempDir.'/messages.en.concrete');
}
public function testDumpIntl()
{
$tempDir = sys_get_temp_dir();
$catalogue = new MessageCatalogue('en');
$catalogue->add(['foo' => 'bar'], 'd1');
| gue = new MessageCatalogue('en');
$catalogue->add(['foo' => 'bar']);
$dumper = new ConcreteFileDumper();
$dumper->dump($catalogue, ['path' => $tempDir]);
$this->assertFileExists($tempDir.'/messag | {
"filepath": "src/Symfony/Component/Translation/Tests/Dumper/FileDumperTest.php",
"language": "php",
"file_size": 2728,
"cut_index": 563,
"middle_length": 229
} |
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation\Tests\Dumper;
use PHPUnit\Framework\TestCase;
use S... | $catalogue = new MessageCatalogue('en');
$catalogue->add(['foo' => 'bar']);
$dumper = new IcuResFileDumper();
$this->assertStringEqualsFile(__DIR__.'/../Fixtures/resourcebundle/res/en.res', $dumper->formatCatalogue($catalogue, | ()
{
| {
"filepath": "src/Symfony/Component/Translation/Tests/Dumper/IcuResFileDumperTest.php",
"language": "php",
"file_size": 814,
"cut_index": 522,
"middle_length": 14
} |
php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation\Tests\Dumper;
use PHPUnit\Framework\TestCas... | $catalogue = new MessageCatalogue('en');
$catalogue->add(['foo' => 'bar']);
$dumper = new IniFileDumper();
$this->assertStringEqualsFile(__DIR__.'/../Fixtures/resources.ini', $dumper->formatCatalogue($catalogue, 'messages')); | ue()
{
| {
"filepath": "src/Symfony/Component/Translation/Tests/Dumper/IniFileDumperTest.php",
"language": "php",
"file_size": 793,
"cut_index": 514,
"middle_length": 14
} |
part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation\Tests\Loader;
use PHPUnit\Framework\TestCase;
use Symfony\Componen... | rtEquals(['foo' => 'bar'], $catalogue->all('domain1'));
$this->assertEquals('en', $catalogue->getLocale());
$this->assertEquals([new FileResource($resource)], $catalogue->getResources());
}
public function testLoadDoesNothingIfEmpt | TestCase
{
public function testLoad()
{
$loader = new IniFileLoader();
$resource = __DIR__.'/../Fixtures/resources.ini';
$catalogue = $loader->load($resource, 'en', 'domain1');
$this->asse | {
"filepath": "src/Symfony/Component/Translation/Tests/Loader/IniFileLoaderTest.php",
"language": "php",
"file_size": 1632,
"cut_index": 537,
"middle_length": 229
} |
ge.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation;
use Psr\Log\LoggerInterface;
use Symfony\Contracts\Translation\LocaleAwareInterface;
use Sy... | rans(?string $id, array $parameters = [], ?string $domain = null, ?string $locale = null): string
{
$trans = $this->translator->trans($id = (string) $id, $parameters, $domain, $locale);
$this->log($id, $domain, $locale);
return | e, LocaleAwareInterface
{
public function __construct(
private TranslatorInterface&TranslatorBagInterface&LocaleAwareInterface $translator,
private LoggerInterface $logger,
) {
}
public function t | {
"filepath": "src/Symfony/Component/Translation/LoggingTranslator.php",
"language": "php",
"file_size": 2837,
"cut_index": 563,
"middle_length": 229
} |
n Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation\Writer;
use Symfony\Component\Translation\Exception\InvalidArgumentException;
use Symfony\Component\Translation... | cted format.
*
* @param string $format The format to use to dump the messages
* @param array $options Options that are passed to the dumper
*
* @throws InvalidArgumentException
*/
public function write(MessageCatalogue $ | translation from the catalogue according to the sele | {
"filepath": "src/Symfony/Component/Translation/Writer/TranslationWriterInterface.php",
"language": "php",
"file_size": 947,
"cut_index": 582,
"middle_length": 52
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation\Tests;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Translation\MessageCatalogue;
use Symfony\Component\Translation\TranslatorBag;
cl... | 'foo' => 'bar']] + $messages + [
'domain2+intl-icu' => ['bar' => 'foo'],
'domain3+intl-icu' => ['biz' => 'biz'],
];
$catalogue = new MessageCatalogue('en', $messages);
$bag = new TranslatorBag();
$ba | 'bar']]);
$bag = new TranslatorBag();
$bag->addCatalogue($catalogue);
$this->assertEquals(['en' => $messages], $this->getAllMessagesFromTranslatorBag($bag));
$messages = ['domain1+intl-icu' => [ | {
"filepath": "src/Symfony/Component/Translation/Tests/TranslatorBagTest.php",
"language": "php",
"file_size": 4088,
"cut_index": 614,
"middle_length": 229
} |
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation\Tests\Exception;
use PHPUnit\Framework\TestCase... | $this->assertSame('debug', $exception->getDebug());
}
public function testExceptionWithNullAsDebugMessage()
{
$mock = $this->createStub(ResponseInterface::class);
$mock->method('getInfo')->willReturn(null);
$except | eptionWithDebugMessage()
{
$mock = $this->createStub(ResponseInterface::class);
$mock->method('getInfo')->willReturn('debug');
$exception = new ProviderException('Exception message', $mock, 503);
| {
"filepath": "src/Symfony/Component/Translation/Tests/Exception/ProviderExceptionTest.php",
"language": "php",
"file_size": 1128,
"cut_index": 518,
"middle_length": 229
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation\Tests\Exception;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses;
use PHPUnit\Frame... | Symfony\Component\Translation\Provider\Dsn;
#[RunTestsInSeparateProcesses]
final class UnsupportedSchemeExceptionTest extends TestCase
{
public static function setUpBeforeClass(): void
{
ClassExistsMock::register(__CLASS__);
ClassE | ctory;
use Symfony\Component\Translation\Bridge\Lokalise\LokaliseProviderFactory;
use Symfony\Component\Translation\Bridge\Phrase\PhraseProviderFactory;
use Symfony\Component\Translation\Exception\UnsupportedSchemeException;
use | {
"filepath": "src/Symfony/Component/Translation/Tests/Exception/UnsupportedSchemeExceptionTest.php",
"language": "php",
"file_size": 3314,
"cut_index": 614,
"middle_length": 229
} |
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation\Tests\Provider;
use PHPUnit\Framework\TestCase;... | er->expects($this->once())
->method('read')
->with(['messages'], ['en', 'fr'])
->willReturn($expectedBag);
$filteringProvider = new FilteringProvider(
$innerProvider,
['en', 'fr', null, ' | oviderTest extends TestCase
{
public function testReadDelegatesWithFilteredLocales()
{
$innerProvider = $this->createMock(ProviderInterface::class);
$expectedBag = new TranslatorBag();
$innerProvid | {
"filepath": "src/Symfony/Component/Translation/Tests/Provider/FilteringProviderTest.php",
"language": "php",
"file_size": 1209,
"cut_index": 518,
"middle_length": 229
} |
ge.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation\Tests\Writer;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Translation\Dumper\Dumpe... | public function testWrite()
{
$dumper = $this->createMock(DumperInterface::class);
$dumper
->expects($this->once())
->method('dump');
$writer = new TranslationWriter();
$writer->addDumper('test | ion;
use Symfony\Component\Translation\Exception\RuntimeException;
use Symfony\Component\Translation\MessageCatalogue;
use Symfony\Component\Translation\Writer\TranslationWriter;
class TranslationWriterTest extends TestCase
{
| {
"filepath": "src/Symfony/Component/Translation/Tests/Writer/TranslationWriterTest.php",
"language": "php",
"file_size": 2226,
"cut_index": 563,
"middle_length": 229
} |
ge.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation\Tests\Util;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
u... | 'foo1' => 'bar',
'foo.bar' => 'value',
],
// expected output
[
'foo1' => 'bar',
'foo' => ['bar' => 'value'],
],
] | {
$this->assertEquals($expectedOutput, ArrayConverter::expandToTree($input));
}
public static function messagesData()
{
return [
[
// input
[
| {
"filepath": "src/Symfony/Component/Translation/Tests/Util/ArrayConverterTest.php",
"language": "php",
"file_size": 2858,
"cut_index": 563,
"middle_length": 229
} |
ction tests
<?php new \Symfony\Component\Translation\TranslatableMessage('translatable-fqn single-quoted key'); ?>
<?php new \Symfony\Component\Translation\TranslatableMessage('translatable-fqn double-quoted key'); ?>
<?php new \Symfony\Component\Translation\TranslatableMessage(<<<EOF
translatable-fqn heredoc key
EOF
)... | ?>
<?php new \Symfony\Component\Translation\TranslatableMessage(<<<EOF
translatable-fqn heredoc key with whitespace and escaped \$\n sequences
EOF
); ?>
<?php new \Symfony\Component\Translation\TranslatableMessage(<<<'EOF'
translatable-fqn nowdoc key with | -fqn double-quoted key with whitespace and escaped \$\n\" sequences"
); ?>
<?php new \Symfony\Component\Translation\TranslatableMessage(
'translatable-fqn single-quoted key with whitespace and nonescaped \$\n\' sequences'
); | {
"filepath": "src/Symfony/Component/Translation/Tests/Fixtures/extractor/translatable-fqn.html.php",
"language": "php",
"file_size": 2242,
"cut_index": 563,
"middle_length": 229
} |
e is used for translation message extraction tests
<?php t('translatable-short single-quoted key'); ?>
<?php t('translatable-short double-quoted key'); ?>
<?php t(<<<EOF
translatable-short heredoc key
EOF
); ?>
<?php t(<<<'EOF'
translatable-short nowdoc key
EOF
); ?>
<?php t(
"translatable-short double-quoted key w... | k at the end"'); ?>
<?php t('translatable-short concatenated'.' message'.<<<EOF
with heredoc
EOF
.<<<'EOF'
and nowdoc
EOF
); ?>
<?php t('translatable-short other-domain-test-no-params-short-array', [], 'not_messages'); ?>
<?php t('translatable-short o | eredoc key with whitespace and escaped \$\n sequences
EOF
); ?>
<?php t(<<<'EOF'
translatable-short nowdoc key with whitespace and nonescaped \$\n sequences
EOF
); ?>
<?php t('translatable-short single-quoted key with "quote mar | {
"filepath": "src/Symfony/Component/Translation/Tests/Fixtures/extractor/translatable-short.html.php",
"language": "php",
"file_size": 1426,
"cut_index": 524,
"middle_length": 229
} |
ction tests
<?php new \Symfony\Component\Translation\TranslatableMessage('translatable-fqn single-quoted key'); ?>
<?php new \Symfony\Component\Translation\TranslatableMessage('translatable-fqn double-quoted key'); ?>
<?php new \Symfony\Component\Translation\TranslatableMessage(<<<EOF
translatable-fqn heredoc key
EOF
)... | ?>
<?php new \Symfony\Component\Translation\TranslatableMessage(<<<EOF
translatable-fqn heredoc key with whitespace and escaped \$\n sequences
EOF
); ?>
<?php new \Symfony\Component\Translation\TranslatableMessage(<<<'EOF'
translatable-fqn nowdoc key with | -fqn double-quoted key with whitespace and escaped \$\n\" sequences"
); ?>
<?php new \Symfony\Component\Translation\TranslatableMessage(
'translatable-fqn single-quoted key with whitespace and nonescaped \$\n\' sequences'
); | {
"filepath": "src/Symfony/Component/Translation/Tests/Fixtures/extractor-ast/translatable-fqn.html.php",
"language": "php",
"file_size": 2242,
"cut_index": 563,
"middle_length": 229
} |
translation message extraction tests
<?php \Symfony\Component\Translation\t('translatable-short-fqn single-quoted key'); ?>
<?php \Symfony\Component\Translation\t('translatable-short-fqn double-quoted key'); ?>
<?php \Symfony\Component\Translation\t(<<<EOF
translatable-short-fqn heredoc key
EOF
); ?>
<?php \Symfony\Co... | n heredoc key with whitespace and escaped \$\n sequences
EOF
); ?>
<?php \Symfony\Component\Translation\t(<<<'EOF'
translatable-short-fqn nowdoc key with whitespace and nonescaped \$\n sequences
EOF
); ?>
<?php \Symfony\Component\Translation\t('translatab | n\" sequences"
); ?>
<?php \Symfony\Component\Translation\t(
'translatable-short-fqn single-quoted key with whitespace and nonescaped \$\n\' sequences'
); ?>
<?php \Symfony\Component\Translation\t(<<<EOF
translatable-short-fq | {
"filepath": "src/Symfony/Component/Translation/Tests/Fixtures/extractor-ast/translatable-short-fqn.html.php",
"language": "php",
"file_size": 1986,
"cut_index": 537,
"middle_length": 229
} |
single-quoted key'); ?>
<?php echo $view['translator']->trans('double-quoted key'); ?>
<?php echo $view['translator']->trans(<<<EOF
heredoc key
EOF
); ?>
<?php echo $view['translator']->trans(<<<'EOF'
nowdoc key
EOF
); ?>
<?php echo $view['translator']->trans(
"double-quoted key with whitespace and escaped \$\n\" s... | quote mark at the end"'); ?>
<?php echo $view['translator']->trans('concatenated'.' message'.<<<EOF
with heredoc
EOF
.<<<'EOF'
and nowdoc
EOF
); ?>
<?php echo $view['translator']->trans('other-domain-test-no-params-short-array', [], 'not_messages'); ?> | th whitespace and escaped \$\n sequences
EOF
); ?>
<?php echo $view['translator']->trans(<<<'EOF'
nowdoc key with whitespace and nonescaped \$\n sequences
EOF
); ?>
<?php echo $view['translator']->trans('single-quoted key with " | {
"filepath": "src/Symfony/Component/Translation/Tests/Fixtures/extractor-ast/translation.html.php",
"language": "php",
"file_size": 3247,
"cut_index": 614,
"middle_length": 229
} |
translation message extraction tests
<?php
use Symfony\Component\Validator\Constraints as Assert;
class Foo
{
#[Assert\NotBlank(message: 'message-in-constraint-attribute')]
public string $bar;
#[Assert\Length(exactMessage: 'custom Length exact message from attribute from named argument')]
public str... | ype' => 'isbn10',
'message' => 'custom Isbn message from attribute with options as array',
])]
public string $isbn2;
}
class Foo2
{
public function index()
{
$constraint1 = new Assert\Isbn('isbn10', 'custom Isbn message'); | 2')]
public string $bar3;
#[Assert\Isbn('isbn10', 'custom Isbn message from attribute')] // no way to handle those arguments (not named, not in associative array).
public string $isbn;
#[Assert\Isbn([
't | {
"filepath": "src/Symfony/Component/Translation/Tests/Fixtures/extractor-ast/validator-constraints.php",
"language": "php",
"file_size": 1635,
"cut_index": 537,
"middle_length": 229
} |
part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation\Tests\Loader;
use PHPUnit\Framework\Attributes\RequiresPhpExtensio... | enrb command
$loader = new IcuResFileLoader();
$resource = __DIR__.'/../Fixtures/resourcebundle/res';
$catalogue = $loader->load($resource, 'en', 'domain1');
$this->assertEquals(['foo' => 'bar'], $catalogue->all('domain1')) | ception;
use Symfony\Component\Translation\Loader\IcuResFileLoader;
#[RequiresPhpExtension('intl')]
class IcuResFileLoaderTest extends LocalizedTestCase
{
public function testLoad()
{
// resource is build using g | {
"filepath": "src/Symfony/Component/Translation/Tests/Loader/IcuResFileLoaderTest.php",
"language": "php",
"file_size": 1644,
"cut_index": 537,
"middle_length": 229
} |
ge.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation\Tests\Loader;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\Resource\FileReso... | , 'en', 'domain1');
$this->assertEquals(['foo' => 'bar'], $catalogue->all('domain1'));
$this->assertEquals('en', $catalogue->getLocale());
$this->assertEquals([new FileResource($resource)], $catalogue->getResources());
}
p | leLoader;
class MoFileLoaderTest extends TestCase
{
public function testLoad()
{
$loader = new MoFileLoader();
$resource = __DIR__.'/../Fixtures/resources.mo';
$catalogue = $loader->load($resource | {
"filepath": "src/Symfony/Component/Translation/Tests/Loader/MoFileLoaderTest.php",
"language": "php",
"file_size": 2466,
"cut_index": 563,
"middle_length": 229
} |
?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation\Provider;
use Symfony\Component\Translatio... | turn $dsn->getUser() ?? throw new IncompleteDsnException('User is not set.', $dsn->getScheme().'://'.$dsn->getHost());
}
protected function getPassword(Dsn $dsn): string
{
return $dsn->getPassword() ?? throw new IncompleteDsnException( | sn->getScheme(), $this->getSupportedSchemes(), true);
}
/**
* @return string[]
*/
abstract protected function getSupportedSchemes(): array;
protected function getUser(Dsn $dsn): string
{
re | {
"filepath": "src/Symfony/Component/Translation/Provider/AbstractProviderFactory.php",
"language": "php",
"file_size": 1055,
"cut_index": 513,
"middle_length": 229
} |
hp
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation\Tests\Provider;
use PHPUnit\Framework\TestCa... | ception()
{
$this->expectException(UnsupportedSchemeException::class);
(new NullProviderFactory())->create(new Dsn('foo://localhost'));
}
public function testCreate()
{
$this->assertInstanceOf(NullProvider::class, | \Component\Translation\Provider\NullProviderFactory;
/**
* @author Mathieu Santostefano <msantostefano@protonmail.com>
*/
class NullProviderFactoryTest extends TestCase
{
public function testCreateThrowsUnsupportedSchemeEx | {
"filepath": "src/Symfony/Component/Translation/Tests/Provider/NullProviderFactoryTest.php",
"language": "php",
"file_size": 1070,
"cut_index": 515,
"middle_length": 229
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation\Tests\DataCollector;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Respons... | ator(new Translator('en')));
$dataCollector->lateCollect();
$this->assertEquals(0, $dataCollector->getCountMissings());
$this->assertEquals(0, $dataCollector->getCountFallbacks());
$this->assertEquals(0, $dataCollector->get | e Symfony\Component\Translation\Translator;
class TranslationDataCollectorTest extends TestCase
{
public function testCollectEmptyMessages()
{
$dataCollector = new TranslationDataCollector(new DataCollectorTransl | {
"filepath": "src/Symfony/Component/Translation/Tests/DataCollector/TranslationDataCollectorTest.php",
"language": "php",
"file_size": 4626,
"cut_index": 614,
"middle_length": 229
} |
translation message extraction tests
<?php new TranslatableMessage('translatable single-quoted key'); ?>
<?php new TranslatableMessage('translatable double-quoted key'); ?>
<?php new TranslatableMessage(<<<EOF
translatable heredoc key
EOF
); ?>
<?php new TranslatableMessage(<<<'EOF'
translatable nowdoc key
EOF
); ?>
<... | h whitespace and nonescaped \$\n sequences
EOF
); ?>
<?php new TranslatableMessage('translatable single-quoted key with "quote mark at the end"'); ?>
<?php new TranslatableMessage('translatable concatenated'.' message'.<<<EOF
with heredoc
EOF
.<<<'EOF'
| itespace and nonescaped \$\n\' sequences'
); ?>
<?php new TranslatableMessage(<<<EOF
translatable heredoc key with whitespace and escaped \$\n sequences
EOF
); ?>
<?php new TranslatableMessage(<<<'EOF'
translatable nowdoc key wit | {
"filepath": "src/Symfony/Component/Translation/Tests/Fixtures/extractor/translatable.html.php",
"language": "php",
"file_size": 1682,
"cut_index": 537,
"middle_length": 229
} |
translation message extraction tests
<?php echo $view['translator']->trans('single-quoted key'); ?>
<?php echo $view['translator']->trans('double-quoted key'); ?>
<?php echo $view['translator']->trans(<<<EOF
heredoc key
EOF
); ?>
<?php echo $view['translator']->trans(<<<'EOF'
nowdoc key
EOF
); ?>
<?php echo $view['tra... | es
EOF
); ?>
<?php echo $view['translator']->trans('single-quoted key with "quote mark at the end"'); ?>
<?php echo $view['translator']->trans('concatenated'.' message'.<<<EOF
with heredoc
EOF
.<<<'EOF'
and nowdoc
EOF
); ?>
<?php echo $view['translato | sequences'
); ?>
<?php echo $view['translator']->trans(<<<EOF
heredoc key with whitespace and escaped \$\n sequences
EOF
); ?>
<?php echo $view['translator']->trans(<<<'EOF'
nowdoc key with whitespace and nonescaped \$\n sequenc | {
"filepath": "src/Symfony/Component/Translation/Tests/Fixtures/extractor/translation.html.php",
"language": "php",
"file_size": 1603,
"cut_index": 537,
"middle_length": 229
} |
part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation\Tests\Loader;
use PHPUnit\Framework\TestCase;
use Symfony\Componen... | ogue = $loader->load($resource, 'en', 'domain1');
$this->assertEquals(['foo' => 'bar'], $catalogue->all('domain1'));
$this->assertEquals('en', $catalogue->getLocale());
$this->assertEquals([new FileResource($resource)], $catalogue- | nt\Translation\Loader\CsvFileLoader;
class CsvFileLoaderTest extends TestCase
{
public function testLoad()
{
$loader = new CsvFileLoader();
$resource = __DIR__.'/../Fixtures/resources.csv';
$catal | {
"filepath": "src/Symfony/Component/Translation/Tests/Loader/CsvFileLoaderTest.php",
"language": "php",
"file_size": 1916,
"cut_index": 537,
"middle_length": 229
} |
part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation\Tests\Loader;
use PHPUnit\Framework\TestCase;
use Symfony\Componen... | atalogue = $loader->load($resource, 'en', 'domain1');
$this->assertEquals(['foo' => 'bar'], $catalogue->all('domain1'));
$this->assertEquals('en', $catalogue->getLocale());
$this->assertEquals([new FileResource($resource)], $catalo | nt\Translation\Loader\JsonFileLoader;
class JsonFileLoaderTest extends TestCase
{
public function testLoad()
{
$loader = new JsonFileLoader();
$resource = __DIR__.'/../Fixtures/resources.json';
$c | {
"filepath": "src/Symfony/Component/Translation/Tests/Loader/JsonFileLoaderTest.php",
"language": "php",
"file_size": 2015,
"cut_index": 537,
"middle_length": 229
} |
use Symfony\Component\Config\Resource\SelfCheckingResourceInterface;
use Symfony\Component\Translation\Loader\ArrayLoader;
use Symfony\Component\Translation\Loader\LoaderInterface;
use Symfony\Component\Translation\MessageCatalogue;
use Symfony\Component\Translation\Translator;
class TranslatorCacheTest extends TestC... | veIteratorIterator(new \RecursiveDirectoryIterator($this->tmpDir), \RecursiveIteratorIterator::CHILD_FIRST);
foreach ($iterator as $path) {
if (preg_match('#[/\\\\]\.\.?$#', $path->__toString())) {
continue;
| d function tearDown(): void
{
$this->deleteTmpDir();
}
protected function deleteTmpDir()
{
if (!file_exists($dir = $this->tmpDir)) {
return;
}
$iterator = new \Recursi | {
"filepath": "src/Symfony/Component/Translation/Tests/TranslatorCacheTest.php",
"language": "php",
"file_size": 12882,
"cut_index": 921,
"middle_length": 229
} |
part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation\Tests\Provider;
use PHPUnit\Framework\TestCase;
use Symfony\Compon... | llection(
(static function () {
yield 'foo' => new NullProvider();
yield 'baz' => new NullProvider();
})()
))->keys());
}
public function testToString()
{
$this->assertSa | testKeys()
{
$this->assertSame(['foo', 'baz'], $this->createProviderCollection()->keys());
}
public function testKeysWithGenerator()
{
$this->assertSame(['foo', 'baz'], (new TranslationProviderCo | {
"filepath": "src/Symfony/Component/Translation/Tests/Provider/TranslationProviderCollectionTest.php",
"language": "php",
"file_size": 1982,
"cut_index": 537,
"middle_length": 229
} |
e is used for translation message extraction tests
<?php t('translatable-short single-quoted key'); ?>
<?php t('translatable-short double-quoted key'); ?>
<?php t(<<<EOF
translatable-short heredoc key
EOF
); ?>
<?php t(<<<'EOF'
translatable-short nowdoc key
EOF
); ?>
<?php t(
"translatable-short double-quoted key w... | k at the end"'); ?>
<?php t('translatable-short concatenated'.' message'.<<<EOF
with heredoc
EOF
.<<<'EOF'
and nowdoc
EOF
); ?>
<?php t('translatable-short other-domain-test-no-params-short-array', [], 'not_messages'); ?>
<?php t('translatable-short o | eredoc key with whitespace and escaped \$\n sequences
EOF
); ?>
<?php t(<<<'EOF'
translatable-short nowdoc key with whitespace and nonescaped \$\n sequences
EOF
); ?>
<?php t('translatable-short single-quoted key with "quote mar | {
"filepath": "src/Symfony/Component/Translation/Tests/Fixtures/extractor-ast/translatable-short.html.php",
"language": "php",
"file_size": 1426,
"cut_index": 524,
"middle_length": 229
} |
ge.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation\Tests\Loader;
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
use Symfony\Component\C... | ion::class);
(new IcuDatFileLoader())->load(__DIR__.'/../Fixtures/resourcebundle/corrupted/resources', 'es', 'domain2');
}
public function testDatEnglishLoad()
{
// bundled resource is build using pkgdata command which at leas | Translation\Loader\IcuDatFileLoader;
#[RequiresPhpExtension('intl')]
class IcuDatFileLoaderTest extends LocalizedTestCase
{
public function testLoadInvalidResource()
{
$this->expectException(InvalidResourceExcept | {
"filepath": "src/Symfony/Component/Translation/Tests/Loader/IcuDatFileLoaderTest.php",
"language": "php",
"file_size": 2440,
"cut_index": 563,
"middle_length": 229
} |
buted with this source code.
*/
namespace Symfony\Component\Translation\Tests\Util;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Translation\Util\XliffUtils;
class XliffUtilsTest extends TestCase
{
#[DataProvider('providePaths')]
public function testGe... | s may contain spaces. Without rawurlencode, the
// resulting `file:///` URL is syntactically invalid and triggers a
// libxml "Invalid Schema" warning when fed to schemaValidateSource().
yield 'POSIX path with spaces' => [
| e(null, $path));
}
public static function providePaths(): iterable
{
yield 'plain POSIX path' => [
'/tmp/symfony123',
'file:////tmp/symfony123',
];
// Windows username | {
"filepath": "src/Symfony/Component/Translation/Tests/Util/XliffUtilsTest.php",
"language": "php",
"file_size": 5912,
"cut_index": 716,
"middle_length": 229
} |
translation message extraction tests
<?php new TranslatableMessage('translatable single-quoted key'); ?>
<?php new TranslatableMessage('translatable double-quoted key'); ?>
<?php new TranslatableMessage(<<<EOF
translatable heredoc key
EOF
); ?>
<?php new TranslatableMessage(<<<'EOF'
translatable nowdoc key
EOF
); ?>
<... | h whitespace and nonescaped \$\n sequences
EOF
); ?>
<?php new TranslatableMessage('translatable single-quoted key with "quote mark at the end"'); ?>
<?php new TranslatableMessage('translatable concatenated'.' message'.<<<EOF
with heredoc
EOF
.<<<'EOF'
| itespace and nonescaped \$\n\' sequences'
); ?>
<?php new TranslatableMessage(<<<EOF
translatable heredoc key with whitespace and escaped \$\n sequences
EOF
); ?>
<?php new TranslatableMessage(<<<'EOF'
translatable nowdoc key wit | {
"filepath": "src/Symfony/Component/Translation/Tests/Fixtures/extractor-ast/translatable.html.php",
"language": "php",
"file_size": 1682,
"cut_index": 537,
"middle_length": 229
} |
Component\Translation\Loader\YamlFileLoader;
use Symfony\Component\Translation\MessageCatalogue;
use Symfony\Component\Translation\TranslatableMessage;
use Symfony\Component\Translation\Translator;
class TranslatorTest extends TestCase
{
private string $defaultLocale;
protected function setUp(): void
{
... | taProvider('getValidLocalesTests')]
public function testConstructorValidLocale($locale)
{
$translator = new Translator($locale);
$this->assertSame($locale ?: (class_exists(\Locale::class) ? \Locale::getDefault() : 'en'), $translato | }
#[DataProvider('getInvalidLocalesTests')]
public function testConstructorInvalidLocale($locale)
{
$this->expectException(InvalidArgumentException::class);
new Translator($locale);
}
#[Da | {
"filepath": "src/Symfony/Component/Translation/Tests/TranslatorTest.php",
"language": "php",
"file_size": 24240,
"cut_index": 1331,
"middle_length": 229
} |
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation\Tests\Dumper;
use PHPUnit\Framework\TestCase;
u... | formatCatalogue($catalogue, 'messages'));
}
public function testDumpWithCustomEncoding()
{
$catalogue = new MessageCatalogue('en');
$catalogue->add(['foo' => '"bar"']);
$dumper = new JsonFileDumper();
$this->a | ()
{
$catalogue = new MessageCatalogue('en');
$catalogue->add(['foo' => 'bar']);
$dumper = new JsonFileDumper();
$this->assertStringEqualsFile(__DIR__.'/../Fixtures/resources.json', $dumper-> | {
"filepath": "src/Symfony/Component/Translation/Tests/Dumper/JsonFileDumperTest.php",
"language": "php",
"file_size": 1165,
"cut_index": 518,
"middle_length": 229
} |
php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation\Tests\Dumper;
use PHPUnit\Framework\TestCas... | $catalogue = new MessageCatalogue('en');
$catalogue->add(['foo' => 'bar']);
$dumper = new PhpFileDumper();
$this->assertStringEqualsFile(__DIR__.'/../Fixtures/resources.php', $dumper->formatCatalogue($catalogue, 'messages')); | ue()
{
| {
"filepath": "src/Symfony/Component/Translation/Tests/Dumper/PhpFileDumperTest.php",
"language": "php",
"file_size": 793,
"cut_index": 514,
"middle_length": 14
} |
This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation\Tests\Dumper;
use PHPUnit\Framework\TestCase;
use Sym... | 'Comment 1',
'Comment 2',
],
'flags' => [
'fuzzy',
'another',
],
'sources' => [
'src/file_1',
'src/file_2:50',
| $catalogue = new MessageCatalogue('en');
$catalogue->add(['foo' => 'bar', 'foo_bar' => 'foobar', 'bar_foo' => 'barfoo'], 'resources');
$catalogue->setMetadata('foo_bar', [
'comments' => [
| {
"filepath": "src/Symfony/Component/Translation/Tests/Dumper/QtFileDumperTest.php",
"language": "php",
"file_size": 1395,
"cut_index": 524,
"middle_length": 229
} |
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation\Tests\DependencyInjection;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjec... | orPassTest extends TestCase
{
private ContainerBuilder $container;
private DataCollectorTranslatorPass $dataCollectorTranslatorPass;
protected function setUp(): void
{
$this->container = new ContainerBuilder();
$this->dataC | ectorTranslator;
use Symfony\Component\Translation\DependencyInjection\DataCollectorTranslatorPass;
use Symfony\Component\Translation\Translator;
use Symfony\Contracts\Translation\TranslatorInterface;
class DataCollectorTranslat | {
"filepath": "src/Symfony/Component/Translation/Tests/DependencyInjection/DataCollectorTranslatorPassTest.php",
"language": "php",
"file_size": 4324,
"cut_index": 614,
"middle_length": 229
} |
php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation\Tests\Dumper;
use PHPUnit\Framework\TestCas... | $catalogue = new MessageCatalogue('en');
$catalogue->add(['foo' => 'bar']);
$dumper = new MoFileDumper();
$this->assertStringEqualsFile(__DIR__.'/../Fixtures/resources.mo', $dumper->formatCatalogue($catalogue, 'messages'));
| ()
{
| {
"filepath": "src/Symfony/Component/Translation/Tests/Dumper/MoFileDumperTest.php",
"language": "php",
"file_size": 789,
"cut_index": 514,
"middle_length": 14
} |
buted with this source code.
*/
namespace Symfony\Component\Translation\Tests\Dumper;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Translation\Dumper\XliffFileDumper;
use Symfony\Component\Translation\MessageCatalogue;
class XliffFileDumperTest extends TestCase
{
public function testFormatCatalogue()
... | $dumper = new XliffFileDumper();
$this->assertStringEqualsFile(
__DIR__.'/../Fixtures/resources-clean.xlf',
$dumper->formatCatalogue($catalogue, 'messages', ['default_locale' => 'fr_FR'])
);
}
public funct | ]);
$catalogue->setMetadata('foo', ['notes' => [['priority' => 1, 'from' => 'bar', 'content' => 'baz']]]);
$catalogue->setMetadata('key', ['notes' => [['content' => 'baz'], ['content' => 'qux']]]);
| {
"filepath": "src/Symfony/Component/Translation/Tests/Dumper/XliffFileDumperTest.php",
"language": "php",
"file_size": 6777,
"cut_index": 716,
"middle_length": 229
} |
This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation\Tests\Dumper;
use PHPUnit\Framework\TestCase;
use Sym... | StringEqualsFile(__DIR__.'/../Fixtures/messages.yml', $dumper->formatCatalogue($catalogue, 'messages', ['as_tree' => true, 'inline' => 999]));
}
public function testLinearFormatCatalogue()
{
$catalogue = new MessageCatalogue('en');
|
{
$catalogue = new MessageCatalogue('en');
$catalogue->add([
'foo.bar1' => 'value1',
'foo.bar2' => 'value2',
]);
$dumper = new YamlFileDumper();
$this->assert | {
"filepath": "src/Symfony/Component/Translation/Tests/Dumper/YamlFileDumperTest.php",
"language": "php",
"file_size": 1299,
"cut_index": 524,
"middle_length": 229
} |
part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation\Tests\Dumper;
use PHPUnit\Framework\TestCase;
use Symfony\Componen... | 'Comment 1',
'Comment 2',
],
'flags' => [
'fuzzy',
'another',
],
'sources' => [
'src/file_1',
'src/file_2:50',
],
| ogue = new MessageCatalogue('en');
$catalogue->add(['foo' => 'bar', 'bar' => 'foo', 'foo_bar' => 'foobar', 'bar_foo' => 'barfoo']);
$catalogue->setMetadata('foo_bar', [
'comments' => [
| {
"filepath": "src/Symfony/Component/Translation/Tests/Dumper/PoFileDumperTest.php",
"language": "php",
"file_size": 1797,
"cut_index": 537,
"middle_length": 229
} |
ng="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2">
<file source-language="en" target-language="en" datatype="plaintext" original="file.ext">
<header>
<tool tool-id="symfony" tool-name="Symfony"/>
</header>
... | xliff:document:1.2" version="1.2">
<file source-language="en" target-language="en" datatype="plaintext" original="file.ext">
<header>
<tool tool-id="symfony" tool-name="Symfony"/>
</header>
| </body>
</file>
</xliff>
XLIFF;
$expectedValidatorsFileContent = <<<'XLIFF'
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc: | {
"filepath": "src/Symfony/Component/Translation/Bridge/Crowdin/Tests/CrowdinProviderTest.php",
"language": "php",
"file_size": 90332,
"cut_index": 3790,
"middle_length": 229
} |
ge.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Translation\Dumper;
use Symfony\Component\Translation\MessageCatalogue;
/**
* IcuResDumper generates a... | domain) as $source => $target) {
$indexes .= pack('v', \strlen($data) + 28);
$data .= $source."\0";
}
$data .= $this->writePadding($data);
$keyTop = $this->getPosition($data);
foreach ($messages->a | = '%domain%/%locale%.%extension%';
public function formatCatalogue(MessageCatalogue $messages, string $domain, array $options = []): string
{
$data = $indexes = $resources = '';
foreach ($messages->all($ | {
"filepath": "src/Symfony/Component/Translation/Dumper/IcuResFileDumper.php",
"language": "php",
"file_size": 2909,
"cut_index": 563,
"middle_length": 229
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.