|
|||
|
Hello guys,
After much reading, googling, etc, i finally decided to post my problem here. Here's my problem, i am using a tmx file to translate validation errors on form submission. But the translated string are not encoded correctly. For instance, in xml file i have: Code:
<?xml version="1.0" encoding="UTF-8"?>
...
...
<tu tuid="isEmpty">
<note>Validation message template for class Zend_Validate_NotEmpty.</note>
<note>Possible variables include value</note>
<tuv xml:lang="pt">
<seg>O conteúdo está vazio, mas é requerido</seg>
</tuv>
</tu>
Code:
O conteúdo está vazio, mas é requerido Code:
class forms_RegisterForm extends Zend_Form {
public function __construct($options = null)
{
parent::__construct ($options);
$this->setName('Registo');
$locale = new Zend_Locale();
$translate = new Zend_Translate('tmx', APPLICATION_DIRECTORY . '/languages/portuguese.xml', $locale);
$this->setDefaultTranslator($translate);
$firstName = new Zend_Form_Element_Text('firstName');
$firstName->setLabel('Nome')
->setRequired(true)
->addValidator('NotEmpty');
.....
What am i doing wrong? Can't this be done? Thank you very much in advance. ![]() |
|
|||
|
Ever tried if the translation itself, without form works encoded ?
Aka, have you tried if your translation and sourcefile is encoded right ? When this works, than it's not a I18N problem, but a MVC problem. ![]() Just to note. Translation returns the source in the same encoding as it was written. There is no change at all. You can even not define the encoding which is returned as this would not be possible for Zend_Translate when you use WIN-1252 and have chinese characters in your source for example. I think you've somewhere missed a utf-8 setting. php.ini, form, framework, html header...
__________________
Greetings Thomas Weidner I18N Team Leader, Zend Framework http://www.thomasweidner.com |
|
|||
|
Well, a bit offline reply, just wanting to say the topic has helped anyway.
As I just started ZF and still studying docs., your code solved a good doubt I had "how to translate those Validator messages?" (probably in docs, but I haven't seen yet): PHP Code:
![]() |
|
|||
|
To easily get most of the usual error messages from the validators here's a script to get them automatically.
![]() The source code page generated is a XML file for translation. ![]() Just put this file in your ../library folder P.S.-I found this script somewhere, i didn't write it. Credits to the creator... :P |
![]() |
| Thread Tools | |
| Display Modes | |
|
|