Bolt\Controller\Backend\General::translation PHP Метод

translation() публичный Метод

Prepare/edit/save a translation.
public translation ( Request $request, string $domain, string $tr_locale ) : TemplateResponse | RedirectResponse
$request Symfony\Component\HttpFoundation\Request The Symfony Request
$domain string The domain
$tr_locale string The translation locale
Результат Bolt\Response\TemplateResponse | Symfony\Component\HttpFoundation\RedirectResponse
    public function translation(Request $request, $domain, $tr_locale)
    {
        $tr = ['domain' => $domain, 'locale' => $tr_locale];
        // Get the translation data
        $data = $this->getTranslationData($tr);
        // Create the form
        $form = $this->createFormBuilder(FormType::class, $data)->add('contents', TextareaType::class, ['constraints' => [new Assert\NotBlank(), new Assert\Length(['min' => 10])]])->getForm();
        $form->handleRequest($request);
        if ($form->isValid()) {
            $data = $form->getData();
            if ($response = $this->saveTranslationFile($data['contents'], $tr)) {
                return $response;
            }
        }
        $context = ['form' => $form->createView(), 'basename' => basename($tr['shortPath']), 'filetype' => 'yml', 'write_allowed' => $tr['writeallowed']];
        return $this->render('@bolt/editlocale/editlocale.twig', $context);
    }