public function getTranslation( $identifier, $defaultTranslation = null ) : string
   {

      if ( $this->_useNumericId )
      {

         // Not integer identifier. End here with an exception
         if ( ! \is_int( $identifier ) )
         {
            throw new \InvalidArgumentException( 'Current ' . __CLASS__ . ' instance requires numeric identifier!' );
         }

         // The identifier not exists, return the default translation
         if ( ! isset( $this->_translations[ $identifier ] ) )
         {
            return $defaultTranslation;
         }

         // Return string translation as it
         if ( \is_string( $this->_translations[ $identifier ] ) )
         {
            return $this->_translations[ $identifier ];
         }

         // Handle translation array values
         if ( \is_array( $this->_translations[ $identifier ] ) )
         {

            if ( isset( $this->_translations[ $identifier ][ 'text' ] ) )
            {
               return $this->_translations[ $identifier ][ 'text' ];
            }

            if ( isset( $this->_translations[ $identifier ][ 'value' ] ) )
            {
               return $this->_translations[ $identifier ][ 'value' ];
            }

            if ( isset( $this->_translations[ $identifier ][ 'translation' ] ) )
            {
               return $this->_translations[ $identifier ][ 'translation' ];
            }

         }

         // No translation found
         return $defaultTranslation;

      }

      // Not integer identifier. End here with an exception
      if ( ! \is_string( $identifier ) )
      {
         throw new \InvalidArgumentException( 'Current ' . __CLASS__ . ' instance requires string identifier!' );
      }

      // The identifier not exists, return the default translation
      if ( ! isset( $this->_translations[ $identifier ] ) )
      {
         return empty( $defaultTranslation ) ? $identifier : $defaultTranslation;
      }

      // Return string translation as it
      if ( \is_string( $this->_translations[ $identifier ] ) )
      {
         return $this->_translations[ $identifier ];
      }

      // Handle translation array values
      if ( \is_array( $this->_translations[ $identifier ] ) )
      {

         if ( isset( $this->_translations[ $identifier ][ 'text' ] ) )
         {
            return $this->_translations[ $identifier ][ 'text' ];
         }

         if ( isset( $this->_translations[ $identifier ][ 'value' ] ) )
         {
            return $this->_translations[ $identifier ][ 'value' ];
         }

         if ( isset( $this->_translations[ $identifier ][ 'translation' ] ) )
         {
            return $this->_translations[ $identifier ][ 'translation' ];
         }

      }

      return empty( $defaultTranslation ) ? $identifier : $defaultTranslation;

   }
public function getTranslation( $identifier, $defaultTranslation = null ) : string
   {

      if ( $this->_useNumericId )
      {

         // Not integer identifier. End here with an exception
         if ( ! \is_int( $identifier ) )
         {
            throw new \InvalidArgumentException( 'Current ' . __CLASS__ . ' instance requires numeric identifier!' );
         }

         // The identifier not exists, return the default translation
         if ( ! isset( $this->_translations[ $identifier ] ) )
         {
            return $defaultTranslation;
         }

         // Return string translation as it
         if ( \is_string( $this->_translations[ $identifier ] ) )
         {
            return $this->_translations[ $identifier ];
         }

         // Handle translation array values
         if ( \is_array( $this->_translations[ $identifier ] ) )
         {

            if ( isset( $this->_translations[ $identifier ][ 'text' ] ) )
            {
               return $this->_translations[ $identifier ][ 'text' ];
            }

            if ( isset( $this->_translations[ $identifier ][ 'value' ] ) )
            {
               return $this->_translations[ $identifier ][ 'value' ];
            }

            if ( isset( $this->_translations[ $identifier ][ 'translation' ] ) )
            {
               return $this->_translations[ $identifier ][ 'translation' ];
            }

         }

         // No translation found
         return $defaultTranslation;

      }

      // Not integer identifier. End here with an exception
      if ( ! \is_string( $identifier ) )
      {
         throw new \InvalidArgumentException( 'Current ' . __CLASS__ . ' instance requires string identifier!' );
      }

      // The identifier not exists, return the default translation
      if ( ! isset( $this->_translations[ $identifier ] ) )
      {
         return empty( $defaultTranslation ) ? $identifier : $defaultTranslation;
      }

      // Return string translation as it
      if ( \is_string( $this->_translations[ $identifier ] ) )
      {
         return $this->_translations[ $identifier ];
      }

      // Handle translation array values
      if ( \is_array( $this->_translations[ $identifier ] ) )
      {

         if ( isset( $this->_translations[ $identifier ][ 'text' ] ) )
         {
            return $this->_translations[ $identifier ][ 'text' ];
         }

         if ( isset( $this->_translations[ $identifier ][ 'value' ] ) )
         {
            return $this->_translations[ $identifier ][ 'value' ];
         }

         if ( isset( $this->_translations[ $identifier ][ 'translation' ] ) )
         {
            return $this->_translations[ $identifier ][ 'translation' ];
         }

      }

      return empty( $defaultTranslation ) ? $identifier : $defaultTranslation;

   }
public function getTranslation ( $ identifier , $ defaultTranslation = null ) : string { if ( $ this -> _useNumericId ) { // Not integer identifier. End here with an exception if ( ! \ is_int ( $ identifier ) ) { throw new \ InvalidArgumentException ( 'Current ' . __CLASS__ . ' instance requires numeric identifier!' ) ; } // The identifier not exists, return the default translation if ( ! isset ( $ this -> _translations [ $ identifier ] ) ) { return $ defaultTranslation ; } // Return string translation as it if ( \ is_string ( $ this -> _translations [ $ identifier ] ) ) { return $ this -> _translations [ $ identifier ] ; } // Handle translation array values if ( \ is_array ( $ this -> _translations [ $ identifier ] ) ) { if ( isset ( $ this -> _translations [ $ identifier ] [ 'text' ] ) ) { return $ this -> _translations [ $ identifier ] [ 'text' ] ; } if ( isset ( $ this -> _translations [ $ identifier ] [ 'value' ] ) ) { return $ this -> _translations [ $ identifier ] [ 'value' ] ; } if ( isset ( $ this -> _translations [ $ identifier ] [ 'translation' ] ) ) { return $ this -> _translations [ $ identifier ] [ 'translation' ] ; } } // No translation found return $ defaultTranslation ; } // Not integer identifier. End here with an exception if ( ! \ is_string ( $ identifier ) ) { throw new \ InvalidArgumentException ( 'Current ' . __CLASS__ . ' instance requires string identifier!' ) ; } // The identifier not exists, return the default translation if ( ! isset ( $ this -> _translations [ $ identifier ] ) ) { return empty ( $ defaultTranslation ) ? $ identifier : $ defaultTranslation ; } // Return string translation as it if ( \ is_string ( $ this -> _translations [ $ identifier ] ) ) { return $ this -> _translations [ $ identifier ] ; } // Handle translation array values if ( \ is_array ( $ this -> _translations [ $ identifier ] ) ) { if ( isset ( $ this -> _translations [ $ identifier ] [ 'text' ] ) ) { return $ this -> _translations [ $ identifier ] [ 'text' ] ; } if ( isset ( $ this -> _translations [ $ identifier ] [ 'value' ] ) ) { return $ this -> _translations [ $ identifier ] [ 'value' ] ; } if ( isset ( $ this -> _translations [ $ identifier ] [ 'translation' ] ) ) { return $ this -> _translations [ $ identifier ] [ 'translation' ] ; } } return empty ( $ defaultTranslation ) ? $ identifier : $ defaultTranslation ; }
Gets the translation with the defined identifier

@param  string|int  $identifier
@param  string|null $defaultTranslation Is returned if the translation was not found
@return string
@throws \InvalidArgumentException If the $identifier is invalid
Gets the translation with the defined identifier