This repository has been archived by the owner on Jan 31, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request zendframework/zendframework#1725 from weierophinne…
…y/feature/file-i18n [zen-66] Update File\Transfer to new Translator
- Loading branch information
Showing
7 changed files
with
108 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ | |
|
||
namespace ZendTest\Validator; | ||
|
||
use Zend\I18n\Translator\Translator; | ||
use Zend\Validator\EmailAddress; | ||
use Zend\Validator\Hostname; | ||
|
||
|
@@ -365,16 +366,21 @@ public function testHostnameValidatorMessagesShouldBeTranslated() | |
{ | ||
$hostnameValidator = new Hostname(); | ||
$translations = array( | ||
'hostnameIpAddressNotAllowed' => 'hostnameIpAddressNotAllowed translation', | ||
'hostnameUnknownTld' => 'hostnameUnknownTld translation', | ||
'hostnameDashCharacter' => 'hostnameDashCharacter translation', | ||
'hostnameIpAddressNotAllowed' => 'hostnameIpAddressNotAllowed translation', | ||
'hostnameUnknownTld' => 'hostnameUnknownTld translation', | ||
'hostnameDashCharacter' => 'hostnameDashCharacter translation', | ||
'hostnameInvalidHostnameSchema' => 'hostnameInvalidHostnameSchema translation', | ||
'hostnameUndecipherableTld' => 'hostnameUndecipherableTld translation', | ||
'hostnameInvalidHostname' => 'hostnameInvalidHostname translation', | ||
'hostnameInvalidLocalName' => 'hostnameInvalidLocalName translation', | ||
'hostnameLocalNameNotAllowed' => 'hostnameLocalNameNotAllowed translation', | ||
'hostnameUndecipherableTld' => 'hostnameUndecipherableTld translation', | ||
'hostnameInvalidHostname' => 'hostnameInvalidHostname translation', | ||
'hostnameInvalidLocalName' => 'hostnameInvalidLocalName translation', | ||
'hostnameLocalNameNotAllowed' => 'hostnameLocalNameNotAllowed translation', | ||
); | ||
$translator = new \Zend\Translator\Translator('ArrayAdapter', $translations); | ||
$loader = new TestAsset\ArrayTranslator(); | ||
$loader->translations = $translations; | ||
$translator = new Translator(); | ||
$translator->getPluginManager()->setService('test', $loader); | ||
$translator->addTranslationFile('test', null); | ||
|
||
$this->validator->setTranslator($translator)->setHostnameValidator($hostnameValidator); | ||
|
||
$this->validator->isValid('[email protected],512.777'); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
namespace ZendTest\Validator\TestAsset; | ||
|
||
use Zend\I18n\Translator; | ||
|
||
class ArrayTranslator implements Translator\Loader\LoaderInterface | ||
{ | ||
public $translations; | ||
|
||
public function load($filename, $locale) | ||
{ | ||
$textDomain = new Translator\TextDomain($this->translations); | ||
return $textDomain; | ||
} | ||
} |
Oops, something went wrong.