问题
I am having a problem in Symfony 1.4 and Doctrine with getting the value of an i18n object without output escaping.
Typically I just do this $object->getDescription(ESC_RAW);
to get the value un-escaped. The problem comes in when I want to get a specific translation of the object. How do I specify the culture and the escaping strategy? I haven't found any documentation on this. Can I pass multiple parameters as an array or something similar to this: $object->getDescription(array('fr', ESC_RAW));
?
Here's the relevant portion of my schema:
Object:
actAs:
Timestampable: ~
I18n:
fields: [name, description]
columns:
name: { type: string(255), notnull: true }
description: { type: string(1000) }
user_id: { type: integer }
relations:
User: { class: sfGuardUser, local: user_id, foreign: id, type: one, foreignType: many, foreignAlias: Objects }
回答1:
Try:
sfOutputEscaper::unescape($object->Translation['fr']->description);
回答2:
$object->Translation['fr']->getDescription(ESC_RAW);
This should do the trick :)
来源:https://stackoverflow.com/questions/14988309/symfony-i18n-objects-without-output-escaping