Lazy loads zend translator

@return ZendTranslator
321296
public function getTranslatorService()
    {
        if (is_null($this->_translatorService)) {
            $translator = new ZendTranslator();
            $translator->addTranslationFilePattern(
                $this->type,
                $this->basePath,
                '%s/'.$this->getMessageFile(),
                $this->domain
            );
            $this->_translatorService = $translator;
        }
        return $this->_translatorService;
    }
569712
public function getTranslator()
    {
        if (null === $this->_translator) {
            $serviceLocator = $this->getServiceLocator();
            if ($serviceLocator->has('Translator')) {
                $this->setTranslator($serviceLocator->get('Translator'));
            }
        }

        return $this->_translator;
    }
455833
public function getTranslation($language = null)
    {
        if ($language === null) {
            $language = $this->getLanguage();
        }

        if (!isset($this->owner->{$this->translationsAttribute}[$language])) {
            $this->owner->{$this->translationsAttribute}[$language] = $this->loadTranslation($language);
        }

        return $this->owner->{$this->translationsAttribute}[$language];
    }
1317470
protected function buildAlternateTranslations()
    {
        $translations = [];

        $context  = $this->contextObject();
        $origLang = $this->currentLanguage();

        $this->translator()->isIteratingLocales = true;
        foreach ($this->locales() as $langCode => $localeStruct) {
            if ($langCode === $origLang) {
                continue;
            }

            $this->translator()->setLocale($langCode);

            $translations[$langCode] = $this->formatAlternateTranslation($context, $localeStruct);
        }

        $this->translator()->setLocale($origLang);
        unset($this->translator()->isIteratingLocales);

        return $translations;
    }
975028
public function getTranslation($language = null)
    {
        if ($language === null) {
            $language = $this->getLanguage();
        }

        if (!isset($this->_models[$language])) {
            $this->_models[$language] = $this->loadTranslation($language);
        }

        return $this->_models[$language];
    }
654510
private function getTranslation()
    {
        $operatorTranslation = null;
        foreach ($this->entity->getTranslations() as $translation) {
            if ($translation->getLocale() == $this->locale) {
                $operatorTranslation = $translation;
            }
        }
        if (!$operatorTranslation) {
            $operatorTranslation = new OperatorTranslation();
            $operatorTranslation->setLocale($this->locale);
            $operatorTranslation->setOperator($this->entity);
            $this->entity->addTranslation($operatorTranslation);
        }

        return $operatorTranslation;
    }
692909
public function getTranslateForm()
    {
        if ($this->translateForm === null) {
            $this->translateForm = $this->getServiceLocator()->get('playgroundtranslate_translate_form');
        }
        return $this->translateForm;
    }
551271
protected function _initTranslate()
    {
        $this->bootstrap('locale');

        $language = $this->locale->getLanguage();

        /*
         * Scan for files with -<languagecode> and disable notices when the requested
         * language is not found
         */
        $options = array( 'adapter'         => 'gettext',
                          'content'         => GEMS_LIBRARY_DIR . '/languages/',
                          'disableNotices'  => true,
                          'scan'            => \Zend_Translate::LOCALE_FILENAME);

        $translate = new \Zend_Translate($options);

        // If we don't find the needed language, use a fake translator to disable notices
        if (! $translate->isAvailable($language)) {
            $translate = \MUtil_Translate_Adapter_Potemkin::create();
        }

        //Now if we have a project specific language file, add it
        $projectLanguageDir = APPLICATION_PATH . '/languages/';
        if (file_exists($projectLanguageDir)) {
            $options['content']        = $projectLanguageDir;
            $options['disableNotices'] = true;
            $projectTranslations       = new \Zend_Translate($options);
            //But only when it has the requested language
            if ($projectTranslations->isAvailable($language)) {
                $translate->addTranslation(array('content' => $projectTranslations));
            }
            unset($projectTranslations);  //Save some memory
        }

        $translate->setLocale($language);
        \Zend_Registry::set('Zend_Translate', $translate);

        // Fix for _init resource being case insensitive
        $container = $this->getContainer();
        $adapter   = $translate->getAdapter();
        $container->translateAdapter = $adapter;
        $this->translateAdapter      = $adapter;

        return $translate;
    }
520415
public function getTranslationModel($language = null) {
        if ($language === null) {
            $language = $this->getLanguage();
        }
        if (!isset($this->_models[$language])) {
            $this->_models[$language] = $this->loadTranslation($language);
        }
        return $this->_models[$language];
    }
1220210
public function translation()
    {
        if (is_null($this->translationsClass))
            $this->translationsClass = get_class($this) . 'Translations';

        return $this->hasOne($this->translationsClass, 'record_id', 'id')->where('language_code', app()->getLocale());
    }
821126
public function generateTranslateEntry()
    {
        if (is_null($this->getCrawler())) {
            throw new ParserContextException('You can\'t generate translate entry without having a crawler initialized.');
        }

        $parameters = [
            'language_from' => $this->getLanguageFrom(),
            'language_to' => $this->getLanguageTo()
        ];

        // if data is coming from $_SERVER, load it ...
        if ($this->getParser()->getConfigProvider() instanceof ServerConfigProvider) {
            $this->getParser()->getConfigProvider()->loadFromServer();
        }

        // managing auto-discover for title
        if ($this->getParser()->getConfigProvider()->getAutoDiscoverTitle()) {
            $title = 'Empty title';

            foreach ($this->getCrawler()->filter('title') as $element) {
                if ($element->nodeValue != '') {
                    $title = $element->nodeValue;
                }
            }

            $parameters['title'] = $title;
        }

        $parameters = array_merge($parameters, $this->getParser()->getConfigProvider()->asArray());
        $this->translateEntry = new TranslateEntry($parameters);

        return $this->translateEntry;
    }
629079
public function getTranslations()
    {
        return $this->owner->hasMany($this->translationClassName, [$this->languageForeignKey => $this->_ownerPrimaryKey]);
    }
331096
public static function GetInstance() : Translator
   {

      if ( null === self::$_instance )
      {
         self::$_instance = new Translator();
      }

      return self::$_instance;

   }
1322233
private function loadTranslationsFromDefaultPath()
    {
        /** @var DirectoryInterface $baseDir */
        $baseDir = $this->getBaseDirectory();
        /** @var Filesystem $filesystem */
        $filesystem = $this->getBaseDirectory()->getFilesystem();
        if ($filesystem->has($baseDir->getFullPath() . '/translations') === false) {
            return null;
        }
        $translations = [];
        /** @var Local $local */
        $local = $filesystem->getAdapter();
        $basePath = $local->getPathPrefix();

        /** @var DirectoryInterface $translationDirectory */
        $translationDirectory = $filesystem->get($baseDir->getFullPath() . '/translations');
        foreach ($translationDirectory->getContents(true) as $fileInfo) {
            if ($fileInfo->isFile() === false) {
                continue;
            }

            $format = $fileInfo->getExtension();
            $resource = $basePath . $fileInfo->getPath();
            $locale = $fileInfo->getFilename('.' . $format);

            $translations[] = [$format, $resource, $locale];
        }

        return $translations;
    }
488760
public function getTranslation($language = null)
    {
        $language = $language ?: Yii::$app->language;
        $translations = $this->getModelTranslations();

        // search translation by language in exists translations
        foreach ($translations as $translation) {
            // if translation exists - return it
            if ($translation->getAttribute($this->translationLanguageAttrName) === $language) {
                $this->translationsBuffer[] = $translation;

                return $translation;
            }
        }

        // if translation doesn't exist - create and return
        $translationEntityClass = $this->owner->getRelation($this->translationRelationName)->modelClass;

        /* @var BaseActiveRecord $translation */
        $translation = new $translationEntityClass();
        $translation->setAttribute($this->translationLanguageAttrName, $language);
        $translations[] = $translation;
        $this->translationsBuffer = $translations;
        $this->owner->populateRelation($this->translationRelationName, $translations);

        return $translation;
    }
1128758
protected function initTranslateable()
    {
        if ($this->translateAdapter instanceof \Zend_Translate_Adapter) {
            // OK
            return;
        }

        if ($this->translate instanceof \Zend_Translate) {
            // Just one step
            $this->translateAdapter = $this->translate->getAdapter();
            return;
        }

        if ($this->translate instanceof \Zend_Translate_Adapter) {
            // It does happen and if it is all we have
            $this->translateAdapter = $this->translate;
            return;
        }

        // Make sure there always is an adapter, even if it is fake.
        $this->translateAdapter = new \MUtil_Translate_Adapter_Potemkin();
    }
63831
protected function LoadLanguage()
    {
        if (is_object($this->config['language'])) {
            $l = $this->config['language'];
        } else {
            $languages = array(
                $this->config['language'],
                '\RelativeTime\Languages\\' . $this->config['language'],
            );

            $l = null;
            foreach ($languages as $lang) {
                if (class_exists($lang)) {
                    $l = new $lang();
                    break;
                }
            }
        }

        if ($l instanceof ArrayAccess) {
            return $l;
        }

        return new English();
    }