I am trying to use the localization features in cakephp. In app_model.php I have a method that gets the different payment methods.
function getDistinctFields($model, $field)
{
$list = ClassRegistry::init($model)->find('all', array(
'fields'=>array("DISTINCT $model.$field"),
'conditions' => array('not' => array("$model.$field" => null))
));
debug($list);
$translated = "{n}.$model.$field";
$return = Set::combine($list, "{n}.$model.$field", __($translated, true));
return $return;
}
The result of the debug($list) looks like this:
[0] => Array
(
[InstantPaymentNotification] => Array
(
[payment_status] => Pending
)
)
[1] => Array
(
[InstantPaymentNotification] => Array
(
[payment_status] => Completed
)
)
[2] => Array
(
[InstantPaymentNotification] => Array
(
[payment_status] => Denied
)
)
[3] => Array
(
[InstantPaymentNotification] => Array
(
[payment_status] => Refunded
)
)
The output of the method looks like this:
> Array (
> [Pending] => Pending
> [Completed] => Completed
> [Denied] => Denied
> [Refunded] => Refunded
> [Reversed] => Reversed
> [Canceled_Reversal] => Canceled_Reversal )
Nicer, but the value is not translated as it should be. I created the default.po file in the correct location and tested to see if it works on other pages. However, it seems it doesn't work with the Set class.