Chapter 16: Behaviors 254 Below is a list of all the options you can use with the I18n behavior: Name Default Description className %CLASS%Translation The name pattern to use for generated class. fields array() The fields to internationalize. type string The type of lang column. length 2 The length of the lang column. options array() Other options for the lang column. Lets check the SQL that is generated by the above models: Listing 16-43 // test.php Listing 16-44 // ... $sql = Doctrine_Core::generateSqlFromArray(array('NewsItem')); echo $sql[0] . "\n"; echo $sql[1]; The above code would output the following SQL query: CREATE TABLE news_item_translation (id BIGINT, title VARCHAR(255), body LONGTEXT, lang CHAR(2), PRIMARY KEY(id, lang)) ENGINE = INNODB CREATE TABLE news_item (id BIGINT AUTO_INCREMENT, PRIMARY KEY(id)) ENGINE = INNODB Notice how the field title is not present in the news_item table. Since its present in the translation table it would be a waste of resources to have that same field in the main table. Basically Doctrine always automatically removes all translated fields from the main table. Now the first time you initialize a new NewsItem record Doctrine initializes the behavior that builds the followings things: 1. Record class called NewsItemTranslation 2. Bi-directional relations between NewsItemTranslation and NewsItem Lets take a look at how we can manipulate the translations of the NewsItem: Listing 16-45 // test.php // ... $newsItem = new NewsItem(); $newsItem->Translation['en']->title = 'some title'; $newsItem->Translation['en']->body = 'test'; $newsItem->Translation['fi']->title = 'joku otsikko'; $newsItem->Translation['fi']->body = 'test'; $newsItem->save(); print_r($newsItem->toArray()); The above example would produce the following output: ----------------- Brought to you by