2014-09-05 51 views
1

我想翻譯包含在配置陣列中的消息:ZF2:PO/MO代與poEdit的對錶,驗證和篩選郵件

$this->add(
     [ 
      'name'  => 'username', 
      'required' => true, 
      'validators' => [ 
       [ 
        'name' => 'Regex', 
        'options' => [ 
         'pattern' => '~^[a-zA-Z\-\_0-9]+$~', 
         'messages' => [ 
          Regex::NOT_MATCH => 
           'Your username may only contain' 
           . ' letters, digits, underscores (_) and hyphens (-).' 
           . ' Please use a different one.' // Translate me 
         ] 
        ] 
       ] 
      ] 
     ] 
    ); 

不過,我不能找到一種方法與PoEdit軟件做到這一點。如果這是不可能的,那麼PoEdit可以處理它的最佳做法是什麼?

+0

_(「請使用一個不同的。」),你的意思是這樣? – Skaza 2014-09-05 12:38:20

+0

_($ string)已經翻譯了,這會產生開銷,因爲zf2驗證消息也被翻譯 – machete 2014-09-07 12:59:48

回答

1

一種可能的解決方案是編寫定製方法等

function t($string) { return $string; }

並將其添加到該目錄的方法。

Regex::NOT_MATCH =>   t('Your username may only contain' 
          . ' letters, digits, underscores (_) and hyphens (-).' 
          . ' Please use a different one.') 

不是一個漂亮的解決方案,但我發現的唯一一個合作