zendframework/zf2 — pull request #1828 by cgmartin (2012-07-10 01:54:06+00:00)
Title: [WIP] I18n translation support for Form labels and validation errors

DO NOT MERGE. Form label translations, looking for feedback. No tests yet.

Borrowed pattern that exists in Zend\Validator\AbstractValidator, applied to Zend\Form\Element, and added support for text domains.

Usage:
```php
use Zend\I18n\Translator\Translator;
use Zend\Form\Element;
use Zend\Validator\AbstractValidator;
use Zend\Validator\Date as DateValidator;

$translator = new Translator();

//
// To set a global translator for all Elements and Validators:
Element::setDefaultTranslator($translator);
AbstractValidator::setDefaultTranslator($translator);

//
// Element usage:
$element = new Element('foo', array(
'translator' => $translator,
'translator_text_domain' => 'myDomain', // default is 'default'
'translator_disabled' => false, // default is false
));
// or
$element
->setTranslator($translator)
->setTranslatorTextDomain('myDomain') // default is 'default'
->setTranslatorDisabled(false); // default is false

//
// Validator usage:
$validator = new DateValidator(array(
'translator' => $translator,
'translatorTextDomain' => 'myDomain', // default is 'default'
'translatorDisabled' => false, // default is false
)); // options in validators may need underscores/cleanup?

// or
$validator
->setTranslator($translator)
->setTranslatorTextDomain('myDomain') // default is 'default'
->setTranslatorDisabled(false); // default is false

```

Specialized Zend\Form\Element\*.php could pass it's translator down to it's default validators (see example in Zend\Form\Element\Color.php).

No changes to Zend\Form\View\Helper\FormLabel. To use this helper with translate, you'd need to do:
```php
// inside view.phtml
echo $this->formLabel($this->translate('My Label'));
```