diff options
author | tof <> | 2007-08-27 07:16:27 +0000 |
---|---|---|
committer | tof <> | 2007-08-27 07:16:27 +0000 |
commit | 7e884b51284e83b1604c9d029d3845e77e76d802 (patch) | |
tree | 050c205b14adef43b14d8970a13ea4ff4a8a3a1b /demos/blog-tutorial/protected/common | |
parent | 37508534ac227c4e39ba8e9eb417d559a7bf0f3e (diff) |
Add Internationalization to Blog-Tutorial
Diffstat (limited to 'demos/blog-tutorial/protected/common')
-rwxr-xr-x | demos/blog-tutorial/protected/common/BlogTutorialGlobalization.php | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/demos/blog-tutorial/protected/common/BlogTutorialGlobalization.php b/demos/blog-tutorial/protected/common/BlogTutorialGlobalization.php new file mode 100755 index 00000000..70435e34 --- /dev/null +++ b/demos/blog-tutorial/protected/common/BlogTutorialGlobalization.php @@ -0,0 +1,31 @@ +<?php + +class BlogTutorialGlobalization extends TGlobalizationAutoDetect +{ + public function init($xml) + { + parent::init($xml); + $this->Application->OnBeginRequest[] = array($this, 'beginRequest'); + } + + public function beginRequest($sender, $param) + { + if(null == ($culture=$this->Request['lang'])) + { + if(null !== ($cookie=$this->Request->Cookies['lang'])) + $culture = $cookie->getValue(); + } + + if(is_string($culture)) + { + $info = new CultureInfo(); + if($info->validCulture($culture)) + { + $this->setCulture($culture); + $this->Response->Cookies[] = new THttpCookie('lang',$culture); + } + } + } +} + +?>
\ No newline at end of file |