private static function toArray(Translations $translations, $includeHeaders, $forceArray = false)
    {
        $pluralForm = $translations->getPluralForms();
        $pluralSize = is_array($pluralForm) ? ($pluralForm[0] - 1) : null;
        $messages = [];

        if ($includeHeaders) {
            $messages[''] = [
                '' => [self::generateHeaders($translations)],
            ];
        }

        foreach ($translations as $translation) {
            if ($translation->isDisabled()) {
                continue;
            }

            $context = $translation->getContext();
            $original = $translation->getOriginal();

            if (!isset($messages[$context])) {
                $messages[$context] = [];
            }

            if ($translation->hasPluralTranslations(true)) {
                $messages[$context][$original] = $translation->getPluralTranslations($pluralSize);
                array_unshift($messages[$context][$original], $translation->getTranslation());
            } elseif ($forceArray) {
                $messages[$context][$original] = [$translation->getTranslation()];
            } else {
                $messages[$context][$original] = $translation->getTranslation();
            }
        }

        return [
            'domain' => $translations->getDomain(),
            'plural-forms' => $translations->getHeader('Plural-Forms'),
            'messages' => $messages,
        ];
    }
private static function toArray(Translations $translations, $includeHeaders, $forceArray = false)
    {
        $pluralForm = $translations->getPluralForms();
        $pluralSize = is_array($pluralForm) ? ($pluralForm[0] - 1) : null;
        $messages = [];

        if ($includeHeaders) {
            $messages[''] = [
                '' => [self::generateHeaders($translations)],
            ];
        }

        foreach ($translations as $translation) {
            if ($translation->isDisabled()) {
                continue;
            }

            $context = $translation->getContext();
            $original = $translation->getOriginal();

            if (!isset($messages[$context])) {
                $messages[$context] = [];
            }

            if ($translation->hasPluralTranslations(true)) {
                $messages[$context][$original] = $translation->getPluralTranslations($pluralSize);
                array_unshift($messages[$context][$original], $translation->getTranslation());
            } elseif ($forceArray) {
                $messages[$context][$original] = [$translation->getTranslation()];
            } else {
                $messages[$context][$original] = $translation->getTranslation();
            }
        }

        return [
            'domain' => $translations->getDomain(),
            'plural-forms' => $translations->getHeader('Plural-Forms'),
            'messages' => $messages,
        ];
    }
private static function toArray ( Translations $ translations , $ includeHeaders , $ forceArray = false ) { $ pluralForm = $ translations -> getPluralForms ( ) ; $ pluralSize = is_array ( $ pluralForm ) ? ( $ pluralForm [ 0 ] - 1 ) : null ; $ messages = [ ] ; if ( $ includeHeaders ) { $ messages [ '' ] = [ '' => [ self :: generateHeaders ( $ translations ) ] , ] ; } foreach ( $ translations as $ translation ) { if ( $ translation -> isDisabled ( ) ) { continue ; } $ context = $ translation -> getContext ( ) ; $ original = $ translation -> getOriginal ( ) ; if ( ! isset ( $ messages [ $ context ] ) ) { $ messages [ $ context ] = [ ] ; } if ( $ translation -> hasPluralTranslations ( true ) ) { $ messages [ $ context ] [ $ original ] = $ translation -> getPluralTranslations ( $ pluralSize ) ; array_unshift ( $ messages [ $ context ] [ $ original ] , $ translation -> getTranslation ( ) ) ; } elseif ( $ forceArray ) { $ messages [ $ context ] [ $ original ] = [ $ translation -> getTranslation ( ) ] ; } else { $ messages [ $ context ] [ $ original ] = $ translation -> getTranslation ( ) ; } } return [ 'domain' => $ translations -> getDomain ( ) , 'plural-forms' => $ translations -> getHeader ( 'Plural-Forms' ) , 'messages' => $ messages , ] ; }
Returns a multidimensional array.

@param Translations $translations
@param bool         $includeHeaders
@param bool         $forceArray

@return array
Returns a multidimensional array .