File tree 2 files changed +27
-0
lines changed
src/Symfony/Component/Translation/Tests
2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -71,6 +71,9 @@ public function assertCatalogue(MessageCatalogue $catalogue): void
71
71
'translatable-short-fqn ' .$ expectedNowdoc => 'prefixtranslatable-short-fqn ' .$ expectedNowdoc ,
72
72
'translatable-short-fqn concatenated message with heredoc and nowdoc ' => 'prefixtranslatable-short-fqn concatenated message with heredoc and nowdoc ' ,
73
73
'translatable-short-fqn default domain ' => 'prefixtranslatable-short-fqn default domain ' ,
74
+ 'text_align.left.label ' => 'prefixtext_align.left.label ' ,
75
+ 'text_align.center.label ' => 'prefixtext_align.center.label ' ,
76
+ 'text_align.right.label ' => 'prefixtext_align.right.label ' ,
74
77
],
75
78
'not_messages ' => [
76
79
'other-domain-test-no-params-short-array ' => 'prefixother-domain-test-no-params-short-array ' ,
@@ -111,5 +114,7 @@ public function assertCatalogue(MessageCatalogue $catalogue): void
111
114
112
115
$ this ->assertEquals (['sources ' => [self ::FIXTURES_FOLDER . 'translatable-short-fqn.html.php:2 ' ]], $ catalogue ->getMetadata ('translatable-short-fqn single-quoted key ' ));
113
116
$ 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 ' ));
117
+
118
+ $ this ->assertEquals (['sources ' => [self ::FIXTURES_FOLDER . 'translatable-backed-enum.html.php:17 ' ]], $ catalogue ->getMetadata ('text_align.left.label ' ));
114
119
}
115
120
}
Original file line number Diff line number Diff line change
1
+ This template is used for translation message extraction tests
2
+ <?php
3
+ // @See https://symfony.com/doc/current/reference/forms/types/enum.html#example-usage
4
+
5
+ use Symfony \Contracts \Translation \TranslatableInterface ;
6
+ use Symfony \Contracts \Translation \TranslatorInterface ;
7
+
8
+ enum TextAlign: string implements TranslatableInterface
9
+ {
10
+ case Left = 'Left aligned ' ;
11
+ case Center = 'Center aligned ' ;
12
+ case Right = 'Right aligned ' ;
13
+
14
+ public function trans (TranslatorInterface $ translator , ?string $ locale = null ): string
15
+ {
16
+ return match ($ this ) {
17
+ self ::Left => $ translator ->trans ('text_align.left.label ' , locale: $ locale ),
18
+ self ::Center => $ translator ->trans ('text_align.center.label ' , locale: $ locale ),
19
+ self ::Right => $ translator ->trans ('text_align.right.label ' , locale: $ locale ),
20
+ };
21
+ }
22
+ }
You can’t perform that action at this time.
0 commit comments