Permalink
Browse files

Fix: port PR #241 from Propel

  • Loading branch information...
1 parent 99034da commit fdca1999b3f303e81d516d00a984dfdb1206818d @K-Phoen K-Phoen committed with willdurand Mar 30, 2012
@@ -209,7 +209,7 @@ public function objectFilter(&$script, $builder)
$pattern = '/public function add' . $i18nTablePhpName . '.*[\r\n]\s*\{/';
$addition = "
if (\$l && \$locale = \$l->get$localeColumnName()) {
- \$this->set$localeColumnName(\$locale);
+ \$this->set{$localeColumnName}(\$locale);
\$this->currentTranslations[\$locale] = \$l;
}";
$replacement = "\$0$addition";
@@ -76,6 +76,16 @@ public function setUp()
<reference local="movie_id" foreign="id" />
</foreign-key>
</table>
+
+ <table name="i18n_behavior_test_local_column">
+ <column name="id" primaryKey="true" type="INTEGER" autoIncrement="true" />
+ <column name="foo" type="INTEGER" />
+ <column name="bar" type="VARCHAR" size="100" />
+ <behavior name="i18n">
+ <parameter name="i18n_columns" value="bar" />
+ <parameter name="locale_column" value="my_lang" />
+ </behavior>
+ </table>
</database>
EOF;
QuickBuilder::buildSchema($schema);
@@ -389,4 +399,18 @@ public function testI18nWithRelations2()
$count = \MovieI18nQuery::create()->count();
$this->assertEquals(0, $count, '0 i18n movies');
}
+
+ public function testUseLocalColumnParameter()
+ {
+ $o = new \I18nBehaviorTestLocalColumn();
+ $translation1 = new \I18nBehaviorTestLocalColumnI18n();
+ $translation1->setMyLang('en_EN');
+ $o->addI18nBehaviorTestLocalColumnI18n($translation1);
+ $translation2 = new \I18nBehaviorTestLocalColumnI18n();
+ $translation2->setMyLang('fr_FR');
+ $o->addI18nBehaviorTestLocalColumnI18n($translation2);
+ $o->save();
+ $this->assertEquals($translation1, $o->getTranslation('en_EN'));
+ $this->assertEquals($translation2, $o->getTranslation('fr_FR'));
+ }
}

0 comments on commit fdca199

Please sign in to comment.