<?php

declare(strict_types=1);

namespace DigiComp\FlowTranslationEndpoint\ViewHelpers;

use Neos\Flow\I18n\Service as I18nService;
use Neos\FluidAdaptor\Core\ViewHelper\AbstractViewHelper;

class CurrentHtmlLangViewHelper extends AbstractViewHelper
{
    /**
     * @var I18nService
     */
    protected I18nService $i18nService;

    /**
     * @param I18nService $i18nService
     */
    public function __construct(I18nService $i18nService)
    {
        $this->i18nService = $i18nService;
    }

    /**
     * @return string
     */
    public function render(): string
    {
        return \str_replace('_', '-', (string)$this->i18nService->getConfiguration()->getCurrentLocale());
    }
}