summaryrefslogtreecommitdiff
path: root/demos/blog-tutorial/protected/common
diff options
context:
space:
mode:
authortof <>2007-08-27 07:16:27 +0000
committertof <>2007-08-27 07:16:27 +0000
commit7e884b51284e83b1604c9d029d3845e77e76d802 (patch)
tree050c205b14adef43b14d8970a13ea4ff4a8a3a1b /demos/blog-tutorial/protected/common
parent37508534ac227c4e39ba8e9eb417d559a7bf0f3e (diff)
Add Internationalization to Blog-Tutorial
Diffstat (limited to 'demos/blog-tutorial/protected/common')
-rwxr-xr-xdemos/blog-tutorial/protected/common/BlogTutorialGlobalization.php31
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