original_string: public static function canonicalize($locale)
      {
          $locale = (string) $locale;
  
          if ('' === $locale || '.' === $locale[0]) {
              return self::getDefault();
          }
  
          if (!preg_match('/^([a-z]{2})[-_]([a-z]{2})(?:([a-z]{2})(?:[-_]([a-z]{2}))?)?(?:\..*)?$/i', $locale, $m)) {
              return $locale;
          }
  
          if (!empty($m[4])) {
              return strtolower($m[1]).'_'.ucfirst(strtolower($m[2].$m[3])).'_'.strtoupper($m[4]);
          }
  
          if (!empty($m[3])) {
              return strtolower($m[1]).'_'.ucfirst(strtolower($m[2].$m[3]));
          }
  
          return strtolower($m[1]).'_'.strtoupper($m[2]);
      }
code: public static function canonicalize($locale)
      {
          $locale = (string) $locale;
  
          if ('' === $locale || '.' === $locale[0]) {
              return self::getDefault();
          }
  
          if (!preg_match('/^([a-z]{2})[-_]([a-z]{2})(?:([a-z]{2})(?:[-_]([a-z]{2}))?)?(?:\..*)?$/i', $locale, $m)) {
              return $locale;
          }
  
          if (!empty($m[4])) {
              return strtolower($m[1]).'_'.ucfirst(strtolower($m[2].$m[3])).'_'.strtoupper($m[4]);
          }
  
          if (!empty($m[3])) {
              return strtolower($m[1]).'_'.ucfirst(strtolower($m[2].$m[3]));
          }
  
          return strtolower($m[1]).'_'.strtoupper($m[2]);
      }
code_tokens: public static function canonicalize ( $ locale ) { $ locale = ( string ) $ locale ; if ( '' === $ locale || '.' === $ locale [ 0 ] ) { return self :: getDefault ( ) ; } if ( ! preg_match ( '/^([a-z]{2})[-_]([a-z]{2})(?:([a-z]{2})(?:[-_]([a-z]{2}))?)?(?:\..*)?$/i' , $ locale , $ m ) ) { return $ locale ; } if ( ! empty ( $ m [ 4 ] ) ) { return strtolower ( $ m [ 1 ] ) . '_' . ucfirst ( strtolower ( $ m [ 2 ] . $ m [ 3 ] ) ) . '_' . strtoupper ( $ m [ 4 ] ) ; } if ( ! empty ( $ m [ 3 ] ) ) { return strtolower ( $ m [ 1 ] ) . '_' . ucfirst ( strtolower ( $ m [ 2 ] . $ m [ 3 ] ) ) ; } return strtolower ( $ m [ 1 ] ) . '_' . strtoupper ( $ m [ 2 ] ) ; }
docstring: Returns a canonicalized locale string.
  
  This polyfill doesn't implement the full-spec algorithm. It only
  canonicalizes locale strings handled by the `LocaleBundle` class.
  
  @param string $locale
  
  @return string
docstring_tokens: Returns a canonicalized locale string .