public function validateArrayKey($file, $key, $against_language, $validate_language)
	{
		if (gettype($against_language) !== gettype($validate_language))
		{
			$this->output->addMessage(Output::FATAL, sprintf('Should be type %1$s but is type %2$s', gettype($against_language), gettype($validate_language)), $file, $key);
			return;
		}

		$cat_validate_keys = array_keys($validate_language);
		$cat_against_keys = array_keys($against_language);
		$invalid_keys = array_diff($cat_validate_keys, $cat_against_keys);

		foreach ($against_language as $array_key => $lang)
		{
			// Only error for string keys, plurals might force different keys
			if (!isset($validate_language[$array_key]))
			{
				if (gettype($array_key) == 'string')
				{
					$this->output->addMessage(Output::FATAL, 'Array is missing key: ' . $array_key, $file, $key);
				}
				continue;
			}

			if (is_string($lang))
			{
				$this->validateString($file, $key . '.' . $array_key, $lang, $validate_language[$array_key]);
			}
			else
			{
				$this->validateArray($file, $key . '.' . $array_key, $lang, $validate_language[$array_key]);
			}
		}

		if (!empty($invalid_keys))
		{
			foreach ($invalid_keys as $array_key)
			{
				if (gettype($array_key) == 'string')
				{
					$this->output->addMessage(Output::FATAL, 'Array has invalid key: ' . $array_key, $file, $key);
				}
				else
				{
					// Strangly used plural?
					$this->output->addMessage(Output::FATAL, 'Array has invalid key: ' . $array_key, $file, $key);
				}
				$this->output->addMessage(Output::ERROR, 'Key was not validated: ' . $array_key, $file, $key . '.' . $array_key);
			}
		}
	}
public function validateArrayKey($file, $key, $against_language, $validate_language)
	{
		if (gettype($against_language) !== gettype($validate_language))
		{
			$this->output->addMessage(Output::FATAL, sprintf('Should be type %1$s but is type %2$s', gettype($against_language), gettype($validate_language)), $file, $key);
			return;
		}

		$cat_validate_keys = array_keys($validate_language);
		$cat_against_keys = array_keys($against_language);
		$invalid_keys = array_diff($cat_validate_keys, $cat_against_keys);

		foreach ($against_language as $array_key => $lang)
		{
			// Only error for string keys, plurals might force different keys
			if (!isset($validate_language[$array_key]))
			{
				if (gettype($array_key) == 'string')
				{
					$this->output->addMessage(Output::FATAL, 'Array is missing key: ' . $array_key, $file, $key);
				}
				continue;
			}

			if (is_string($lang))
			{
				$this->validateString($file, $key . '.' . $array_key, $lang, $validate_language[$array_key]);
			}
			else
			{
				$this->validateArray($file, $key . '.' . $array_key, $lang, $validate_language[$array_key]);
			}
		}

		if (!empty($invalid_keys))
		{
			foreach ($invalid_keys as $array_key)
			{
				if (gettype($array_key) == 'string')
				{
					$this->output->addMessage(Output::FATAL, 'Array has invalid key: ' . $array_key, $file, $key);
				}
				else
				{
					// Strangly used plural?
					$this->output->addMessage(Output::FATAL, 'Array has invalid key: ' . $array_key, $file, $key);
				}
				$this->output->addMessage(Output::ERROR, 'Key was not validated: ' . $array_key, $file, $key . '.' . $array_key);
			}
		}
	}
public function validateArrayKey ( $ file , $ key , $ against_language , $ validate_language ) { if ( gettype ( $ against_language ) !== gettype ( $ validate_language ) ) { $ this -> output -> addMessage ( Output :: FATAL , sprintf ( 'Should be type %1$s but is type %2$s' , gettype ( $ against_language ) , gettype ( $ validate_language ) ) , $ file , $ key ) ; return ; } $ cat_validate_keys = array_keys ( $ validate_language ) ; $ cat_against_keys = array_keys ( $ against_language ) ; $ invalid_keys = array_diff ( $ cat_validate_keys , $ cat_against_keys ) ; foreach ( $ against_language as $ array_key => $ lang ) { // Only error for string keys, plurals might force different keys if ( ! isset ( $ validate_language [ $ array_key ] ) ) { if ( gettype ( $ array_key ) == 'string' ) { $ this -> output -> addMessage ( Output :: FATAL , 'Array is missing key: ' . $ array_key , $ file , $ key ) ; } continue ; } if ( is_string ( $ lang ) ) { $ this -> validateString ( $ file , $ key . '.' . $ array_key , $ lang , $ validate_language [ $ array_key ] ) ; } else { $ this -> validateArray ( $ file , $ key . '.' . $ array_key , $ lang , $ validate_language [ $ array_key ] ) ; } } if ( ! empty ( $ invalid_keys ) ) { foreach ( $ invalid_keys as $ array_key ) { if ( gettype ( $ array_key ) == 'string' ) { $ this -> output -> addMessage ( Output :: FATAL , 'Array has invalid key: ' . $ array_key , $ file , $ key ) ; } else { // Strangly used plural? $ this -> output -> addMessage ( Output :: FATAL , 'Array has invalid key: ' . $ array_key , $ file , $ key ) ; } $ this -> output -> addMessage ( Output :: ERROR , 'Key was not validated: ' . $ array_key , $ file , $ key . '.' . $ array_key ) ; } } }
Validates an array entry

Arrays that have strings as key, must have the same keys in the foreign language
Arrays that have integers as keys, might have different ones (plurals)
Additional keys can not be further validated

Function works recursive

@param	string	$file		File to validate
@param	string	$key		Key to validate
@param	array	$against_language		Original language
@param	array	$validate_language		Translated language
@return	null
Validates an array entry