Ejemplo n.º 1
0
 /**
  * @test
  */
 public function itShouldNotBeAblToTranslateToGerman()
 {
     $rt = new ResourceTranslator(realpath(__DIR__ . '/../i18n/src'));
     $r = new TranslatableResource('testprice', ['name' => 'Johannes', 'amount' => 22.5]);
     $this->setExpectedException(\IntlException::class);
     $rt->translate('de_DE', $r);
 }
Ejemplo n.º 2
0
 /**
  * @param  ApplicationUser[] $users
  * @param  object            $object
  * @param  string            $language
  * @return DefaultMessage
  */
 public function buildMessage(array $users, $object, $language = null)
 {
     $filteredUsers = self::filterUsers($users);
     if (count($filteredUsers) === 0) {
         return null;
     }
     $messageResource = $this->extractor->extractMessage($object);
     if ($messageResource === null) {
         return null;
     }
     $language = $language ?: self::getLanguage($filteredUsers);
     try {
         $translatedText = $this->resourceTranslator->translate($language, $messageResource);
     } catch (\IntlException $e) {
         $translatedText = $messageResource->getKey();
     }
     return new DefaultMessage($filteredUsers, $translatedText);
 }
Ejemplo n.º 3
0
 private function givenTranslatorWillTranslate()
 {
     $this->resourceTranslator->shouldReceive('translate')->with($this->language, $this->translatedMessage)->andReturn($this->translatedString);
 }