2015-10-15 53 views
0

當我var_dump($t)輸出這樣我只想要phalcon翻譯對象屬性中的所有數組?

$t = object(Phalcon\Translate\Adapter\NativeArray)[121] 
protected '_translate' => 
array (size=14) 
    'attendancelist' => string 'ယေန႕စာရင္း' (length=30) 
    'monthlylist' => string 'လစဥ္တက္ေရာက္စာရင္း' (length=54) 
    'bye' => string 'sayounara' (length=9) 
    'hi-name' => string 'Bonjour %name%' (length=14) 
    'song' => string 'La chanson est %song%' (length=21) 
    'todaylist' => string '' (length=0) 
    'date' => string 'ရက္စြဲ' (length=18) 
    'username' => string 'နာမည္' (length=15) 
    'checkin' => string '' (length=0) 
    'late' => string 'ေနာက္က်ခ်ိန္' (length=36) 
    'checkout' => string '' (length=0) 
    'workingtime' => string 'အလုပ္ခ်ိန္' (length=30) 
    'overtime' => string 'အခ်ိန္ပို' (length=27) 
    'location' => string 'ေနရာ' (length=12) 

我想剛纔的所有陣列,所以我儘量$t->_translate也不行。

,但正確的代碼是$t->_("attendancelist");是好的....但是我想所有的數組而不是單個..

我想陣列是

array (size=14) 
    'attendancelist' => string 'ယေန႕စာရင္း' (length=30) 
    'monthlylist' => string 'လစဥ္တက္ေရာက္စာရင္း' (length=54) 
    'bye' => string 'sayounara' (length=9) 
    'hi-name' => string 'Bonjour %name%' (length=14) 
    'song' => string 'La chanson est %song%' (length=21) 
    'todaylist' => string '' (length=0) 
    'date' => string 'ရက္စြဲ' (length=18) 
    'username' => string 'နာမည္' (length=15) 
    'checkin' => string '' (length=0) 
    'late' => string 'ေနာက္က်ခ်ိန္' (length=36) 
    'checkout' => string '' (length=0) 
    'workingtime' => string 'အလုပ္ခ်ိန္' (length=30) 
    'overtime' => string 'အခ်ိန္ပို' (length=27) 
    'location' => string 'ေနရာ' (length=12) 

幫我把所有陣列?

我看到
+1

'$ t-> getTranslate()'有效嗎? – M2sh

+0

沒有它在M2sh不起作用 –

回答

0

最簡單的方法是實現toArray()方法:

class NativeArrayExt extends \Phalcon\Translate\Adapter\NativeArray { 
    public function toArray() { 
     return $this->_translate; 
    } 
} 

或重新實現_()做的,如果沒有參數providen相同。

相關問題