src/Beluga/Translation/Locale.php
public static function TryParseArray(
      &$refLocale, array $requestData, array $acceptedKeys = [ 'locale', 'language', 'lang', 'loc', 'lc', 'lng' ] )
      : bool
   {

      if ( \count( $requestData ) < 1 )
      {
         return false;
      }

      $requestData  = \array_change_key_case( $requestData , \CASE_LOWER );
      $acceptedKeys = \array_change_key_case( $acceptedKeys, \CASE_LOWER );
      $language     = null;

      foreach ( $acceptedKeys as $key )
      {
         if ( ! isset( $requestData[ $key  ] ) )
         {
            continue;
         }
         $language = \trim( $requestData[ 'language' ] );
         break;
      }

      if ( empty( $language ) ) { return false; }

      if ( ! \preg_match( '~^([a-zA-Z]{2})([_-]([a-zA-Z]{2}))?~', $language, $matches ) )
      {
         return false;
      }

      // Getting the LID + CID
      $lid = \strtolower( $matches[ 1 ] );
      $cid = empty( $matches[ 2 ] )
         ? null
         : \strtoupper( $matches[ 3 ] );

      // Everything is OK. Init the new instance and return TRUE
      $refLocale = new Locale( $lid, $cid );

      return true;

   }
public static function TryParseArray(
      &$refLocale, array $requestData, array $acceptedKeys = [ 'locale', 'language', 'lang', 'loc', 'lc', 'lng' ] )
      : bool
   {

      if ( \count( $requestData ) < 1 )
      {
         return false;
      }

      $requestData  = \array_change_key_case( $requestData , \CASE_LOWER );
      $acceptedKeys = \array_change_key_case( $acceptedKeys, \CASE_LOWER );
      $language     = null;

      foreach ( $acceptedKeys as $key )
      {
         if ( ! isset( $requestData[ $key  ] ) )
         {
            continue;
         }
         $language = \trim( $requestData[ 'language' ] );
         break;
      }

      if ( empty( $language ) ) { return false; }

      if ( ! \preg_match( '~^([a-zA-Z]{2})([_-]([a-zA-Z]{2}))?~', $language, $matches ) )
      {
         return false;
      }

      // Getting the LID + CID
      $lid = \strtolower( $matches[ 1 ] );
      $cid = empty( $matches[ 2 ] )
         ? null
         : \strtoupper( $matches[ 3 ] );

      // Everything is OK. Init the new instance and return TRUE
      $refLocale = new Locale( $lid, $cid );

      return true;

   }
public static function TryParseArray ( & $ refLocale , array $ requestData , array $ acceptedKeys = [ 'locale' , 'language' , 'lang' , 'loc' , 'lc' , 'lng' ] ) : bool { if ( \ count ( $ requestData ) < 1 ) { return false ; } $ requestData = \ array_change_key_case ( $ requestData , \ CASE_LOWER ) ; $ acceptedKeys = \ array_change_key_case ( $ acceptedKeys , \ CASE_LOWER ) ; $ language = null ; foreach ( $ acceptedKeys as $ key ) { if ( ! isset ( $ requestData [ $ key ] ) ) { continue ; } $ language = \ trim ( $ requestData [ 'language' ] ) ; break ; } if ( empty ( $ language ) ) { return false ; } if ( ! \ preg_match ( '~^([a-zA-Z]{2})([_-]([a-zA-Z]{2}))?~' , $ language , $ matches ) ) { return false ; } // Getting the LID + CID $ lid = \ strtolower ( $ matches [ 1 ] ) ; $ cid = empty ( $ matches [ 2 ] ) ? null : \ strtoupper ( $ matches [ 3 ] ) ; // Everything is OK. Init the new instance and return TRUE $ refLocale = new Locale ( $ lid , $ cid ) ; return true ; }
Tries to create a new Locale instance from defined array. It accepts one of the following array keys
to declare an

@param  \Beluga\Translation\Locale $refLocale Returns the Locale instance if the method return TRUE.
@param  array $requestData The array with the data that should be used for getting local info from.
@return bool
Tries to create a new Locale instance from defined array . It accepts one of the following array keys to declare an