Hello,

In a project I need to have distinct labels for male or female items.

Simple example :
  User [ gender ('m', 'f') ; role_id ]
  Role [ id ; label ]

Imagine we have :
Role#1 : "Directeur"
User#1 : [ 'f' ; 1 ]

When i display user#1's role i'd like to display "Directrice" and not
"Directeur".

I was planning to handle it by fake languages this way :
- Default labels are all male.
- A lang "LANG_female" for all female labels.

And this method in User.php :
function getRoleLabel()
{
  // Change language to "female" if needed
  if ($this->getGender() == 'f') {
    sfContext::getInstance()->getI18N()->setCulture
(sfContext::getInstance()->getUser()->getCulture().'_female');
  }

  // Get label in the required language
  $role_label = sfContext::getInstance()->getI18N()->__($this->getRole
()->getLabel());

  // Rollback to user's culture
  sfContext::getInstance()->getI18N()->setCulture
(sfContext::getInstance()->getUser()->getCulture());

  return $role_label;
}




This method would have some advantages :
 - Relies on a standard pre-existing flow
 - Easy to edit labels in XLIFF format

But I'm not sure to see the main disadvantages (except that it
requires to extend all the concerned methods) nor if there is a
simplier way to handle this.
--~--~---------~--~----~------------~-------~--~----~
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 
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to