This repository was archived by the owner on Jan 8, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Make I18n component completely optional for Mvc #5406
Merged
weierophinney
merged 5 commits into
zendframework:develop
from
DASPRiD:bugfix/mvc-translator-wrapper
Jan 3, 2014
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
a3267ed
Make I18n component completely optional for Mvc
DASPRiD 6edd5d7
Let MVC translator implement all available translator interfaces
DASPRiD 72ccab5
Re-add translator interface
DASPRiD eb868f8
Fix interface-change related tests
DASPRiD 64e4dc1
Fix Zend\File related problem
DASPRiD File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,44 @@ | ||
| <?php | ||
| /** | ||
| * Zend Framework (http://framework.zend.com/) | ||
| * | ||
| * @link http://github.com/zendframework/zf2 for the canonical source repository | ||
| * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) | ||
| * @license http://framework.zend.com/license/new-bsd New BSD License | ||
| */ | ||
|
|
||
| namespace Zend\I18n\Translator; | ||
|
|
||
| /** | ||
| * Translator interface. | ||
| */ | ||
| interface TranslatorInterface | ||
| { | ||
| /** | ||
| * Translate a message. | ||
| * | ||
| * @param string $message | ||
| * @param string $textDomain | ||
| * @param string $locale | ||
| * @return string | ||
| */ | ||
| public function translate($message, $textDomain = 'default', $locale = null); | ||
|
|
||
| /** | ||
| * Translate a plural message. | ||
| * | ||
| * @param string $singular | ||
| * @param string $plural | ||
| * @param int $number | ||
| * @param string $textDomain | ||
| * @param string|null $locale | ||
| * @return string | ||
| */ | ||
| public function translatePlural( | ||
| $singular, | ||
| $plural, | ||
| $number, | ||
| $textDomain = 'default', | ||
| $locale = null | ||
| ); | ||
| } |
This file contains hidden or 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 hidden or 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,28 @@ | ||
| <?php | ||
| /** | ||
| * Zend Framework (http://framework.zend.com/) | ||
| * | ||
| * @link http://github.com/zendframework/zf2 for the canonical source repository | ||
| * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) | ||
| * @license http://framework.zend.com/license/new-bsd New BSD License | ||
| */ | ||
|
|
||
| namespace Zend\Mvc\I18n; | ||
|
|
||
| use Zend\I18n\Translator\TranslatorInterface as I18nTranslatorInterface; | ||
| use Zend\Validator\Translator\TranslatorInterface as ValidatorTranslatorInterface; | ||
|
|
||
| class DummyTranslator implements | ||
| I18nTranslatorInterface, | ||
| ValidatorTranslatorInterface | ||
| { | ||
| public function translate($message, $textDomain = 'default', $locale = null) | ||
| { | ||
| return $message; | ||
| } | ||
|
|
||
| public function translatePlural($singular, $plural, $number, $textDomain = 'default', $locale = null) | ||
| { | ||
| return ($number == 1 ? $singular : $plural); | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -145,10 +145,10 @@ public function injectTranslator($helper) | |
| { | ||
| if ($helper instanceof TranslatorAwareInterface) { | ||
| $locator = $this->getServiceLocator(); | ||
| if ($locator && $locator->has('MvcTranslator')) { | ||
| $helper->setTranslator($locator->get('MvcTranslator')); | ||
| } elseif ($locator && $locator->has('translator')) { | ||
| if ($locator && $locator->has('translator')) { | ||
| $helper->setTranslator($locator->get('translator')); | ||
| } elseif ($locator && $locator->has('MvcTranslator')) { | ||
| $helper->setTranslator($locator->get('MvcTranslator')); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would argue we should prefer the MvcTranslator over the Translator service here. The assumption is that the MvcTranslator service is the "bridge" implementation, and would be the one shared between all translator-aware services. |
||
| } | ||
| } | ||
| } | ||
|
|
||
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am getting
Zend\ServiceManager\Exception\ServiceNotCreatedException
While attempting to create mvctranslator(alias: MvcTranslator) an invalid factory was registered for this instance type.
Should you not implement FactoryInterface?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, now it's an invalid factory.