/** * Show the current registered bundles with language files * * @return type */ public function listBundlesAction() { $bundles = $this->container->getParameter('kernel.bundles'); $kernel = $this->container->get('kernel'); $translator = $this->get('translator'); $csp_l10n_sys_locales = LocaleDefinitions::$csp_l10n_sys_locales; $csp_l10n_langs = LocaleDefinitions::$csp_l10n_langs; $localeFiles = new LocaleFiles($kernel); foreach ($bundles as $bundle => $bundleFullName) { $path = $kernel->locateResource('@' . $bundle); $messageFiles = $localeFiles->getLanguages($path); for ($i = 0; $i < count($messageFiles); $i++) { if (!isset($csp_l10n_sys_locales[$messageFiles[$i]['locale']]) && !isset($csp_l10n_langs[$messageFiles[$i]['locale']])) { $messageFiles[$i]['unknown'] = true; } if (strlen($messageFiles[$i]['locale']) > 2) { if (isset($csp_l10n_sys_locales[$messageFiles[$i]['locale']])) { $messageFiles[$i]['additional'] = $csp_l10n_sys_locales[$messageFiles[$i]['locale']]; } } } $bundleList[] = array('name' => $bundle, 'fullName' => $bundleFullName, 'path' => $path, 'messageFiles' => $messageFiles); } asort($bundleList); $form = $this->createForm(new LanguageChoiceType($this->container, $translator, false)); return $this->render('GeschkeAdminTranslatorGUIBundle:Bundles:list.html.twig', array('mainnav' => 'bundles', 'bundles' => $bundleList, 'form_copy' => $form->createView())); }
/** * Get real filename with all directory components of a message xliff file. * * @param type $bundle * @param type $locale * @param type $domain * @return string * @throws FileNotFoundException */ public function getFilename($bundle, $locale, $domain) { $path = $this->kernel->locateResource('@' . $bundle); $localeFiles = new LocaleFiles($this->kernel); $files = $localeFiles->getLanguages($path); $localeFile = null; foreach ($files as $localeData) { if ($localeData['locale'] == $locale && $localeData['domain'] == $domain) { $localeFile = $localeData; break; } } if (!$localeFile) { throw new FileNotFoundException(); } $filename = $path . 'Resources/translations/' . $localeFile['file']; return $filename; }