|
@@ -26,6 +26,7 @@ class ZendExtension extends Extension
|
|
|
{
|
|
|
protected $resources = array(
|
|
|
'logger' => 'logger.xml',
|
|
|
+ 'i18n' => 'i18n.xml',
|
|
|
);
|
|
|
|
|
|
/**
|
|
@@ -55,6 +56,42 @@ class ZendExtension extends Extension
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Loads the i18n configuration.
|
|
|
+ *
|
|
|
+ * Usage example:
|
|
|
+ *
|
|
|
+ * <zend:i18n locale="en" adapter="xliff" data="/path/to/messages.xml" />
|
|
|
+ *
|
|
|
+ * @param array $config An array of configuration settings
|
|
|
+ * @param \Symfony\Components\DependencyInjection\ContainerBuilder $container A ContainerBuilder instance
|
|
|
+ */
|
|
|
+ public function i18nLoad($config, ContainerBuilder $container)
|
|
|
+ {
|
|
|
+ if (!$container->hasDefinition('zend.i18n')) {
|
|
|
+ $loader = new XmlFileLoader($container, __DIR__.'/../Resources/config');
|
|
|
+ $loader->load($this->resources['i18n']);
|
|
|
+ $container->setAlias('i18n', 'zend.i18n');
|
|
|
+ }
|
|
|
+
|
|
|
+ if (isset($config['locale'])) {
|
|
|
+ $container->setParameter('zend.translator.locale', $config['locale']);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (isset($config['adapter'])) {
|
|
|
+ $container->setParameter('zend.translator.adapter', constant($config['adapter']));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (isset($config['translations']) && is_array($config['translations'])) {
|
|
|
+ foreach ($config['translations'] as $locale => $catalogue) {
|
|
|
+ if ($locale == $container->getParameter('zend.translator.locale')) {
|
|
|
+ $container->setParameter('zend.translator.catalogue', $catalogue);
|
|
|
+ }
|
|
|
+ $container->findDefinition('zend.translator')->addMethodCall('addTranslation', array($catalogue, $locale));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Returns the base path for the XSD files.
|
|
|
*
|