Issues

ZF-11336: existing translations translator missing

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.



<?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 "
"; 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

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

Expected results

 
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:

[...]

    // 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

This is the bug at work :D

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

Solution:

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

 
    // 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%'",

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

Fixed with Git-Request #220