finish to implement translation
This commit is contained in:
@@ -47,6 +47,7 @@ use Thelia\Config\DatabaseConfiguration;
|
||||
use Thelia\Config\DefinePropel;
|
||||
use Thelia\Core\TheliaContainerBuilder;
|
||||
use Thelia\Core\DependencyInjection\Loader\XmlFileLoader;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
|
||||
use Propel\Runtime\Propel;
|
||||
@@ -122,7 +123,8 @@ class Thelia extends Kernel
|
||||
|
||||
if (defined("THELIA_INSTALL_MODE") === false) {
|
||||
$modules = \Thelia\Model\ModuleQuery::getActivated();
|
||||
|
||||
$translator = $container->getDefinition('thelia.translator');
|
||||
$dirs = array();
|
||||
foreach ($modules as $module) {
|
||||
|
||||
try {
|
||||
@@ -138,10 +140,38 @@ class Thelia extends Kernel
|
||||
|
||||
$loader = new XmlFileLoader($container, new FileLocator(THELIA_MODULE_DIR . "/" . ucfirst($module->getCode()) . "/Config"));
|
||||
$loader->load("config.xml");
|
||||
|
||||
if (is_dir($dir = THELIA_MODULE_DIR . "/" . ucfirst($module->getCode()) . "/I18n")) {
|
||||
$dirs[] = $dir;
|
||||
}
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
// FIXME: process module configuration exception
|
||||
}
|
||||
}
|
||||
|
||||
//Load translation from templates
|
||||
//admin template
|
||||
if(is_dir($dir = THELIA_TEMPLATE_DIR . '/admin/default/I18n')) {
|
||||
$dirs[] = $dir;
|
||||
}
|
||||
|
||||
//front template
|
||||
$template = ConfigQuery::getActiveTemplate();
|
||||
if(is_dir($dir = THELIA_TEMPLATE_DIR . $template . "/I18n")) {
|
||||
$dirs[] = $dir;
|
||||
}
|
||||
|
||||
if ($dirs) {
|
||||
$finder = Finder::create()
|
||||
->files()
|
||||
->depth(0)
|
||||
->in($dirs);
|
||||
|
||||
foreach ($finder as $file) {
|
||||
list($locale, $format) = explode('.', $file->getBaseName(), 2);
|
||||
$translator->addMethodCall('addResource', array($format, (string) $file, $locale));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user