Welcome, Guest. Register Now!
   
Mark Forums Read Mark Forums Read Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 09-09-2008, 11:27 AM
Junior Member
 
Join Date: Sep 2008
Posts: 15
Default Using Zend_Translate attached to Zend_Form : Problem with latin characters

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>
appears in browser like this:
Code:
O conteúdo está vazio, mas é requerido
The form code is (relevant part...):
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 09-10-2008, 05:52 AM
Member
 
Join Date: Aug 2008
Posts: 52
Default

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 09-10-2008, 09:55 AM
Junior Member
 
Join Date: Sep 2008
Posts: 15
Default

My bad... i'm so sorry to make you guys lose your time.

The thing was that the source file was missing:
Code:
<meta http-equiv="Content-Type" content="text/html;  charset=utf-8" />
Everything works a treat now.
Thank you
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 10-08-2008, 01:32 AM
Junior Member
 
Join Date: Oct 2008
Posts: 3
Default

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:
$this->setDefaultTranslator($translate); 
That answers everything.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 10-08-2008, 11:14 PM
Junior Member
 
Join Date: Sep 2008
Posts: 15
Default

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
Attached Files
File Type: zip extractor.zip (1.4 KB, 6 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 03:45 PM.