Determines the request path.

@param  array  $languages Locale segments
@return string
329716
protected function determinePath(array $languages): string
	{
		$path = '/';

		$server = $this->server->all();

		if(isset($server['PATH_INFO']))
		{
			$path = $server['PATH_INFO'];
		}
		elseif(isset($server['REQUEST_URI']))
		{
			if($path = parse_url($server['REQUEST_URI'], PHP_URL_PATH))
			{
				// Remove base path from the request path

				$basePath = pathinfo($server['SCRIPT_NAME'], PATHINFO_DIRNAME);

				if($basePath !== '/' && stripos($path, $basePath) === 0)
				{
					$path = mb_substr($path, mb_strlen($basePath));
				}

				// Remove "/index.php" from the path

				if(stripos($path, '/' . $this->scriptName) === 0)
				{
					$path = mb_substr($path, (strlen($this->scriptName) + 1));
				}

				$path = rawurldecode($path);
			}
		}

		return $this->stripLocaleSegment($languages, $path);
	}
649095
public function getTranslationsByLocalesAndDomains($locales, $domains)
    {
        $em = $this->getEntityManager();
        $qb = $em->createQueryBuilder();
        $qb
            ->select('t')
            ->from('KunstmaanTranslatorBundle:Translation', 't')
            ->andWhere('t.status != :statusstring')
            ->setParameter('statusstring', Translation::STATUS_DISABLED)
            ->orderBy('t.domain', 'ASC')
            ->addOrderBy('t.keyword', 'ASC');

        if (count($locales) > 0) {
            $qb->andWhere($qb->expr()->in('t.locale', $locales));
        }

        if (count($domains) > 0) {
            $qb->andWhere($qb->expr()->in('t.domain', $domains));
        }

        $result = $qb
            ->getQuery()
            ->getResult();

        return $result;
    }
974991
public function getI18nPaths()
	{
		$paths = array();

		foreach ( $this->_manifests as $basePath => $manifest )
		{
			if ( isset( $manifest['i18n'] ) )
			{
				foreach( $manifest['i18n'] as $domain => $location ) {
					$paths[$domain][] = $basePath . DIRECTORY_SEPARATOR . $location;
				}
			}
		}

		return $paths;
	}
424781
private function collectValues($languages)
    {
        $values = [];

        foreach ($languages as $languageKey) {
            $languageContent = $this->manager->getFileContent($this->files[$languageKey]);

            $values[$languageKey] = $this->ask(
                sprintf(
                    '<fg=yellow>%s.%s:%s</> translation',
                    $this->fileName,
                    $this->key,
                    $languageKey
                ),
                isset($languageContent[$this->key]) ? $languageContent[$this->key] : null
            );
        }

        return $values;
    }
914075
protected function guessFrontendLocale($locales)
    {
        // search for match in array
        if (is_array($locales)) {
            foreach ($locales as $locale) {
                $match = $this->matchLocaleInAvailableLanguages($locale);
                if (strlen($match) > 0) {
                    return $match;
                }
            }
        } // check if locale matches in available languages
        else {
            $match = $this->matchLocaleInAvailableLanguages($locales);
            if (strlen($match) > 0) {
                return $match;
            }
        }

        return $this->defaultLocale;
    }
1023230
protected function getTranslationPathBaseDirectory($base, $lang = null)
    {
        if (empty($lang)) {
            $lang = $this->getLanguage();
        }

        if (!empty($this->pluginName)) {

            if ($base == 'tmp') {
                return sprintf('%s/plugins/%s/lang/%s.json', StaticContainer::get('path.tmp'), $this->pluginName, $lang);
            } else {
                return sprintf('%s/lang/%s.json', Manager::getPluginDirectory($this->pluginName), $lang);
            }
        }

        if ($base == 'tmp') {
            return sprintf('%s/%s.json', StaticContainer::get('path.tmp'), $lang);
        }

        return sprintf('%s/%s/%s.json', PIWIK_INCLUDE_PATH, $base, $lang);
    }
1074239
public function lang_get($params) {
        if (isset($params['line'])) {
            $parameters = isset($params['params']) ? $params['params'] : array();
            $default = isset($params['default']) ? $params['default'] : null;
            $language = isset($params['lang']) ? $params['lang'] : null;
            return Lang::get($params['line'], $parameters, $default, $language);
        }
        return false;
    }
1217619
public function getLocaleFromRoute($segments = null) {
        // if segmets are not set - get from current request
        if (is_null($segments)) {
            $segments = \Request::segments();
        }
        $locale = $this->getDefaultRoutelocale();
        if ($allLocales = \Routelocale::getAllRoutelocales()) {
            // reduce array of segments to [0] and find by value
            if ($curLocaleIndex = array_search(array_shift($segments), $allLocales)) {
                $locale = $allLocales[$curLocaleIndex];
            }  
        }
        return $locale;
    }
46575
public function getDefaultUrl($language = null)
    {
        foreach ($this->urls as $url) {
            if ($url->isDefault()) {
                return $url;
            }
        }

        return null;
    }
826347
public static function path(...$paths)
    {
        $protocol = '';
        $path = trim(implode(DIRECTORY_SEPARATOR, $paths));
        if (preg_match('@^([a-z0-9]+://|/)(.*)@i', $path, $m)) {
            $protocol = $m[1];
            $path = $m[2];
        }
        $path = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $path);
        $parts = array_filter(explode(DIRECTORY_SEPARATOR, $path), 'strlen');
        $absolutes = [];
        foreach ($parts as $part) {
            if ('.' == $part) {
                continue;
            }
            if ('..' == $part) {
                array_pop($absolutes);
            } else {
                $absolutes[] = $part;
            }
        }
        $path = implode(DIRECTORY_SEPARATOR, $absolutes);
        if (DIRECTORY_SEPARATOR == '\\' && isset($protocol[4])) {
            $path = str_replace(DIRECTORY_SEPARATOR, '/', $path);
        }
        return $protocol . $path;
    }
1369819
protected function getNestedResourceUri(array $segments)
	{
		$me = $this;

		// We will spin through the segments and create a place-holder for each of the
		// resource segments, as well as the resource itself. Then we should get an
		// entire string for the resource URI that contains all nested resources.
		return implode('/', array_map(function($s) use ($me)
		{
			return $s.'/{'.$me->getResourceWildcard($s).'}';

		}, $segments));
	}
898570
public function getLanguageURLPrefix($lang = null)
    {
        // if active lang is not passed in, use current active
        if (!$lang) {
            $lang = $this->getLanguage();
        }

        return $this->isIncludeDefaultLanguage($lang) ? '/' . $lang : '';
    }
1006017
protected function _getRoutesWithFallback($language) {
        $routesFile = $this->view->config()->resources->router->routesFile->{$language};
        $config = new Garp_Config_Ini($routesFile, APPLICATION_ENV);
        
        if ($config->routes) {
            return $config->routes->toArray();
        } 
        
        $routesFile = $this->view->config()->resources->router->routesFile->generic;
        $config = new Garp_Config_Ini($routesFile, APPLICATION_ENV);
        return $config->routes->toArray();
    }
368331
public static function getLanguagePath($basePath = PATH_APP, $language = null)
	{
		$dir = $basePath . DS . 'language';

		if (!empty($language))
		{
			$dir .= DS . $language;
		}

		return $dir;
	}
1028173
private function compareTranslations(array $default, array $languages)
    {
        // Return diff language by language
        foreach ($languages as $language) {
            $this->addOutput($language);
            $current = $this->getTranslations($this->basePath, $language);

            foreach ($default as $key => $values) {
                $valuesKeys = array_keys($values);

                foreach ($valuesKeys as $key2) {
                    if (in_array($key2, ['custom', 'attributes'], true)) {
                        continue;
                    }

                    if (!isset($current[$key][$key2])) {
                        $this->addOutput($language, "  * {$key} : {$key2} : not present");
                    } elseif ($current[$key][$key2] === $default[$key][$key2]) {
                        $this->addOutput($language, "  * {$key} : {$key2}");
                    }
                }
            }
        }
    }
1182743
static function fetchTranslatedNames( &$countries )
    {
        $locale = eZLocale::instance();
        $translatedCountryNames = $locale->translatedCountryNames();
        foreach ( array_keys( $countries ) as $countryKey )
        {
            $translatedName = isset( $translatedCountryNames[$countryKey] ) ? $translatedCountryNames[$countryKey] : false;
            if ( $translatedName )
                $countries[$countryKey]['Name'] = $translatedName;
        }
        usort( $countries, array( 'eZCountryType', 'compareCountryNames' ) );
    }
380402
protected function getNestedResourceUri(array $segments)
    {
        // We will spin through the segments and create a place-holder for each of the
        // resource segments, as well as the resource itself. Then we should get an
        // entire string for the resource URI that contains all nested resources.
        return implode('/', array_map(function ($segment)
        {
            $name = $this->getResourceWildcard($segment);

            return $segment .'/{' .$name .'}';

        }, $segments));
    }