我有使用不同语言运行的应用程序。自定义标签标头$this->translate('message')
可以很好地解决任何问题。我只是面临翻译zend错误消息表单的问题。这是我在module.config.php
中添加的内容。任何人都可以帮我显示不同语言的错误信息表格。
'translator' => array(
'locale' => 'pl',
'translation_file_patterns' => array(
array(
'type' => 'gettext',
'base_dir' => __DIR__ . '/../language',
'pattern' => '%s.mo',
),
array(
'type' => 'phpArray',
'base_dir' => 'vendor/zendframework/zend-i18n-resources/languages',
'pattern' => '%s/Zend_Captcha.php',
'text_domain' => 'formvalidation',
),
array(
'type' => 'phpArray',
'base_dir' => 'vendor/zendframework/zend-i18n-resources/languages',
'pattern' => '%s/Zend_Validate.php',
'text_domain' => 'formvalidation',
),
),
),
答案 0 :(得分:0)
这是我在getInputFilter表单函数中的方法。这样我就可以在Poedit中检索字符串并继续翻译:
public function getInputFilter() {
if (!$this->filter) {
$inputFilter = new InputFilter();
$factory = new InputFactory ();
$inputFilter->add($factory->createInput(array(
'name' => 'email',
'filters' => array(
array(
'name' => 'StripTags'
),
array(
'name' => 'StringTrim'
)
),
'validators' => array(
array(
'name' => 'EmailAddress',
'options' => array(
'messages' => array(
'emailAddressInvalidFormat' => _('Email address format is not invalid')
)
)
),
array(
'name' => 'NotEmpty',
'options' => array(
'messages' => array(
'isEmpty' => _('Email address is required')
)
)
),
array(
'name' => 'StringLength',
'options' => array(
'min'=>6,
'max'=>128,
'messages' => array(
\Zend\Validator\StringLength::TOO_LONG => _('Invalid length for this field')
)
)
)
)
)));
$this->filter = $inputFilter;
}
return $this->filter;
}