Skip to content
This repository has been archived by the owner on Jan 31, 2020. It is now read-only.

Duck type TranslatorAwareInterface #57

Merged
merged 1 commit into from
Apr 18, 2016

Conversation

weierophinney
Copy link
Member

Starting with zend-mvc 3, i18n features are considered opt-in and optional. However, several official helpers in zend-view are translator-aware, and optionally expose translation features if a translator is composed.

This patch does the following:

  • Introduces TranslatorAwareTrait, which encapsulates the logic for composing a translator and translation text domain. This logic was duplicated across multiple helpers already, and is simply extracted from it.
  • Updates FlashMessenger, HeadTitle, and the navigation AbstractHelper to:
    • Remove the explicit implementation of TranslatorAwareInterface.
    • Use the new TranslatorAwareTrait, effectively duck typing TranslatorAwareInterface.
  • Updates HelperPluginManager to inject a translator for helpers that either explicitly implement TranslatorAwareInterface or duck type it.

These changes fix issues when adapting the skeleton application to use the development branch of zend-mvc (future v3).

Starting with zend-mvc 3, i18n features are considered opt-in and optional.
However, several official helpers in zend-view are translator-aware, and
optionally expose translation features if a translator is composed.

This patch does the following:

- Introduces `TranslatorAwareTrait`, which encapsulates the logic for composing
  a translator and translation text domain. This logic was duplicated across
  multiple helpers already, and is simply extracted from it.
- Updates `FlashMessenger`, `HeadTitle`, and the navigation `AbstractHelper` to:
  - Remove the explicit implementation of `TranslatorAwareInterface`.
  - Use the new `TranslatorAwareTrait`, effectively duck typing
    `TranslatorAwareInterface`.
- Updates `HelperPluginManager` to inject a translator for helpers that either
  explicitly implement `TranslatorAwareInterface` or duck type it.
@weierophinney weierophinney added this to the 2.6.6 milestone Apr 18, 2016
@weierophinney weierophinney self-assigned this Apr 18, 2016
@weierophinney weierophinney merged commit e44fb0b into zendframework:master Apr 18, 2016
weierophinney added a commit that referenced this pull request Apr 18, 2016
weierophinney added a commit that referenced this pull request Apr 18, 2016
weierophinney added a commit that referenced this pull request Apr 18, 2016
@weierophinney weierophinney deleted the hotfix/i18n branch April 18, 2016 19:23
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant