This commit is contained in:
Manuel Raynaud
2014-04-22 12:41:22 +02:00
parent 05bb8ecb80
commit 0435478ae8
17 changed files with 1654 additions and 1654 deletions

View File

@@ -31,7 +31,8 @@ class TranslationsController extends BaseAdminController
* @return Module the module object * @return Module the module object
* @throws \InvalidArgumentException if module was not found * @throws \InvalidArgumentException if module was not found
*/ */
protected function getModule($item_name) { protected function getModule($item_name)
{
if (null !== $module = ModuleQuery::create()->findPk($item_name)) if (null !== $module = ModuleQuery::create()->findPk($item_name))
return $module; return $module;
@@ -40,8 +41,8 @@ class TranslationsController extends BaseAdminController
); );
} }
protected function getModuleTemplateNames(Module $module, $template_type)
protected function getModuleTemplateNames(Module $module, $template_type) { {
$templates = $templates =
TemplateHelper::getInstance()->getList( TemplateHelper::getInstance()->getList(
$template_type, $template_type,
@@ -96,14 +97,12 @@ class TranslationsController extends BaseAdminController
$domain = $module->getTranslationDomain(); $domain = $module->getTranslationDomain();
$i18n_directory = $module->getAbsoluteI18nPath(); $i18n_directory = $module->getAbsoluteI18nPath();
$walkMode = TemplateHelper::WALK_MODE_PHP; $walkMode = TemplateHelper::WALK_MODE_PHP;
} } elseif ($module_part == 'admin-includes') {
else if ($module_part == 'admin-includes') {
$directory = $module->getAbsoluteAdminIncludesPath(); $directory = $module->getAbsoluteAdminIncludesPath();
$domain = $module->getAdminIncludesTranslationDomain(); $domain = $module->getAdminIncludesTranslationDomain();
$i18n_directory = $module->getAbsoluteAdminIncludesI18nPath(); $i18n_directory = $module->getAbsoluteAdminIncludesI18nPath();
$walkMode = TemplateHelper::WALK_MODE_TEMPLATE; $walkMode = TemplateHelper::WALK_MODE_TEMPLATE;
} } elseif (! empty($module_part)) {
else if (! empty($module_part)) {
// Front or back office template, form of $module_part is [bo|fo].subdir-name // Front or back office template, form of $module_part is [bo|fo].subdir-name
list($type, $subdir) = explode('.', $module_part); list($type, $subdir) = explode('.', $module_part);
@@ -111,13 +110,11 @@ class TranslationsController extends BaseAdminController
$directory = $module->getAbsoluteBackOfficeTemplatePath($subdir); $directory = $module->getAbsoluteBackOfficeTemplatePath($subdir);
$domain = $module->getBackOfficeTemplateTranslationDomain($subdir); $domain = $module->getBackOfficeTemplateTranslationDomain($subdir);
$i18n_directory = $module->getAbsoluteBackOfficeI18nTemplatePath($subdir); $i18n_directory = $module->getAbsoluteBackOfficeI18nTemplatePath($subdir);
} } elseif ($type == 'fo') {
else if ($type == 'fo') {
$directory = $module->getAbsoluteFrontOfficeTemplatePath($subdir); $directory = $module->getAbsoluteFrontOfficeTemplatePath($subdir);
$domain = $module->getFrontOfficeTemplateTranslationDomain($subdir); $domain = $module->getFrontOfficeTemplateTranslationDomain($subdir);
$i18n_directory = $module->getAbsoluteFrontOfficeI18nTemplatePath($subdir); $i18n_directory = $module->getAbsoluteFrontOfficeI18nTemplatePath($subdir);
} } else {
else {
throw new \InvalidArgumentException("Undefined module template type: '$type'."); throw new \InvalidArgumentException("Undefined module template type: '$type'.");
} }

View File

@@ -242,6 +242,7 @@ class SmartyParser extends Smarty implements ParserInterface
if (false === $this->templateExists($realTemplateName) || false === $this->checkTemplate($realTemplateName)) { if (false === $this->templateExists($realTemplateName) || false === $this->checkTemplate($realTemplateName)) {
throw new ResourceNotFoundException(Translator::getInstance()->trans("Template file %file cannot be found.", array('%file' => $realTemplateName))); throw new ResourceNotFoundException(Translator::getInstance()->trans("Template file %file cannot be found.", array('%file' => $realTemplateName)));
} }
return $this->internalRenderer('file', $realTemplateName, $parameters); return $this->internalRenderer('file', $realTemplateName, $parameters);
} }

View File

@@ -77,7 +77,8 @@ class TemplateDefinition
} }
} }
public function getTranslationDomain() { public function getTranslationDomain()
{
return $this->translationDomainPrefix . strtolower($this->getName()); return $this->translationDomainPrefix . strtolower($this->getName());
} }

View File

@@ -126,8 +126,7 @@ class TemplateHelper
$list[] = new TemplateDefinition($file->getFilename(), $templateType); $list[] = new TemplateDefinition($file->getFilename(), $templateType);
} }
} } catch (\UnexpectedValueException $ex) {
catch (\UnexpectedValueException $ex) {
// Ignore the exception and continue // Ignore the exception and continue
} }
} }

View File

@@ -217,7 +217,7 @@ class Thelia extends Kernel
$module->getAbsoluteTemplateBasePath() $module->getAbsoluteTemplateBasePath()
); );
foreach($templates as $template) { foreach ($templates as $template) {
$translationDirs[$module->getBackOfficeTemplateTranslationDomain($template->getName())] = $translationDirs[$module->getBackOfficeTemplateTranslationDomain($template->getName())] =
$module->getAbsoluteBackOfficeI18nTemplatePath($template->getName()); $module->getAbsoluteBackOfficeI18nTemplatePath($template->getName());
} }
@@ -229,7 +229,7 @@ class Thelia extends Kernel
$module->getAbsoluteTemplateBasePath() $module->getAbsoluteTemplateBasePath()
); );
foreach($templates as $template) { foreach ($templates as $template) {
$translationDirs[$module->getFrontOfficeTemplateTranslationDomain($template->getName())] = $translationDirs[$module->getFrontOfficeTemplateTranslationDomain($template->getName())] =
$module->getAbsoluteFrontOfficeI18nTemplatePath($template->getName()); $module->getAbsoluteFrontOfficeI18nTemplatePath($template->getName());
} }
@@ -279,8 +279,7 @@ class Thelia extends Kernel
$translator->addMethodCall('addResource', array($format, (string) $file, $locale, $domain)); $translator->addMethodCall('addResource', array($format, (string) $file, $locale, $domain));
} }
} } catch (\InvalidArgumentException $ex) {
catch (\InvalidArgumentException $ex) {
// Ignore missing I18n directories // Ignore missing I18n directories
Tlog::getInstance()->addWarning("loadTranslation: missing $dir directory"); Tlog::getInstance()->addWarning("loadTranslation: missing $dir directory");
} }

View File

@@ -16,17 +16,18 @@ class Module extends BaseModule
const ADMIN_INCLUDES_DIRECTORY_NAME = "AdminIncludes"; const ADMIN_INCLUDES_DIRECTORY_NAME = "AdminIncludes";
public function postSave(ConnectionInterface $con = null) public function postSave(ConnectionInterface $con = null)
{ {
ModuleQuery::resetActivated(); ModuleQuery::resetActivated();
} }
public function getTranslationDomain() { public function getTranslationDomain()
{
return strtolower($this->getCode()); return strtolower($this->getCode());
} }
public function getAdminIncludesTranslationDomain() { public function getAdminIncludesTranslationDomain()
{
return $this->getTranslationDomain().'.ai'; return $this->getTranslationDomain().'.ai';
} }
@@ -48,7 +49,8 @@ class Module extends BaseModule
); );
} }
public function getBackOfficeTemplateTranslationDomain($templateName) { public function getBackOfficeTemplateTranslationDomain($templateName)
{
return $this->getTranslationDomain(). '.bo.' . $templateName; return $this->getTranslationDomain(). '.bo.' . $templateName;
} }
@@ -70,7 +72,8 @@ class Module extends BaseModule
); );
} }
public function getFrontOfficeTemplateTranslationDomain($templateName) { public function getFrontOfficeTemplateTranslationDomain($templateName)
{
return $this->getTranslationDomain(). '.fo.' . $templateName; return $this->getTranslationDomain(). '.fo.' . $templateName;
} }