Initialize the translate component.

Scans the application and project dirs for available translations

Use $this->translate to access afterwards
Also sets $this->translateAdapter to access afterwards

@return \Zend_Translate
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;
    }
305850
protected function getTranslateHelper()
    {
        if ( $this->translateHelper )
        {
            return $this->translateHelper;
        }

        if ( method_exists( $this->view, 'plugin' ) )
        {
            $this->translateHelper = $this->view
                                          ->plugin( 'translate' );
        }

        if ( ! $this->translateHelper instanceof Translate )
        {
            $this->translateHelper = new Translate();
        }

        return $this->translateHelper;
    }
784475
protected static function translator()
    {
        if (static::$translator === null) {
            $translator = new Translator('en');
            $translator->addLoader('array', new ArrayLoader());
            static::$translator = $translator;
            static::setLocale('en');
        }

        return static::$translator;
    }
950783
protected function initElements()
    {
        
        
    	parent::initElements();
    	
    	$elements = $this->form->getElements();
    	$this->form->setElements(array());
    	
    	
    	$currentLangElt = tao_helpers_form_FormFactory::getElement('current_lang', 'Textbox');
		$currentLangElt->setDescription(__('Current language'));
		$currentLangElt->setAttributes(array('readonly' => 'true'));
		$currentLangElt->setValue(\common_session_SessionManager::getSession()->getDataLanguage());	//API lang /data lang
		$this->form->addElement($currentLangElt);
		
		$dataLangElement = tao_helpers_form_FormFactory::getElement('translate_lang', 'Combobox');
		$dataLangElement->setDescription(__('Translate to'));
		$dataLangElement->setOptions(tao_helpers_I18n::getAvailableLangsByUsage(new core_kernel_classes_Resource(tao_models_classes_LanguageService::INSTANCE_LANGUAGE_USAGE_DATA)));
		$dataLangElement->setEmptyOption(__('Select a language'));
		$dataLangElement->addValidator( tao_helpers_form_FormFactory::getValidator('NotEmpty') );
		$this->form->addElement($dataLangElement);
		
		$this->form->createGroup('translation_info', __('Translation parameters'), array('current_lang', 'translate_lang'));
    	
		$dataGroup = array();
		foreach($elements as $element){
			
			if( $element instanceof tao_helpers_form_elements_Hidden ||
				$element->getName() == 'uri' || $element->getName() == 'classUri'){
					
				$this->form->addElement($element);
				
			}
			else{
				
				$propertyUri = tao_helpers_Uri::decode($element->getName());
				$property = new core_kernel_classes_Property($propertyUri);
				
				//translate only language dependent properties or Labels
				//supported widget are: Textbox, TextArea, HtmlArea
				//@todo support other widgets
				if(	( $property->isLgDependent() && 
					  ($element instanceof tao_helpers_form_elements_Textbox ||
					   $element instanceof tao_helpers_form_elements_TextArea ||
					   $element instanceof tao_helpers_form_elements_HtmlArea
					  ) ) ||
					$propertyUri == OntologyRdfs::RDFS_LABEL){
				
					$translatedElt = clone $element;
					
					$viewElt = tao_helpers_form_FormFactory::getElement('view_'.$element->getName(), 'Label');
					$viewElt->setDescription($element->getDescription());
					$viewElt->setValue($element->getValue());
					$viewElt->setAttribute('no-format', true);
					if ($element instanceof tao_helpers_form_elements_HtmlArea){
						$viewElt->setAttribute('htmlentities', false);
					}
					
					$this->form->addElement($viewElt);
					
					$dataGroup[] = $viewElt->getName();
					
					$translatedElt->setDescription(' ');
					$translatedElt->setValue('');
					if($propertyUri == OntologyRdfs::RDFS_LABEL){
						$translatedElt->setForcedValid();
					}
				
					$this->form->addElement($translatedElt);
					
					$dataGroup[] = $translatedElt->getName();
				}
			}
		}
		
		$this->form->createGroup('translation_form', __('Translate'), $dataGroup);
		
        
    }
489253
private function getTranslatorHelper()
    {
        if(null === $this->translatorHelper) {
            $this->translatorHelper = $this->serviceLocator->get('MvcTranslator');
        }
    
        return $this->translatorHelper;
    }
539376
protected function registerTraslator()
    {
        $this->app->singleton('translator', function ($app) {
            $loader = $app['translation.loader'];

            // When registering the translator component, we'll need to set the default
            // locale as well as the fallback locale. So, we'll grab the application
            // configuration so we can easily get both of these values from there.
            $locale = $app['config']['app.locale'];

            $trans = new Translator($loader, $locale);

            $trans->setFallback($app['config']['app.fallback_locale']);

            return $trans;
        });
    }
340441
protected function Init()
    {
        $this->login = ContentLogin::Schema()->ByContent($this->Content());
        $this->HandleLoggedIn();
        $passwordUrl = $this->login->GetPasswordUrl();
        $this->passwordUrl = $passwordUrl ? FrontendRouter::Url($passwordUrl) : '';
        $this->AddNameField();
        $this->AddPasswordField();
        $this->AddUniqueSubmit('LoginSubmit');
        $validator = new Access(self::Guard(), false, $this->ErrorPrefix('Access'));
        $this->Elements()->AddValidator($validator);
        return parent::Init();
    }
910148
public static function bindTranslator($app)
    {
        //1. Bind the translation line loader.
        static::bindLoader($app);

        //2. Bind the translator.
        $app->singleton('translator', function ($app) {
            // When registering the translator component, we'll need to set the default
            // locale as well as the fallback locale. So, we'll grab the application
            // configuration so we can easily get both of these values from there.
            $trans = new Translator(
                $app['translation.loader'], $app['config']['app.locale']
            );

            $trans->setFallback($app['config']['app.fallback_locale']);

            return $trans;
        });
    }
318311
public function load_translation()
    {
        $translator = new \Gettext\Translator();
        $i18n_path = realpath(__DIR__ . '/../../i18n/' . Config::$locale . '.po');

        if (file_exists($i18n_path)) {
            $translations = \Gettext\Translations::fromPoFile($i18n_path);
            $translator->loadTranslations($translations);
        }

        Translator::initGettextFunctions($translator);
    }
331096
public static function GetInstance() : Translator
   {

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

      return self::$_instance;

   }
1114570
public function setUpTranslatableLocale()
    {
        /** @var \Gedmo\Translatable\TranslatableListener $translatable */
        $translatableListener = $this->getContainer()->get('stof_doctrine_extensions.listener.translatable', ContainerInterface::NULL_ON_INVALID_REFERENCE);
        if ($translatableListener) {
            $translatableListener->setTranslatableLocale($this->getDefaultLocale());
        }
    }
120501
public static function getDefaultTranslator()
    {
        if (null === self::$_defaultTranslator) {
            require_once 'Zend/Registry.php';
            if (Zend_Registry::isRegistered('Zend_Translate')) {
                $translator = Zend_Registry::get('Zend_Translate');
                if ($translator instanceof Zend_Translate_Adapter) {
                    return $translator;
                } elseif ($translator instanceof Zend_Translate) {
                    return $translator->getAdapter();
                }
            }
        }

        return self::$_defaultTranslator;
    }
776080
public function run()
    {
        $languageSource = LanguageSource::find()->where([
            'category' => Yii::$app->request->post('category', ''),
            'MD5(message)' => Yii::$app->request->post('hash', ''),
        ])->one();

        if (!$languageSource) {
            return '<div id="translate-manager-error">' . Yii::t('language', 'Text not found in database! Please run project scan before translating!') . '</div>';
        }

        return $this->controller->renderPartial('dialog', [
            'languageSource' => $languageSource,
            'languageTranslate' => $this->_getTranslation($languageSource),
        ]);
    }
1136967
public function init()
    {
        $this->setName('emails')
             ->setLabel(/* @translate */ 'E-Mail Notifications');
        
        $this->add(
            array('type' => Checkbox::class,
                'name' => 'mailAccess',
                'label' => 'foo',
                'options' => array('label' => /* @translate */ 'receive E-Mail alert',
                                   'long_label' => /* @translate */ 'if checked, you\'ll be informed by mail about new applications.'),
                )
        );
        $this->add(
            array('type' => 'Zend\Form\Element\Textarea',
                'name' => 'mailAccessText',
                'options' => array('label' => /* @translate */ 'Mailtext',
                                            'description' => /* @translate */ 'default text of the notification mail about new applications. The following variables can be used:<ul><li>##name## = your name</li><li>##title## = title of the job</li><li>##link## = Url of the application detail page</li></ul>'))
        );
        
        $this->add(
            array('type' => 'Zend\Form\Element\Checkbox',
                'name' => 'autoConfirmMail',
                'options' => array('label' => /* @translate */ 'confirm application immidiatly after submit',
                                   'long_label' => /* @translate */ 'if checked, an application is immediatly confirmed. If unchecked confirmation is the duty of the recruiter.'),
                )
        );
        $this->add(
            array('type' => 'Zend\Form\Element\Textarea',
                        'name' => 'mailConfirmationText',
                         'options' => array('label' => /* @translate */ 'Confirmation mail text',
                                            'description' => /* @translate */ 'default text of the acknowledgment of receipt mail to the applicant. The following variables can be used:<br><ul><li>##anrede_formell## = salutation. Includes gender, firstname and lastname.<li>##anrede_informell## = salutation. Includes fistname and lastname.</li><li>##job_title## = title of the jobs</li><li>##name## = name of the applicant.</li><li>##date## = date of recipt of the application.</li><li>##link## = Link to the application details</li></ul>' ))
        );
        
        $this->add(
            array('type' => 'Zend\Form\Element\Textarea',
                'name' => 'mailInvitationText',
                'options' => array('label' => /* @translate */ 'Invitation mail text',
                                    'description'=> /* @translate */ 'default text of the invitation mail to the applicant. You can use all variables of the acknowledgment of receipt mail. '
                                    ))
        );

        $this->add(
            [
                'type' => 'Zend\Form\Element\Textarea',
                'name' => 'mailAcceptedText',
                'options' => [
                    'label' => /* @translate */ 'Accept mail text',
                    'description'=> /* @translate */ 'default text, when accepting an applicant. This mail is send to by a domain admin to the recruiter, who is responsible for the job posting.'
                ]
            ]
        );
        
        $this->add(
            [
                'type' => 'Zend\Form\Element\Textarea',
                'name' => 'mailRejectionText',
                'options' => [
                    'label' => /* @translate */ 'Rejection mail text',
                    'description' => /* @translate */ 'default text of the refusal of an application to the applicant. You can use all variables of the acknowledgment of receipt mail.'
                ]
            ]
        );
        
        $this->add(
            [
                'type' => 'Zend\Form\Element\Checkbox',
                'name' => 'mailBCC',
                'options' => [
                    'label' => /* @translate */ 'get blind carbon copy of all own mails',
                    'long_label' => /* @translate */ 'if checked, you\'ll get a copy of all mails you send.',
                    'value_options' => [0, 1, true, false]
                ]
            ]
        );

        $this->add(
            array(
                'type' => 'Settings/DisableElementsCapableFormSettingsFieldset',
                'name' => 'applyFormSettings',
                'options' => array(
    
                )
            )
        );
    }
738528
protected function registerTranslationBindings()
    {
        $this->singleton('translator', function () {
            $this->configure('app');

            $this->instance('path.lang', $this->getLanguagePath());

            $this->register('Orchestra\Translation\TranslationServiceProvider');

            return $this->make('translator');
        });
    }
779762
private function initializeCoreI18n()
    {
        if ($this->hasContainer()) {
            /** @var Translator $translator */
            $translator = $this->container->get('thelia.translator');

            if (null !== $translator) {
                $i18nPath = sprintf('%s%s/I18n/', THELIA_MODULE_DIR, $this->getCode());
                $languages = LangQuery::create()->find();

                foreach ($languages as $language) {
                    $locale = $language->getLocale();
                    $i18nFile = sprintf('%s%s.php', $i18nPath, $locale);

                    if (is_file($i18nFile) && is_readable($i18nFile)) {
                        $translator->addResource('php', $i18nFile, $locale, strtolower(self::getModuleCode()));
                    }
                }
            }
        }
    }
29423
public function translate()
	{
		$arguments = func_get_args();

		// Default translation parameters.
		$translate = array(
			'context' => $this->context(),
			'lang' => $this->lang(),
			'parameters' => $this->parameters(),
			'string' => $this->string(),
		);

		// Populate `$translate` variable with function arguments and/or model state.
		foreach ($this->_translate as $i => $element)
		{
			$this->_setup_element($translate, $element, $i, $arguments);
		}
		// Now that the basic data have been set, parameters that need to have context values.
		foreach ($this->_context_params as $parameter)
		{
			$translate['parameters'][$parameter] = $translate[self::CONTEXT];
		}

		// Translate using the populated data.
		return $this->i18n()
			->translate($translate['string'], $translate['context'], $translate['parameters'], $translate['lang']);
	}