diff options
Diffstat (limited to 'framework/Web')
-rw-r--r-- | framework/Web/UI/TTemplateManager.php | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/framework/Web/UI/TTemplateManager.php b/framework/Web/UI/TTemplateManager.php index cb44b81d..d5c5f0ba 100644 --- a/framework/Web/UI/TTemplateManager.php +++ b/framework/Web/UI/TTemplateManager.php @@ -70,7 +70,7 @@ class TTemplateManager extends TModule */
public function getTemplateByFileName($fileName)
{
- if(($fileName=realpath($fileName))!==false && is_file($fileName))
+ if(!is_null($fileName=$this->getLocalizedTemplate($fileName)))
{
if(($cache=$this->getApplication()->getCache())===null)
return new TTemplate(file_get_contents($fileName),dirname($fileName),$fileName);
@@ -91,6 +91,22 @@ class TTemplateManager extends TModule else
return null;
}
+
+ /**
+ * Finds a localized template file.
+ * @param string template file.
+ * @return string|null a localized template file if found, null otherwise.
+ */
+ protected function getLocalizedTemplate($filename)
+ {
+ $app = $this->getApplication()->getGlobalization();
+ if(is_null($app)) return $filename;
+ foreach($app->getLocalizedResource($filename) as $file)
+ {
+ if(($file=realpath($file))!==false && is_file($file))
+ return $file;
+ }
+ }
}
/**
|