Example #1
0
 /**
  * @test
  */
 public function quantityIsDeterminedAutomaticallyIfOneNumricArgumentIsGivenToTranslateByOriginalLabel()
 {
     $mockTranslationProvider = $this->getAccessibleMock('TYPO3\\FLOW3\\I18n\\TranslationProvider\\XliffTranslationProvider');
     $mockTranslationProvider->expects($this->once())->method('getTranslationByOriginalLabel')->with('Untranslated label', $this->defaultLocale, \TYPO3\FLOW3\I18n\Cldr\Reader\PluralsReader::RULE_ONE, 'source', 'packageKey')->will($this->returnValue('Translated label'));
     $mockFormatResolver = $this->getMock('TYPO3\\FLOW3\\I18n\\FormatResolver');
     $mockFormatResolver->expects($this->once())->method('resolvePlaceholders')->with('Translated label', array(1.0), $this->defaultLocale)->will($this->returnValue('Formatted and translated label'));
     $mockPluralsReader = $this->getMock('TYPO3\\FLOW3\\I18n\\Cldr\\Reader\\PluralsReader');
     $mockPluralsReader->expects($this->once())->method('getPluralForm')->with(1.0, $this->defaultLocale)->will($this->returnValue(\TYPO3\FLOW3\I18n\Cldr\Reader\PluralsReader::RULE_ONE));
     $this->translator->injectTranslationProvider($mockTranslationProvider);
     $this->translator->injectFormatResolver($mockFormatResolver);
     $this->translator->injectPluralsReader($mockPluralsReader);
     $result = $this->translator->translateByOriginalLabel('Untranslated label', array(1.0), NULL, NULL, 'source', 'packageKey');
     $this->assertEquals('Formatted and translated label', $result);
 }
Example #2
0
 /**
  * @test
  * @dataProvider labelAndLocaleForTranslation
  */
 public function simpleTranslationByLabelWorks($label, $locale, $translation)
 {
     $result = $this->translator->translateByOriginalLabel($label, array(), NULL, $locale, 'Main', 'TYPO3.FLOW3');
     $this->assertEquals($translation, $result);
 }