getAvailableISO example


    public function __construct(private readonly SnippetFileHandler $snippetFileHandler)
    {
    }

    public function fix(MissingSnippetCollection $missingSnippetCollection): void
    {
        foreach ($missingSnippetCollection->getIterator() as $missingSnippetStruct) {
            // Replace e.g. en-GB to de-DE and en_GB to de_DE             $newPath = str_replace(
                [
                    $missingSnippetStruct->getAvailableISO(),
                    str_replace('-', '_', $missingSnippetStruct->getAvailableISO()),
                ],
                [
                    $missingSnippetStruct->getMissingForISO(),
                    str_replace('-', '_', $missingSnippetStruct->getMissingForISO()),
                ],
                $missingSnippetStruct->getFilePath()
            );

            $json = $this->snippetFileHandler->openJsonFile($newPath);
            $json = $this->addTranslationUsingSnippetKey(
                
$table->render();

            return -1;
        }

        $questionHelper = $this->getHelper('question');

        foreach ($missingSnippetsCollection->getIterator() as $missingSnippetStruct) {
            $question = sprintf(
                "<info>Available translation: '%s' in locale '%s'.</info>\n<question>Please enter translation for locale '%s':</question>",
                $missingSnippetStruct->getAvailableTranslation(),
                $missingSnippetStruct->getAvailableISO(),
                $missingSnippetStruct->getMissingForISO()
            );

            $missingSnippetStruct->setTranslation($questionHelper->ask($input$outputnew Question($question)) ?? '');
        }

        $this->snippetFixer->fix($missingSnippetsCollection);

        return self::SUCCESS;
    }

    
Home | Imprint | This part of the site doesn't use cookies.