original_string: public function getBestRenderLocales($ordered = self::ORDER_LANG) {
          $locales = [];
          $this->getServerLocales();
  
          foreach($this->getClientLocales() as $locale) {
              /** @var Locale $locale  */
  
              $loc = $this->serverLocales->getBestMatchingLocaleForLocale($locale);
              if($loc && !in_array($loc, $locales)) {
                  $locales[]  = $loc;
              }
          }
          if(count($locales) == 0) {
              if($this->defaultLocale)
                  $locales[] = $this->defaultLocale;
              else {
                  $locales[] = $this->getServerLocales()[0] ?? NULL;
              }
          }
  
          if($ordered & self::ORDER_STRUCT) {
              $locs = [];
              foreach($locales as $loc) {
                  /** @var Locale $loc */
                  $lang = $loc->getLanguage();
  
                  $locs[$lang][] = $loc;
              }
  
              if($ordered & self::ORDER_LANG) {
                  foreach($locs as &$ll)
                      usort($ll, LocaleCollection::LANG_SORT_CALLBACK);
              } elseif($ordered & self::ORDER_REG) {
                  foreach($locs as &$ll)
                      usort($ll, LocaleCollection::REG_SORT_CALLBACK);
              }
  
              return $locs;
          }
  
          return $locales;
      }
code: public function getBestRenderLocales($ordered = self::ORDER_LANG) {
          $locales = [];
          $this->getServerLocales();
  
          foreach($this->getClientLocales() as $locale) {
              /** @var Locale $locale  */
  
              $loc = $this->serverLocales->getBestMatchingLocaleForLocale($locale);
              if($loc && !in_array($loc, $locales)) {
                  $locales[]  = $loc;
              }
          }
          if(count($locales) == 0) {
              if($this->defaultLocale)
                  $locales[] = $this->defaultLocale;
              else {
                  $locales[] = $this->getServerLocales()[0] ?? NULL;
              }
          }
  
          if($ordered & self::ORDER_STRUCT) {
              $locs = [];
              foreach($locales as $loc) {
                  /** @var Locale $loc */
                  $lang = $loc->getLanguage();
  
                  $locs[$lang][] = $loc;
              }
  
              if($ordered & self::ORDER_LANG) {
                  foreach($locs as &$ll)
                      usort($ll, LocaleCollection::LANG_SORT_CALLBACK);
              } elseif($ordered & self::ORDER_REG) {
                  foreach($locs as &$ll)
                      usort($ll, LocaleCollection::REG_SORT_CALLBACK);
              }
  
              return $locs;
          }
  
          return $locales;
      }
code_tokens: public function getBestRenderLocales ( $ ordered = self :: ORDER_LANG ) { $ locales = [ ] ; $ this -> getServerLocales ( ) ; foreach ( $ this -> getClientLocales ( ) as $ locale ) { /** @var Locale $locale  */ $ loc = $ this -> serverLocales -> getBestMatchingLocaleForLocale ( $ locale ) ; if ( $ loc && ! in_array ( $ loc , $ locales ) ) { $ locales [ ] = $ loc ; } } if ( count ( $ locales ) == 0 ) { if ( $ this -> defaultLocale ) $ locales [ ] = $ this -> defaultLocale ; else { $ locales [ ] = $ this -> getServerLocales ( ) [ 0 ] ?? NULL ; } } if ( $ ordered & self :: ORDER_STRUCT ) { $ locs = [ ] ; foreach ( $ locales as $ loc ) { /** @var Locale $loc */ $ lang = $ loc -> getLanguage ( ) ; $ locs [ $ lang ] [ ] = $ loc ; } if ( $ ordered & self :: ORDER_LANG ) { foreach ( $ locs as & $ ll ) usort ( $ ll , LocaleCollection :: LANG_SORT_CALLBACK ) ; } elseif ( $ ordered & self :: ORDER_REG ) { foreach ( $ locs as & $ ll ) usort ( $ ll , LocaleCollection :: REG_SORT_CALLBACK ) ; } return $ locs ; } return $ locales ; }
docstring: Tries to figure out which locales matching the desired language and the provided language.
  If no matches can be found, the default CMS language will be served.
  @param int $ordered
  @return array
docstring_tokens: Tries to figure out which locales matching the desired language and the provided language . If no matches can be found the default CMS language will be served .