views:

54

answers:

1

I'm repeatedly getting confused between Language & Culture in Symfony. - I'm setting culture as (en_US) which I guess is correct - but translation files are created for a language (en) - also, when using translation in the database, the lang=en

I have a model whose definition is as follows:

Option:
  package: Options
  tableName: Com_Options
  actAs:
    I18n:
      fields: [name, tooltip]
  columns:
    id:
      type: integer(2)
      primary: true
      notnull: true
      unsigned: true
#      autoincrement: true
    name:
      type: string(50)
      notnull: true
      notblank: true
    tooltip:
      type: string(100)
    sequence:
      type: integer(1)
      unsigned: true
      range: [0,255]

This class is referred by several other classes. When I try to print the name as $refObj->Option->Name I get nothing. When I check the queries, I see that 3 queries are fired in all.

1) to get refObj
2) to get Option
3) to get Translation

But the real problem is that for 3, there is no language parameter in the query.

I wonder how it will get the translated name? Current value of sf_culture: en_US

Is there another way to access the 'name' according to user's language? Or do I need to write custom queries on every model?

Is the problem because autoincrement is OFF, or because Im using a package?

Thanks a lot!

A: 

Found this: a very tedious & costly method, but works:

$class->relation->Translation[$lang]->property

If you wish to read directly from database

$q = Table::getInstance()->createQuery('a')
        ->select('a.id, t.name')
        ->leftJoin('a.Translation t')
        ->where('t.lang = ?', $lang);
return $q->execute(array(), Doctrine::HYDRATE_NONE);

If you use XLIFF files, you need not pass culture/language

__('text which is translated in the XLIFF for user\'s culture');
Prasad