src/Controller/TranslationYamlController.php line 49
<?phpnamespace App\Controller;use App\Repository\SettingsRepository;use App\Service\IlaveUSettingsProvider;use Exception;use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;use Symfony\Component\HttpFoundation\Response;use Symfony\Component\HttpFoundation\Request;use Symfony\Component\Routing\Annotation\Route;use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;use Symfony\Component\Yaml\Yaml;#[Route(path: '/{_locale}')]class TranslationYamlController extends AbstractController{#[Route(path: '/api-trans/translations-yaml', name: 'api_translations_yaml')]public function api_translations_yaml(Request $request,IlaveUSettingsProvider $ilaveSettingsProvider){// Construct the path to the YAML translation file$nameSpaceTrans = strtolower($ilaveSettingsProvider->get()->getProjectName());$yamlFilePath = $this->getParameter('kernel.project_dir') . '/translations/'.$nameSpaceTrans. '/'.$nameSpaceTrans. '.' . $request->getLocale() . '.yaml';// Check if the YAML file existsif (!file_exists($yamlFilePath)) {return $this->json([]);}// Read and parse the YAML file$yamlContent = file_get_contents($yamlFilePath);$translations = Yaml::parse($yamlContent);// Return translations as JSON response// Return translations as JSON response using $this->json()return $this->json($translations);}#[Route(path: '/api-trans/translations-yaml-admin', name: 'api_translations_yaml_admin')]public function api_translations_yaml_admin(Request $request,IlaveUSettingsProvider $ilaveSettingsProvider){// Construct the path to the YAML translation file$nameSpaceTrans = strtolower($ilaveSettingsProvider->get()->getProjectName());$yamlFilePath = $this->getParameter('kernel.project_dir') . '/translations/'.$nameSpaceTrans. '/'.$nameSpaceTrans. '-admin.' . $request->getLocale() . '.yaml';// Check if the YAML file existsif (!file_exists($yamlFilePath)) {return $this->json([]);}// Read and parse the YAML file$yamlContent = file_get_contents($yamlFilePath);$translations = Yaml::parse($yamlContent);// Return translations as JSON response// Return translations as JSON response using $this->json()return $this->json($translations);}}