Gets the global Translator instance. If none is define a empty one is created.

@return \Niirrty\Translation\Translator
@throws TranslationException
331096
public static function GetInstance() : Translator
   {

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

      return self::$_instance;

   }
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;
    }
151908
public function getLanguageManager()
    {
        if ($this->languageManager != null) {
            return $this->languageManager;
        }

        $this->languageManager = new LanguageManager($this->getLanguageService());

        if ($this->logger) {
            $this->languageManager->setLogger($this->logger);
        }

        return $this->languageManager;
    }
1108220
public function translateInstance()
    {

        $instance = $this->getCurrentInstance();

        $formContainer = new tao_actions_form_Translate($this->getCurrentClass(), $instance);
        $myForm = $formContainer->getForm();

        if ($this->hasRequestParameter('target_lang')) {

            $targetLang = $this->getRequestParameter('target_lang');

            if(in_array($targetLang, tao_helpers_I18n::getAvailableLangsByUsage($this->getResource(tao_models_classes_LanguageService::INSTANCE_LANGUAGE_USAGE_DATA)))){
                $langElt = $myForm->getElement('translate_lang');
                $langElt->setValue($targetLang);
                $langElt->setAttribute('readonly', 'true');

                $trData = $this->getClassService()->getTranslatedProperties($instance, $targetLang);
                foreach($trData as $key => $value){
                    $element = $myForm->getElement(tao_helpers_Uri::encode($key));
                    if(!is_null($element)){
                        $element->setValue($value);
                    }
                }
            }
        }

        if($myForm->isSubmited()){
            if($myForm->isValid()){

                $values = $myForm->getValues();
                if(isset($values['translate_lang'])){
                    $datalang = $this->getSession()->getDataLanguage();
                    $lang = $values['translate_lang'];

                    $translated = 0;
                    foreach($values as $key => $value){
                        if(preg_match("/^http/", $key)){
                            $value = trim($value);
                            $property = $this->getProperty($key);
                            if(empty($value)){
                                if($datalang != $lang && $lang != ''){
                                    $instance->removePropertyValueByLg($property, $lang);
                                }
                            }
                            else if($instance->editPropertyValueByLg($property, $value, $lang)){
                                $translated++;
                            }
                        }
                    }
                    if($translated > 0){
                        $this->setData('message', __('Translation saved'));
                    }
                }
            }
        }

        $this->setData('myForm', $myForm->render());
        $this->setData('formTitle', __('Translate'));
        $this->setView('form.tpl', 'tao');
    }
214524
public function getTranslationsAttribute()
    {
        if (!settings('is_multilanguage') || !ContentType::find($this->type_id)->translatable)
            return null;

        $parent = $this->translation_id !== null ? Content::where('id', $this->translation_id)->first() : Content::where('id', $this->id)->first();
        $translations = Content::where('translation_id', $parent->id)->get();

        return $translations->merge([$parent]);
    }
397836
final protected function extendTranslatorService()
    {
        $app = $this->getContainer();

        $app['translator'] = $app->share(
            $app->extend(
                'translator',
                function ($translator) {
                    $translations = $this->loadTranslationsFromDefaultPath();
                    if ($translations === null) {
                        return $translator;
                    }
                    foreach ($translations as $translation) {
                        $translator->addResource($translation[0], $translation[1], $translation[2]);
                    }

                    return $translator;
                }
            )
        );
    }
1146738
public float getTranslationY() {
    return calcAverage(mDetector.getCurrentY(), mDetector.getPointerCount()) -
        calcAverage(mDetector.getStartY(), mDetector.getPointerCount());
  }
1037998
public function getRequest()
    {
        if ($this->request === null) {
            $this->request = Request::createFromGlobals();
        }

        return $this->request;
    }
493260
protected function getLocale()
    {
        if (!$this->hasArgument('forceLocale')) {
            return null;
        }
        $forceLocale = $this->arguments['forceLocale'];
        $useLocale = null;
        if ($forceLocale instanceof I18n\Locale) {
            $useLocale = $forceLocale;
        } elseif (is_string($forceLocale)) {
            try {
                $useLocale = new I18n\Locale($forceLocale);
            } catch (I18n\Exception $exception) {
                throw new InvalidVariableException('"' . $forceLocale . '" is not a valid locale identifier.', 1342610148, $exception);
            }
        } elseif ($forceLocale === true) {
            $useLocale = $this->localizationService->getConfiguration()->getCurrentLocale();
        }

        return $useLocale;
    }
513921
protected function getTranslationRepository()
    {
        if (null === $this->translationRepository) {
            $this->translationRepository = new TranslationRepository($this->getConnection());
        }

        return $this->translationRepository;
    }
518492
private function getTranslatorHelper()
    {
        if (null === $this->translatorHelper) {
           $this->translatorHelper = $this->getServiceLocator()->get('MvcTranslator');
        }
      
        return $this->translatorHelper;
    }
855229
public function currentLocale()
    {
        $langCode = $this->translator()->getLocale();
        $locales  = $this->translator()->locales();
        if (isset($locales[$langCode])) {
            $locale = $locales[$langCode];
            if (isset($locale['locale'])) {
                return $locale['locale'];
            } else {
                return $langCode;
            }
        }

        return null;
    }
569712
public function getTranslator()
    {
        if (null === $this->_translator) {
            $serviceLocator = $this->getServiceLocator();
            if ($serviceLocator->has('Translator')) {
                $this->setTranslator($serviceLocator->get('Translator'));
            }
        }

        return $this->_translator;
    }
1371555
public function getTplLanguage()
    {
        if ($this->_iTplLanguageId === null) {
            $iSessLang = \OxidEsales\Eshop\Core\Registry::getSession()->getVariable('tpllanguage');
            $this->_iTplLanguageId = $this->isAdmin() ? $this->setTplLanguage($iSessLang) : $this->getBaseLanguage();
        }

        return $this->_iTplLanguageId;
    }
932023
public static Translator<String> getIdentityTranslator()
    {
        return new Translator<String>()
        {
            @Override
            public String getPropertyName(String propertyKey)
            {
                return propertyKey;
            }

            @Override
            public String getPropertyKey(String propertyName)
            {
                return propertyName;
            }
        };
    }
815933
static function initialize()
    {
        if ( !isset( $GLOBALS['eZBorkTranslator'] ) ||
             !( $GLOBALS['eZBorkTranslator'] instanceof eZBorkTranslator ) )
        {
            $GLOBALS['eZBorkTranslator'] = new eZBorkTranslator();
        }

        $man = eZTranslatorManager::instance();
        $man->registerHandler( $GLOBALS['eZBorkTranslator'] );
        return $GLOBALS['eZBorkTranslator'];
    }
223587
public function t() {
        $args = func_get_args();
        if(count($args) < 1) {
            return false;
        }

        $message = array_shift($args);

        if(!isset($this->messages[$message])) {
	        // No translation available, return original string
            return vsprintf($message, $args);
        }

		$translation = $this->messages[$message];
        if(is_array($translation)) {
        	// Variations found, pick a translation by random
        	$translation = $translation[array_rand($translation)];
        }

        // Return translation with optional replacements
        return vsprintf($translation, $args);
    }