/** * {@inheritdoc} */ public function getCountTranslationByLocales($domain) { $results = TranslationQuery::create()->join('TransUnit')->where('TransUnit.Domain = ?', $domain)->withColumn('count(Translation.ID)', 'number')->select(array('number', 'Translation.Locale'))->groupBy('Translation.Locale')->find(); $counts = array(); foreach ($results as $row) { $counts[$row['Translation.Locale']] = (int) $row['number']; } return $counts; }
/** * @group orm */ public function testGetTranslationsForFile() { $con = $this->loadDatabase(); $repository = new TransUnitRepository($con); $file = FileQuery::create()->findOneByArray(array('Domain' => 'messages', 'Locale' => 'fr', 'Extention' => 'yml'), $con); $this->assertInstanceOf(self::PROPEL_FILE_CLASS, $file); $result = $repository->getTranslationsForFile($file, false); $expected = array('key.say_goodbye' => 'au revoir', 'key.say_wtf' => 'c\'est quoi ce bordel !?!'); $this->assertEquals($expected, $result); // update a translation and then get translations with onlyUpdated = true $now = new \DateTime('now'); $now->modify('+2 days'); TranslationQuery::create()->filterByLocale('fr')->filterByContent('au revoir')->update(array('UpdatedAt' => $now), $con, false); $result = $repository->getTranslationsForFile($file, true); $expected = array('key.say_goodbye' => 'au revoir'); $this->assertEquals($expected, $result); }