Skip to content

Instantly share code, notes, and snippets.

@sasezaki
Created February 21, 2013 15:59
Show Gist options
  • Save sasezaki/5005702 to your computer and use it in GitHub Desktop.
Save sasezaki/5005702 to your computer and use it in GitHub Desktop.
diff of ZF2 library directory scanned message templates VS resources/languages/en/Zend_Validate.php
1c1,21
< <?php
---
> <?php
> /**
> * Zend Framework
> *
> * LICENSE
> *
> * This source file is subject to the new BSD license that is bundled
> * with this package in the file LICENSE.txt.
> * It is also available through the world-wide-web at this URL:
> * http://framework.zend.com/license/new-bsd
> * If you did not receive a copy of the license and are unable to
> * obtain it through the world-wide-web, please send an email
> * to [email protected] so we can send you a copy immediately.
> *
> * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
> * @license http://framework.zend.com/license/new-bsd New BSD License
> */
>
> /**
> * EN-Revision: 09.Sept.2012
> */
24d43
< "The input does not appear to be a postal code" => "The input does not appear to be a postal code",
47c66
< "The input seems to be an invalid credit card number." => "The input seems to be an invalid credit card number.",
---
> "The input seems to be an invalid creditcard number" => "The input seems to be an invalid creditcard number",
58a78,79
> "Invalid type given. String, integer, array or DateTime expected" => "Invalid type given. String, integer, array or DateTime expected",
> "The input does not appear to be a valid date" => "The input does not appear to be a valid date",
82c103
< "Invalid type given." => "Invalid type given.",
---
> "Invalid type given. String expected" => "Invalid type given. String expected",
89c110
< "File does not match the given crc32 hashes" => "File does not match the given crc32 hashes",
---
> "File '%value%' does not match the given crc32 hashes" => "File '%value%' does not match the given crc32 hashes",
91c112
< "File is not readable or does not exist" => "File is not readable or does not exist",
---
> "File '%value%' is not readable or does not exist" => "File '%value%' is not readable or does not exist",
94,95c115,116
< "File has an incorrect extension" => "File has an incorrect extension",
< "File is not readable or does not exist" => "File is not readable or does not exist",
---
> "File '%value%' has a false extension" => "File '%value%' has a false extension",
> "File '%value%' is not readable or does not exist" => "File '%value%' is not readable or does not exist",
98c119
< "File does not exist" => "File does not exist",
---
> "File '%value%' does not exist" => "File '%value%' does not exist",
101,102c122,123
< "File has an incorrect extension" => "File has an incorrect extension",
< "File is not readable or does not exist" => "File is not readable or does not exist",
---
> "File '%value%' has a false extension" => "File '%value%' has a false extension",
> "File '%value%' is not readable or does not exist" => "File '%value%' is not readable or does not exist",
110c131
< "File does not match the given hashes" => "File does not match the given hashes",
---
> "File '%value%' does not match the given hashes" => "File '%value%' does not match the given hashes",
112c133
< "File is not readable or does not exist" => "File is not readable or does not exist",
---
> "File '%value%' is not readable or does not exist" => "File '%value%' is not readable or does not exist",
115,120c136,141
< "Maximum allowed width for image should be '%maxwidth%' but '%width%' detected" => "Maximum allowed width for image should be '%maxwidth%' but '%width%' detected",
< "Minimum expected width for image should be '%minwidth%' but '%width%' detected" => "Minimum expected width for image should be '%minwidth%' but '%width%' detected",
< "Maximum allowed height for image should be '%maxheight%' but '%height%' detected" => "Maximum allowed height for image should be '%maxheight%' but '%height%' detected",
< "Minimum expected height for image should be '%minheight%' but '%height%' detected" => "Minimum expected height for image should be '%minheight%' but '%height%' detected",
< "The size of image could not be detected" => "The size of image could not be detected",
< "File is not readable or does not exist" => "File is not readable or does not exist",
---
> "Maximum allowed width for image '%value%' should be '%maxwidth%' but '%width%' detected" => "Maximum allowed width for image '%value%' should be '%maxwidth%' but '%width%' detected",
> "Minimum expected width for image '%value%' should be '%minwidth%' but '%width%' detected" => "Minimum expected width for image '%value%' should be '%minwidth%' but '%width%' detected",
> "Maximum allowed height for image '%value%' should be '%maxheight%' but '%height%' detected" => "Maximum allowed height for image '%value%' should be '%maxheight%' but '%height%' detected",
> "Minimum expected height for image '%value%' should be '%minheight%' but '%height%' detected" => "Minimum expected height for image '%value%' should be '%minheight%' but '%height%' detected",
> "The size of image '%value%' could not be detected" => "The size of image '%value%' could not be detected",
> "File '%value%' is not readable or does not exist" => "File '%value%' is not readable or does not exist",
123,125c144,146
< "File is not compressed, '%type%' detected" => "File is not compressed, '%type%' detected",
< "The mimetype could not be detected from the file" => "The mimetype could not be detected from the file",
< "File is not readable or does not exist" => "File is not readable or does not exist",
---
> "File '%value%' is not compressed, '%type%' detected" => "File '%value%' is not compressed, '%type%' detected",
> "The mimetype of file '%value%' could not be detected" => "The mimetype of file '%value%' could not be detected",
> "File '%value%' is not readable or does not exist" => "File '%value%' is not readable or does not exist",
128,130c149,151
< "File is no image, '%type%' detected" => "File is no image, '%type%' detected",
< "The mimetype could not be detected from the file" => "The mimetype could not be detected from the file",
< "File is not readable or does not exist" => "File is not readable or does not exist",
---
> "File '%value%' is no image, '%type%' detected" => "File '%value%' is no image, '%type%' detected",
> "The mimetype of file '%value%' could not be detected" => "The mimetype of file '%value%' could not be detected",
> "File '%value%' is not readable or does not exist" => "File '%value%' is not readable or does not exist",
133,135c154,156
< "File does not match the given md5 hashes" => "File does not match the given md5 hashes",
< "An md5 hash could not be evaluated for the given file" => "An md5 hash could not be evaluated for the given file",
< "File is not readable or does not exist" => "File is not readable or does not exist",
---
> "File '%value%' does not match the given md5 hashes" => "File '%value%' does not match the given md5 hashes",
> "A md5 hash could not be evaluated for the given file" => "A md5 hash could not be evaluated for the given file",
> "File '%value%' is not readable or does not exist" => "File '%value%' is not readable or does not exist",
138,140c159,161
< "File has an incorrect mimetype of '%type%'" => "File has an incorrect mimetype of '%type%'",
< "The mimetype could not be detected from the file" => "The mimetype could not be detected from the file",
< "File is not readable or does not exist" => "File is not readable or does not exist",
---
> "File '%value%' has a false mimetype of '%type%'" => "File '%value%' has a false mimetype of '%type%'",
> "The mimetype of file '%value%' could not be detected" => "The mimetype of file '%value%' could not be detected",
> "File '%value%' is not readable or does not exist" => "File '%value%' is not readable or does not exist",
143c164
< "File exists" => "File exists",
---
> "File '%value%' exists" => "File '%value%' exists",
146c167
< "File does not match the given sha1 hashes" => "File does not match the given sha1 hashes",
---
> "File '%value%' does not match the given sha1 hashes" => "File '%value%' does not match the given sha1 hashes",
148c169
< "File is not readable or does not exist" => "File is not readable or does not exist",
---
> "File '%value%' is not readable or does not exist" => "File '%value%' is not readable or does not exist",
151,153c172,174
< "Maximum allowed size for file is '%max%' but '%size%' detected" => "Maximum allowed size for file is '%max%' but '%size%' detected",
< "Minimum expected size for file is '%min%' but '%size%' detected" => "Minimum expected size for file is '%min%' but '%size%' detected",
< "File is not readable or does not exist" => "File is not readable or does not exist",
---
> "Maximum allowed size for file '%value%' is '%max%' but '%size%' detected" => "Maximum allowed size for file '%value%' is '%max%' but '%size%' detected",
> "Minimum expected size for file '%value%' is '%min%' but '%size%' detected" => "Minimum expected size for file '%value%' is '%min%' but '%size%' detected",
> "File '%value%' is not readable or does not exist" => "File '%value%' is not readable or does not exist",
180c201
< "Too many words, maximum '%max%' are allowed but '%count%' were counted." => "Too many words, maximum '%max%' are allowed but '%count%' were counted.",
---
> "Too much words, maximum '%max%' are allowed but '%count%' were counted" => "Too much words, maximum '%max%' are allowed but '%count%' were counted",
182c203
< "File is not readable or does not exist" => "File is not readable or does not exist",
---
> "File '%value%' is not readable or does not exist" => "File '%value%' is not readable or does not exist",
222,224d242
< // Zend_Validator_IsInstanceOf
< "The input is not an instance of '%className%'" => "The input is not an instance of '%className%'",
<
270d287
<
<?php
use Zend\Loader\StandardAutoloader;
use Zend\Code\Scanner\DirectoryScanner;
require 'library/Zend/Loader/StandardAutoloader.php';
$i18n_dir = __DIR__.'/library/Zend/I18n';
$validator_dir = __DIR__.'/library/Zend/Validator';
$loader = new StandardAutoloader(array('autoregister_zf' => true));
$loader->register();
function scan_messageTemplates($dir) {
$scanner = new DirectoryScanner($dir);
$classes = $scanner->getClasses();
$translateSet = array();
foreach ($classes as $class) {
foreach ($class->getProperties() as $property) {
if ($property->getName() === 'messageTemplates') {
//var_dump($property->getValue());
$reflection = new ReflectionClass($class->getName());
$defaults = $reflection->getDefaultProperties();
$translateSet[str_replace('\\', '_', $class->getName())] = $defaults['messageTemplates'];
}
}
}
return $translateSet;
}
$translateSet = array_merge(scan_messageTemplates($i18n_dir), scan_messageTemplates($validator_dir));
ksort($translateSet);
$translate = "\n";
foreach ($translateSet as $class_name => $messages) {
$translate .= " // $class_name"."\n";
foreach ($messages as $key => $message) {
$translate .= <<<EOF
"$message" => "$message",
EOF;
$translate .= "\n";
}
$translate .= "\n";
}
file_put_contents(__DIR__.'/Zend_Validate.en.php', "<?php \nreturn array($translate);"."\n");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment