/** * @param string $path * @return string * @throws \Exception */ public function render($path = NULL) { if ($path === NULL) { $path = '404'; } /** @var RequestHandler $activeRequestHandler */ $activeRequestHandler = $this->bootstrap->getActiveRequestHandler(); $parentHttpRequest = $activeRequestHandler->getHttpRequest(); $requestPath = $parentHttpRequest->getUri()->getPath(); $language = explode('/', ltrim($requestPath, '/'))[0]; if ($language === 'neos') { throw new \Exception('NotFoundViewHelper can not be used for neos-routes.', 1435648210); } $language = $this->localeDetector->detectLocaleFromLocaleTag($language)->getLanguage(); if ($this->contentDimensionPresetSource->findPresetByUriSegment('language', $language) === NULL) { $language = ''; } if ($language !== '') { $language .= '/'; } $request = Request::create(new Uri(rtrim($parentHttpRequest->getBaseUri(), '/') . '/' . $language . $path)); $matchingRoute = $this->router->route($request); if (!$matchingRoute) { throw new \Exception(sprintf('Uri with path "%s" could not be found.', rtrim($parentHttpRequest->getBaseUri(), '/') . '/' . $language . $path), 1426446160); } $response = new Response(); $objectManager = $this->bootstrap->getObjectManager(); $baseComponentChain = $objectManager->get('TYPO3\\Flow\\Http\\Component\\ComponentChain'); $componentContext = new ComponentContext($request, $response); $baseComponentChain->handle($componentContext); return $response->getContent(); }
/** * Initializes some basic stuff that will basically be needed for each and * every action that is executed later on. */ public function initializeAction() { // get the account of the authenticated user $this->account = $this->securityContext->getAccount(); // set the locale $this->locale = $this->localeDetector->detectLocaleFromLocaleTag($this->settings['defaultLanguage']); if ($this->l18nService->getConfiguration()->getCurrentLocale() !== $this->locale) { $this->l18nService->getConfiguration()->setCurrentLocale($this->locale); } }
/** * @param string $locale */ public function showCommand($locale = 'en_EN') { ini_set('memory_limit', '340M'); /** @var Language $language */ $languages = $this->languageRepository->findAll(); $localeObject = $this->detector->detectLocaleFromLocaleTag($locale); foreach ($languages as $language) { $this->outputFormatted($language->getKey() . ' - ' . $language->getNameForLocale($localeObject)); } }
/** * Get an array of all values in the CLDR where the key is the type attribute * * @param string $path The xpath to select values from * @return array|boolean */ protected function getKeyValues($path) { $defaultLocale = $this->detector->detectLocaleFromLocaleTag('en'); $model = $this->cldrRepository->getModelForLocale($defaultLocale); $data = $model->getRawArray($path); if ($data === FALSE) { return FALSE; } $filteredData = array(); foreach ($data as $nodeString => $children) { if (CldrModel::getAttributeValue($nodeString, 'alt') === FALSE) { $key = CldrModel::getAttributeValue($nodeString, 'type'); $filteredData[$key] = $children; } } return $filteredData; }
/** * @test * @dataProvider sampleLocaleIdentifiers */ public function detectingBestMatchingLocaleFromLocaleIdentifierWorksCorrectly($localeIdentifier, $expectedResult) { $locale = $this->detector->detectLocaleFromLocaleTag($localeIdentifier); $this->assertEquals($expectedResult, $locale); }
/** * @return \TYPO3\Flow\I18n\Locale */ public function getLocalizedName() { $locale = $this->detector->detectLocaleFromLocaleTag($this->key); return $this->getNameForLocale($locale); }
/** * Get a locale matching the identifier string * @param string $identifier * @return \TYPO3\Flow\I18n\Locale */ public function getLocaleByIdentifier($identifier) { return $this->detector->detectLocaleFromLocaleTag($identifier); }