Since 1.2 has now been released (kudos!), I hope that a few more
people played with it since I last asked the question. I'm getting
back to this, sorry for those who read it the first time here (or on
the forums), but I think it's worth it. If I could wait for an answer
in the excellent jobeet tutorial, I'd wait, but unfortunately, I have
to bother you with this today.

I'm trying to expose the I18n fields that are stored in the database,
to the generator. I'm not sure about the best way to do that. I'm half
succeeding, but am still missing some parts, and I'm probably making
things the wrong way altogether. For now, in the form class this is
what I do:

in configure(), for each language ($l in the code below):
- copy all the widgets from the i18n form class widgetSchema (except
crsf_token);
- suffix their names with the culture code;
- setup the defaults (using inflector to translate the widgets name
into camel case);
- copy all the validators.
This seems to work pretty well. At least, all my fields are there,
display the correct values, and I can play with them in generator.yml.

in doSave():
for each language ($là and for each widget (except crsf_token):
  $value = $this->getValue($name.'_'.$l);
  $id = $this->getValue('id');
  $c = new Criteria();
  $c->add(PostI18nPeer::ID,$this->object->getPrimaryKey());
  $c->add(PostI18nPeer::CULTURE,$l);
  $obj = PostI18nPeer::doSelectOne($c, $con);
  if(count($obj)==0)   // no row for this culture
  {
    $obj = new LinkCategoryI18n();
    $obj->setCulture($l);
    $obj->setId($id);
  }
  $obj->setByName(sfInflector::camelize($name), $value);
  $obj->save();

This works well for editing an existing field, but it will not create
a new row in the I18n table.
- When I'm editing a record that has no value for a given culture, I
receive error messages saying "Culture fr: invalid" for each culture.
- When I create a new record altogether, I can trace the following
sql:
INSERT INTO post_i18n (`TITLE`,`CULTURE`) VALUES ('Test','en')
It does not pass the ID field.

Many thanks for your help.

PS: I still hope a section of jobeet will cover internationalization
extensively... Strings extraction is well explained in the
documentation, but i18n fields management less so, and there are quite
a lot of challenges to making a fully internationalized website (think
right-to-left languages for example).
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to