diff options
Diffstat (limited to 'demos/quickstart/protected/QuickStartGlobalization.php')
-rw-r--r-- | demos/quickstart/protected/QuickStartGlobalization.php | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/demos/quickstart/protected/QuickStartGlobalization.php b/demos/quickstart/protected/QuickStartGlobalization.php new file mode 100644 index 00000000..6a0b0fb2 --- /dev/null +++ b/demos/quickstart/protected/QuickStartGlobalization.php @@ -0,0 +1,31 @@ +<?php
+
+class QuickStartGlobalization 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 |