コード例 #1
0
 private function serializeRequest(Request $request)
 {
     return $this->serializeLanguageParams($request->getLanguageTag(), $request->getLanguage(), $request->getScript(), $request->getRegion(), $request->getVariantsTag(), $request->getVariants(), $request->getExtensionsTag(), $request->getExtensions());
 }
コード例 #2
0
 /**
  * Returns the appropriate fallback language chain for a given language.
  *
  * In other words, if a system has the available languages as en-CA, en-US, de-DE
  * Default language is de-DE
  * And a user requests en-SG; this will return array(en-CA, en-US, de-DE).
  * If a user requests fi-FI; will return array(de-DE)
  *
  * TODO: Use External Locale Provider
  * @param string $language
  * @return string[]
  */
 private function resolveLanguageChain($language)
 {
     $resolvedLanguage = $this->resolveLanguage($language);
     if (isset($this->languageResolutionChain[$resolvedLanguage])) {
         return $this->languageResolutionChain[$resolvedLanguage];
     }
     $chain = array();
     $request = new Request('na', $language);
     $chain[] = $request->getLanguageTag();
     $chain[] = implode('-', array_filter(array($request->getLanguage(), $request->getScript(), $request->getRegion())));
     $chain[] = implode('-', array_filter(array($request->getLanguage(), $request->getRegion())));
     $chain[] = implode('-', array_filter(array($request->getLanguage(), $request->getScript())));
     $chain[] = implode('-', array_filter(array($request->getLanguage())));
     $chain[] = $this->getOptions()->getFallbackLanguage();
     $chain = array_filter(array_unique($chain));
     return $chain;
 }