Build multi language pathway binding.
@return void
978514
private function runMultiLanguage(): void
    {
        // check if multi-language is enabled
        if (!App::$Properties->get('multiLanguage')) {
            $this->language = App::$Properties->get('singleLanguage');
            return;
        }

        // check if domain-lang binding is enabled
        if (Any::isArray(App::$Properties->get('languageDomainAlias'))) {
            /** @var array $domainAlias */
            $domainAlias = App::$Properties->get('languageDomainAlias');
            if (Any::isArray($domainAlias) && !Str::likeEmpty($domainAlias[$this->getHost()])) {
                $this->language = $domainAlias[$this->getHost()];
            }
            return;
        }

        // try to find language in pathway
        foreach (App::$Properties->get('languages') as $lang) {
            if (Str::startsWith('/' . $lang, $this->getPathInfo())) {
                $this->language = $lang;
                $this->languageInPath = true;
            }
        }

        // try to find in ?lang get
        if (!$this->language && Arr::in($this->query->get('lang'), App::$Properties->get('languages'))) {
            $this->language = $this->query->get('lang');
        }

        // language still not defined?!
        if (!$this->language) {
            $this->setLanguageFromBrowser();
        }
    }
1295140
protected function init()
	{
	    // language load lang
	    Ioc::language()->setLocale(Config::get('lang'));
	    Ioc::language()->load('common');
	    
	    // errorHandler register
	    Ioc::errorHandler()->register();
	    
	    if ($components = Config::get('components')) {
	        foreach ($components as $key => $def) {
	            Ioc::container()->setShared($key, $def);
	        }
	    }
	}
79879
public function registerTranslations() {
		$i18n = \Yii::$app->i18n;
		if($this->messageCategory && !isset($i18n->translations[$this->messageCategory])) {
			$i18n->translations[$this->messageCategory] = [
				'class' => 'yii\i18n\PhpMessageSource',
				'basePath' => $this->basePath . DIRECTORY_SEPARATOR . 'messages',
				'sourceLanguage' => \Yii::$app->sourceLanguage,
			];
		}
	}
24176
protected function InitLanguageFile()
    {
        if ($this->language == null)
            $this->language = new Language();

        $this->InitRecLanguageFile(get_class($this));
    }
1004623
public function actionCompile()
    {
        
        $extensionsToCreate = explode(',', $this->options['extension']);
        $extensionsToCreate = array_unique($extensionsToCreate);
        
		foreach ($extensionsToCreate as $extension){
			$language = $this->options['language'];
			$compiledTranslationFile = new tao_helpers_translation_TranslationFile();
			$compiledTranslationFile->setTargetLanguage($this->options['language']);
			
			$this->outVerbose("Compiling language '${language}' for extension '${extension}'...");
			
			// Get the dependencies of the target extension.
			// @todo Deal with dependencies at compilation time.
			$dependencies = array();
			if ($extension !== 'tao'){
				$dependencies[] = 'tao';
			}
			
			$this->outVerbose("Resolving Dependencies...");
			foreach ($dependencies as $depExtId){
				$this->outVerbose("Adding messages from extension '${depExtId}' in '${language}'...");
				// Does the locale exist for $depExtId?
				$depPath = $this->buildLanguagePath($depExtId, $language) . '/' . self::DEF_PO_FILENAME;
				if (!file_exists($depPath) || !is_readable($depPath)){
					$this->outVerbose("Dependency on extension '${depExtId}' in '${language}' does not exist. Trying to resolve default language...");
					$depPath = $this->buildLanguagePath($depExtId, tao_helpers_translation_Utils::getDefaultLanguage() . '/' . self::DEF_PO_FILENAME);

					if (!file_exists($depPath) || !is_readable($depPath)){
						$this->outVerbose("Dependency on extension '${depExtId}' in '${language}' does not exist.");
						continue;
					}
				}
				
				// Recompile the dependent extension (for the moment 'tao' meta-extension only).
				$oldVerbose = $this->options['verbose'];
				$this->parameters['verbose'] = false;
				$this->options['extension'] = $depExtId;
				$this->actionCompile();
				$this->options['extension'] = $extension;
				$this->parameters['verbose'] = $oldVerbose;
				
				$poFileReader = new tao_helpers_translation_POFileReader($depPath);
				$poFileReader->read();
				$poFile = $poFileReader->getTranslationFile();
				$poCount = $poFile->count();
				$compiledTranslationFile->addTranslationUnits($poFile->getTranslationUnits());
				
				$this->outVerbose("${poCount} messages added.");
			}

			if (($extDirectories = scandir(ROOT_PATH)) !== false){
						
				// Get all public messages accross extensions.
				foreach ($extDirectories as $extDir){
					$extPath = ROOT_PATH . '/' . $extDir;
					
					if (is_dir($extPath) && is_readable($extPath) && $extDir[0] != '.' && !in_array($extDir, $dependencies) && $extDir != $extension && $extDir != 'generis'){
						$this->outVerbose("Adding public messages from extension '${extDir}' in '${language}'...");
						
						$poPath = $this->buildLanguagePath($extDir, $language) . '/' . self::DEF_PO_FILENAME;
						if (!file_exists($poPath) || !is_readable($poPath)){
							$this->outVerbose("Extension '${extDir}' is not translated in language '${language}'. Trying to retrieve default language...");
							$poPath = $this->buildLanguagePath($extDir, tao_helpers_translation_Utils::getDefaultLanguage()) . '/' . self::DEF_PO_FILENAME;
							
							if (!file_exists($poPath) || !is_readable($poPath)){
								$this->outVerbose("Extension '${extDir}' in '${language}' does not exist.");
								continue;
							}
						}

						$poFileReader = new tao_helpers_translation_POFileReader($poPath);
						$poFileReader->read();
						$poFile = $poFileReader->getTranslationFile();
						$poUnits = $poFile->getByFlag('tao-public');
						$poCount = count($poUnits);
						$compiledTranslationFile->addTranslationUnits($poUnits);
						$this->outVerbose("${poCount} public messages added.");
					}
				}                
				
				// Finally, add the translation units related to the target extension.
				$path = $this->buildLanguagePath($extension, $language) . '/' . self::DEF_PO_FILENAME;
				if (file_exists($path) && is_readable($path)){
					$poFileReader = new tao_helpers_translation_POFileReader($path);
					$poFileReader->read();
					$poFile = $poFileReader->getTranslationFile();
					$compiledTranslationFile->addTranslationUnits($poFile->getTranslationUnits());
					
					// Sort the TranslationUnits.
					$sortingMethod = tao_helpers_translation_TranslationFile::SORT_ASC_I;
					$compiledTranslationFile->setTranslationUnits($compiledTranslationFile->sortBySource($sortingMethod));
					
					$jsPath = $this->buildLanguagePath($extension, $language) . '/' . self::DEF_JS_FILENAME;
					$jsFileWriter = new tao_helpers_translation_JSFileWriter($jsPath, $compiledTranslationFile);
					$jsFileWriter->write();
					$this->outVerbose("JavaScript compiled translations for extension '${extension}' with '${language}' written.");
				}
				else{
					$this->err("PO file '${path}' for extension '${extension}' with language '${language}' cannot be read.", true);
				}
			}
			else{
				$this->err("Cannot list TAO Extensions from root path. Check your system rights.", true);    
			}

			$this->outVerbose("Translations for '${extension}' with language '${language}' gracefully compiled.");

		}
        
    }
123657
public function build()
	{
		$this->setLayout( 'locales/index.tpl' );
		$this->addModule( 'head', 'SharedHead' );
		$this->addModule( 'footer', 'SharedFooter' );
		$this->addModule( 'system_messages', 'SharedSystemMessages' );
		
		$params = $this->getParams();
		$action = \Sifo\Router::getReversalRoute( $params['path_parts'][0] );

		$params = $this->getParams();

		
		if ( $params['params'] !== false && in_array('saved-true', $params["params"]))
		{
			\Sifo\FlashMessages::set( 'File Saved OK.', \Sifo\FlashMessages::MSG_OK );
		}
		if ( $params['params'] !== false && in_array('created-true', $params["params"]))
		{
			\Sifo\FlashMessages::set( 'File Created OK.', \Sifo\FlashMessages::MSG_OK );
		}


		if ($this->getParsedParam( 'instance' ) !== false)
		{
			$this->assign('current_instance', $this->getParsedParam( 'instance' ));
			$this->assign('languages', $this->getLanguagesInstance($this->getParsedParam( 'instance' )));
			//var_dump($this->getLanguagesInstance($this->getParsedParam( 'instance' )));
		}
		if ($this->getParsedParam( 'language' ) !== false)
		{
			$this->assign('current_language', $this->getParsedParam( 'language' ));
			$temp = explode("_", $this->getParsedParam( 'language' ));
			if (  is_array( $temp))
			{
				$this->assign('lang', $temp[1]);
			}
		}

		$instances = $this->getInstances();
		$this->assign('instances', $instances);
		// For url with params generation:
		$this->assign( 'params', $this->getParam( 'parsed_params' ) );
		$this->assign( 'params_definition', $this->getParamsDefinition() );
	}
824567
protected function createLanguages()
    {
        $this->setCliMessage('Configuring language...');

        if (!empty($this->data['store']['language']) && $this->data['store']['language'] !== 'en') {
            $this->getLanguageModel()->update($this->data['store']['language'], array('default' => true));
        }
    }
946902
protected function overrideLangJS(): void
    {
        // Bind the Laravel JS Localization command into the app IOC.
        $this->app->singleton('localization.js', function ($app) {
            $app = $this->app;
            $laravelMajorVersion = (int) $app::VERSION;

            $files = $app['files'];

            if ($laravelMajorVersion === 4) {
                $langs = $app['path.base'].'/app/lang';
            } elseif ($laravelMajorVersion === 5) {
                $langs = $app['path.base'].'/resources/lang';
            }
            $messages = $app['config']->get('localization-js.messages');
            $generator = new LangJsGenerator($files, $langs, $messages);

            return new LangJsCommand($generator);
        });

        // Bind the Laravel JS Localization command into Laravel Artisan.
        $this->commands('localization.js');
    }
855828
protected function registerBindings(): void
    {
        $this->app->bind('algolia.connection', function (Container $app) {
            $manager = $app['algolia'];

            return $manager->connection();
        });

        $this->app->alias('algolia.connection', SearchClient::class);
    }
93768
protected function buildPaths ()
		{
			$titles = [];
			$guids = [];

			$n = count($this->_data);
			for ($i = 0; $i < $n; $i++)
			{
				$parent = $this->_data[ $i ];
				for ($j = $i + 1; $j < $n; $j++)
				{
					$child = $this->_data[ $j ];
					if ($child->lft > $parent->lft and $child->rgt < $parent->rgt)
					{
						$titles[ $child->id ][] = $parent->title;
						$guids[ $child->id ][] = $parent->guid;
					}
				}
				$titles[ $parent->id ][] = $parent->title;
				$guids[ $parent->id ][] = $parent->guid;

				$parent->titlePath = implode($this->_titlePathDelimiter, $titles[ $parent->id ]);
				$parent->guidPath = implode($this->_guidPathDelimiter, $guids[ $parent->id ]);
			}
		}
725787
public function buildRootResource()
    {
        $language = new ExpressionLanguage();

        $resources = array();
        foreach ($this->resourceConfig as $name => $resource) {
            $resources[] = new Values\Resource(
                $name,
                $resource['mediaType'],
                $language->evaluate($resource['href'], [
                    'router' => $this->router,
                    'templateRouter' => $this->templateRouter,
                ])
            );
        }

        return new Root($resources);
    }
726140
private static function init()
    {
        if (!self::$defaultLng) {
            $config = Application::getConfigManager()->loadForModule('Cmf\Language');
            self::$defaultLng = strtolower($config->defaultLanguage);
            $currentLng = $config->currentLanguage;
            self::$currentLng = $currentLng ? strtolower($currentLng) : strtolower($config->defaultLanguage);
        }
    }
985962
public function headerLanguageAction()
    {
        $melisKey = $this->params()->fromRoute('melisKey', '');

        $view = new ViewModel();
        $view->melisKey = $melisKey;
        return $view;
    }
266691
public function init(): void
    {
        // Setup locale
        putenv('LC_ALL=' . $this->locale);
        putenv('LANG=' . $this->locale);
        putenv('LANGUAGE=' . $this->locale);

        // Windows workaround
        \defined('LC_MESSAGES') ?: \define('LC_MESSAGES', 6);

        setlocale(LC_MESSAGES, $this->locale);

        // For gettext only
        if (\function_exists('gettext')) {
            // Setup domain path
            $this->addTextDomain($this->domain, $this->path);

            // Setup default domain
            textdomain($this->domain);
        }
    }
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;
    }
6726
public function buildExportFields()
    {
        $this->addExportField('id', $this->translator->trans('Id'))
            ->addExportField('date', $this->translator->trans('Date'))
            ->addExportField('language', $this->translator->trans('Language'));
    }
1074749
public function handleLanguageIntoSession()
    {
        $this->settingsCommonLib();
        $this->initializeSprGlbAndSession();
        if (is_null($this->tCmnSuperGlobals->get('lang')) && is_null($this->tCmnSession->get('lang'))) {
            $this->tCmnSession->set('lang', $this->commonLibFlags['default_language']);
        } elseif (!is_null($this->tCmnSuperGlobals->get('lang'))) {
            $this->tCmnSession->set('lang', filter_var($this->tCmnSuperGlobals->get('lang'), FILTER_SANITIZE_STRING));
        }
        $this->normalizeLocalizationIntoSession();
    }