|
15 | 15 | use Symfony\Component\Translation\Exception\InvalidArgumentException;
|
16 | 16 | use Symfony\Component\Translation\Exception\NotFoundResourceException;
|
17 | 17 | use Symfony\Component\Translation\Exception\RuntimeException;
|
| 18 | +use Symfony\Component\Translation\Formatter\IntlFormatter; |
| 19 | +use Symfony\Component\Translation\Formatter\IntlFormatterInterface; |
| 20 | +use Symfony\Component\Translation\Formatter\MessageFormatter; |
| 21 | +use Symfony\Component\Translation\Formatter\MessageFormatterInterface; |
18 | 22 | use Symfony\Component\Translation\Loader\ArrayLoader;
|
19 | 23 | use Symfony\Component\Translation\MessageCatalogue;
|
20 | 24 | use Symfony\Component\Translation\Translator;
|
@@ -683,6 +687,41 @@ public function testIntlFormattedDomain()
|
683 | 687 | $this->assertSame('Hi Bob', $translator->trans('some_message', ['%name%' => 'Bob']));
|
684 | 688 | }
|
685 | 689 |
|
| 690 | + public function testIntlDomainOverlapseWithLegacyResourceBefore() |
| 691 | + { |
| 692 | + $intlFormatterMock = $this->createMock(IntlFormatterInterface::class); |
| 693 | + $intlFormatterMock->expects($this->once())->method('formatIntl')->with('hello intl', 'en', [])->willReturn('hello intl'); |
| 694 | + |
| 695 | + $messageFormatter = new MessageFormatter(null, $intlFormatterMock); |
| 696 | + |
| 697 | + $translator = new Translator('en', $messageFormatter); |
| 698 | + $translator->addLoader('array', new ArrayLoader()); |
| 699 | + |
| 700 | + $translator->addResource('array', ['some_message' => 'hello'], 'en', 'messages'); |
| 701 | + $translator->addResource('array', ['some_message' => 'hello intl'], 'en', 'messages+intl-icu'); |
| 702 | + |
| 703 | + $this->assertSame('hello intl', $translator->trans('some_message', [], 'messages')); |
| 704 | + } |
| 705 | + |
| 706 | + /** |
| 707 | + * This is currently symfony application execution order |
| 708 | + */ |
| 709 | + public function testIntlDomainOverlapseWithIntlResourceBefore() |
| 710 | + { |
| 711 | + $intlFormatterMock = $this->createMock(IntlFormatterInterface::class); |
| 712 | + $intlFormatterMock->expects($this->once())->method('formatIntl')->with('hello intl', 'en', [])->willReturn('hello intl'); |
| 713 | + |
| 714 | + $messageFormatter = new MessageFormatter(null, $intlFormatterMock); |
| 715 | + |
| 716 | + $translator = new Translator('en', $messageFormatter); |
| 717 | + $translator->addLoader('array', new ArrayLoader()); |
| 718 | + |
| 719 | + $translator->addResource('array', ['some_message' => 'hello intl'], 'en', 'messages+intl-icu'); |
| 720 | + $translator->addResource('array', ['some_message' => 'hello'], 'en', 'messages'); |
| 721 | + |
| 722 | + $this->assertSame('hello intl', $translator->trans('some_message', [], 'messages')); |
| 723 | + } |
| 724 | + |
686 | 725 | /**
|
687 | 726 | * @group legacy
|
688 | 727 | */
|
|
0 commit comments