Issues

ZF-11336: existing translations translator missing

Issue Type: Bug Created: 2011-04-30T07:35:09.000+0000 Last Updated: 2011-07-13T21:54:10.000+0000 Status: Resolved Fix version(s): - Next Major Release ()

Reporter: Fabio Baleani (fbale) Assignee: Thomas Weidner (thomas) Tags: - Zend_Validate

  • zend_translator

Related issues: Attachments:

Description

I've a problem with translator: I've added resources/languages to my project and loaded into a default translator. Now I found some error correctly translated, some other no.

Regards, Fabio.


<pre class="highlight">
<?php
ini_set('display_errors','1');
error_reporting(E_ALL & E_NOTICE);

include('Zend/Loader/Autoloader.php');
$autoloader = Zend_Loader_Autoloader::getInstance();

$translator = new Zend_Translate(
    Zend_Translate::AN_ARRAY,'../library/Locales','it', array('scan' => Zend_Translate::LOCALE_DIRECTORY)
);

Zend_Validate_Abstract::setDefaultTranslator($translator);

$validator = new Zend_Validate_Alpha();
if (!$validator->isValid('12345')) 
{
    echo "Alpha : ";
    print_r($validator->getMessages());
}

echo "<br></br>";

Zend_Db_Table_Abstract::setDefaultAdapter(Zend_Db::factory('Pdo_Mysql', array(
    'host'           => '127.0.0.1',
    'username'       => 'root',
    'password'       => '',
    'dbname'         => 'monteromano'
)));
$validator = new Zend_Validate_Db_RecordExists(array(
        'table' => 'catasto',
        'field' => 'id_appezz'
    ));
if (!$validator->isValid('PARCO DELLA VITTORIA')) 
{       
    echo "RecordExists : ";
    print_r($validator->getMessages());
}

Actual results

<pre class="literal"> 
Alpha : Array ( [notAlpha] => '12345' contiene caratteri non alfabetici ) 
RecordExists : Array ( [noRecordFound] => No record matching 'PARCO DELLA VITTORIA' was found )

Expected results

<pre class="literal"> 
Alpha : Array ( [notAlpha] => '12345' contiene caratteri non alfabetici ) 
RecordExists : Array ( [noRecordFound] => Non è stato trovato una riga con valore 'PARCO DELLA VITTORIA' )

From translation file in it/Zend_Validate.php:

<pre class="literal">
[...]

    // Zend_Validate_Alpha
    "Invalid type given, value should be a string" => "Tipo di dato non valido, il dato dev'essere una stringa",
    "'%value%' contains non alphabetic characters" => "'%value%' contiene caratteri non alfabetici",
    "'%value%' is an empty string" => "'%value%' è una stringa vuota",

[...]

    // Zend_Validate_Db_Abstract
    "No record matching %value% was found" => "Non è stato trovato una riga con valore %value%",
                                                         //  ^--this is an typo error too... is trovata instead of trovato...
    "A record matching %value% was found" => "E' già stata trovata una riga con valore %value%",

[...]

Comments

Posted by Fabio Baleani (fbale) on 2011-04-30T07:44:16.000+0000

This is the bug at work :D

!http://www.akweb.it/public/bugAtWork.png!

Posted by Fabio Baleani (fbale) on 2011-05-03T05:10:33.000+0000

Solution:

Fix the translation string adding the missing quotes around %value%:

<pre class="highlight"> 
    // Zend_Validate_Db_Abstract
    "No record matching '%value%' was found" => "Non è stato trovata nessuna riga con valore '%value%'",
    "A record matching '%value%' was found" => "E' già stata trovata una riga con valore '%value%'",

Posted by Thomas Weidner (thomas) on 2011-06-26T14:41:22.000+0000

Detaching Zend_Translate from affected components The resource file is bogus not the component

Posted by Thomas Weidner (thomas) on 2011-06-26T17:49:41.000+0000

Fixed with Git-Request #220

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts