Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ public function assertCatalogue(MessageCatalogue $catalogue): void
'translatable-short-fqn '.$expectedNowdoc => 'prefixtranslatable-short-fqn '.$expectedNowdoc,
'translatable-short-fqn concatenated message with heredoc and nowdoc' => 'prefixtranslatable-short-fqn concatenated message with heredoc and nowdoc',
'translatable-short-fqn default domain' => 'prefixtranslatable-short-fqn default domain',
'text_align.left.label' => 'prefixtext_align.left.label',
'text_align.center.label' => 'prefixtext_align.center.label',
'text_align.right.label' => 'prefixtext_align.right.label',
],
'not_messages' => [
'other-domain-test-no-params-short-array' => 'prefixother-domain-test-no-params-short-array',
Expand Down Expand Up @@ -111,5 +114,7 @@ public function assertCatalogue(MessageCatalogue $catalogue): void

$this->assertEquals(['sources' => [self::FIXTURES_FOLDER . 'translatable-short-fqn.html.php:2']], $catalogue->getMetadata('translatable-short-fqn single-quoted key'));
$this->assertEquals(['sources' => [self::FIXTURES_FOLDER . 'translatable-short-fqn.html.php:37']], $catalogue->getMetadata('translatable-short-fqn other-domain-test-no-params-short-array', 'not_messages'));

$this->assertEquals(['sources' => [self::FIXTURES_FOLDER . 'translatable-backed-enum.html.php:17']], $catalogue->getMetadata('text_align.left.label'));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
This template is used for translation message extraction tests
<?php
// @See https://symfony.com/doc/current/reference/forms/types/enum.html#example-usage

use Symfony\Contracts\Translation\TranslatableInterface;
use Symfony\Contracts\Translation\TranslatorInterface;

enum TextAlign: string implements TranslatableInterface
{
case Left = 'Left aligned';
case Center = 'Center aligned';
case Right = 'Right aligned';

public function trans(TranslatorInterface $translator, ?string $locale = null): string
{
return match ($this) {
self::Left => $translator->trans('text_align.left.label', locale: $locale),
self::Center => $translator->trans('text_align.center.label', locale: $locale),
self::Right => $translator->trans('text_align.right.label', locale: $locale),
};
}
}
Loading