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
* @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))
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 =
TemplateHelper::getInstance()->getList(
$template_type,
@@ -96,14 +97,12 @@ class TranslationsController extends BaseAdminController
$domain = $module->getTranslationDomain();
$i18n_directory = $module->getAbsoluteI18nPath();
$walkMode = TemplateHelper::WALK_MODE_PHP;
}
else if ($module_part == 'admin-includes') {
} elseif ($module_part == 'admin-includes') {
$directory = $module->getAbsoluteAdminIncludesPath();
$domain = $module->getAdminIncludesTranslationDomain();
$i18n_directory = $module->getAbsoluteAdminIncludesI18nPath();
$walkMode = TemplateHelper::WALK_MODE_TEMPLATE;
}
else if (! empty($module_part)) {
} elseif (! empty($module_part)) {
// Front or back office template, form of $module_part is [bo|fo].subdir-name
list($type, $subdir) = explode('.', $module_part);
@@ -111,13 +110,11 @@ class TranslationsController extends BaseAdminController
$directory = $module->getAbsoluteBackOfficeTemplatePath($subdir);
$domain = $module->getBackOfficeTemplateTranslationDomain($subdir);
$i18n_directory = $module->getAbsoluteBackOfficeI18nTemplatePath($subdir);
}
else if ($type == 'fo') {
} elseif ($type == 'fo') {
$directory = $module->getAbsoluteFrontOfficeTemplatePath($subdir);
$domain = $module->getFrontOfficeTemplateTranslationDomain($subdir);
$i18n_directory = $module->getAbsoluteFrontOfficeI18nTemplatePath($subdir);
}
else {
} else {
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)) {
throw new ResourceNotFoundException(Translator::getInstance()->trans("Template file %file cannot be found.", array('%file' => $realTemplateName)));
}
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());
}

View File

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

View File

@@ -279,8 +279,7 @@ class Thelia extends Kernel
$translator->addMethodCall('addResource', array($format, (string) $file, $locale, $domain));
}
}
catch (\InvalidArgumentException $ex) {
} catch (\InvalidArgumentException $ex) {
// Ignore missing I18n directories
Tlog::getInstance()->addWarning("loadTranslation: missing $dir directory");
}

View File

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