From 4835704a04cf5aa5ec71a8aef902d54b9c6cae82 Mon Sep 17 00:00:00 2001 From: wei <> Date: Fri, 6 Jan 2006 04:42:44 +0000 Subject: Adding I18N support. --- framework/Web/UI/TTemplateManager.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'framework/Web') 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; + } + } } /** -- cgit v1.2.3