getLocalization() 공개 메소드

Returns the localization code, which is a combination of the language and the country.
사용 중단: use getLocale instead
public getLocalization ( string $delimiter = '_' ) : string
$delimiter string between language and country
리턴 string
예제 #1
0
 /**
  * Returns the localization for this PortalInformation.
  *
  * @return string
  */
 public function getLocale()
 {
     if (null === $this->localization) {
         return;
     }
     return $this->localization->getLocalization();
 }
예제 #2
0
파일: Generator.php 프로젝트: sulu/sulu
 /**
  * Localize given domain.
  *
  * @param string $domain
  * @param Localization $locale
  *
  * @return string
  */
 protected function localizeDomain($domain, Localization $locale)
 {
     if (!$this->urlReplacer->hasLocalizationReplacer($domain) && !$this->urlReplacer->hasLanguageReplacer($domain)) {
         $domain = $this->urlReplacer->appendLocalizationReplacer($domain);
     }
     $domain = $this->urlReplacer->replaceLanguage($domain, $locale->getLanguage());
     $domain = $this->urlReplacer->replaceCountry($domain, $locale->getCountry());
     $domain = $this->urlReplacer->replaceLocalization($domain, $locale->getLocalization());
     return $this->urlReplacer->cleanup($domain);
 }
예제 #3
0
 /**
  * Finds the next available parent-localization in which the node has a translation.
  *
  * @param string[] $availableLocales
  * @param Localization $localization The localization to start the search for
  *
  * @return null|Localization
  */
 private function findAvailableParentLocalization(array $availableLocales, Localization $localization)
 {
     do {
         if (in_array($localization->getLocalization(), $availableLocales)) {
             return $localization;
         }
         // try to load parent and stop if there is no parent
         $localization = $localization->getParent();
     } while ($localization != null);
     return;
 }
 /**
  * It should return any localizations if neither parent nor children.
  */
 public function testWebspaceAnyLocalization()
 {
     $this->inspector->getWebspace($this->document->reveal())->willReturn(self::FIX_WEBSPACE);
     $this->inspector->getLocales($this->document->reveal())->willReturn(['de']);
     $this->webspace->getLocalization(self::FIX_LOCALE)->willReturn($this->localization1->reveal());
     $this->localization1->getLocalization()->willReturn('en');
     $this->localization2->getLocalization()->willReturn('de');
     $this->hydrateEvent->getOption('load_ghost_content', true)->willReturn(true);
     $this->localization1->getParent()->willReturn(null);
     $this->localization1->getChildren()->willReturn([]);
     $this->webspace->getLocalizations()->willReturn([$this->localization2->reveal()]);
     $this->registry->updateLocale($this->document->reveal(), 'de', 'en')->shouldBeCalled();
     $this->hydrateEvent->setLocale('de')->shouldBeCalled();
     $this->subscriber->handleHydrate($this->hydrateEvent->reveal());
 }
 private function upgradeNode(StructureBridge $page, Webspace $webspace, Localization $localization, OutputInterface $output, $depth = 0)
 {
     /** @var SessionManagerInterface $sessionManager */
     $sessionManager = $this->getContainer()->get('sulu.phpcr.session');
     $session = $sessionManager->getSession();
     $node = $session->getNodeByIdentifier($page->getUuid());
     /** @var RlpStrategyInterface $strategy */
     $strategy = $this->getContainer()->get('sulu.content.rlp.strategy.tree');
     /** @var ResourceLocator $resourceLocator */
     $resourceLocator = $this->getContainer()->get('sulu.content.type.resource_locator');
     if (!$page->hasTag('sulu.rlp')) {
         return;
     }
     $property = $page->getPropertyByTagName('sulu.rlp');
     if ($property->getContentTypeName() !== 'resource_locator' && $page->getNodeType() !== Structure::NODE_TYPE_CONTENT) {
         return;
     }
     $transProperty = new TranslatedProperty($property, $localization->getLocalization(), $this->getContainer()->getParameter('sulu.content.language.namespace'));
     try {
         // load value
         $rl = $strategy->loadByContent($node, $webspace->getKey(), $localization->getLocalization());
         // save value
         $property->setValue($rl);
         $resourceLocator->write($node, $transProperty, 1, $webspace->getKey(), $localization->getLocalization());
         $session->save();
         $prefix = '   ';
         for ($i = 0; $i < $depth; ++$i) {
             $prefix .= '-';
         }
         $output->writeln($prefix . '> "' . $page->getPropertyValue('title') . '": ' . $rl);
     } catch (ResourceLocatorNotFoundException $ex) {
     }
 }
예제 #6
0
 /**
  * Create route-document for given domain.
  *
  * @param string $domain
  * @param CustomUrlBehavior $document
  * @param Localization $locale
  * @param string $persistedLocale
  * @param string $routesPath
  *
  * @return RouteDocument
  *
  * @throws ResourceLocatorAlreadyExistsException
  */
 protected function createRoute($domain, CustomUrlBehavior $document, Localization $locale, $persistedLocale, $routesPath)
 {
     $path = sprintf('%s/%s', $routesPath, $domain);
     $routeDocument = $this->findOrCreateRoute($path, $persistedLocale, $document, $domain);
     $routeDocument->setTargetDocument($document);
     $routeDocument->setLocale($locale->getLocalization());
     $routeDocument->setHistory(false);
     $this->documentManager->persist($routeDocument, $persistedLocale, ['path' => $path, 'auto_create' => true]);
     $this->documentManager->publish($routeDocument, $persistedLocale);
     return $routeDocument;
 }
예제 #7
0
 private function upgradeLocale(Webspace $webspace, Localization $localization, OutputInterface $output)
 {
     $output->writeln('  > Upgrade Locale: ' . $localization->getLocalization('-'));
     $contentNode = $this->liveSession->getNode($this->sessionManager->getContentPath($webspace->getKey()));
     $this->upgradeNode($contentNode, $webspace, $localization, $output);
     $this->upgradeByParent($contentNode, $webspace, $localization, $output);
 }