3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
10 namespace Zend\I18n\Translator
;
12 use Zend\I18n\Translator\Translator
;
14 trait TranslatorAwareTrait
19 protected $translator = null;
24 protected $translatorEnabled = true;
29 protected $translatorTextDomain = 'default';
32 * Sets translator to use in helper
34 * @param Translator $translator
35 * @param string $textDomain
38 public function setTranslator(Translator
$translator = null, $textDomain = null)
40 $this->translator
= $translator;
42 if (!is_null($textDomain)) {
43 $this->setTranslatorTextDomain($textDomain);
50 * Returns translator used in object
54 public function getTranslator()
56 return $this->translator
;
60 * Checks if the object has a translator
64 public function hasTranslator()
66 return !is_null($this->translator
);
70 * Sets whether translator is enabled and should be used
72 * @param bool $enabled
75 public function setTranslatorEnabled($enabled = true)
77 $this->translatorEnabled
= $enabled;
83 * Returns whether translator is enabled and should be used
87 public function isTranslatorEnabled()
89 return $this->translatorEnabled
;
93 * Set translation text domain
95 * @param string $textDomain
98 public function setTranslatorTextDomain($textDomain = 'default')
100 $this->translatorTextDomain
= $textDomain;
106 * Return the translation text domain
110 public function getTranslatorTextDomain()
112 return $this->translatorTextDomain
;