StaticTranslator example


    private function getTranslator(ErrorCollection $errors): array
    {
        $translations = [];
        foreach ($errors->getElements() as $error) {
            $translations['checkout.' . $error->getMessageKey()] = self::MESSAGE;
        }

        $translator = new StaticTranslator($translations);

        return [
            'translator',
            ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE,
            $translator,
        ];
    }

    /** * @return array{ * 0: ProfileSalutationMissingError, * 1: BillingAddressSalutationMissingError, * 2: ShippingAddressSalutationMissingError * } */
Home | Imprint | This part of the site doesn't use cookies.