summaryrefslogtreecommitdiff
path: root/demos/quickstart/protected/pages/Advanced/Samples/I18N/Home.php
blob: cce1ed4e1e369a044cf7002dd5ac13c2354488dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php

class Home extends TPage
{
	/**
	 * Change the globalization culture using value from request "lang" parameter.
	 */
	public function __construct()
	{
		parent::__construct();
		$lang = $this->Request['lang'];
		$info = new CultureInfo();
		if($info->validCulture($lang)) //only valid lang is permitted
			$this->getApplication()->getGlobalization()->setCulture($lang);
	}

	/**
	 * Initialize the page with some arbituary data.
	 * @param TEventParameter event parameter.
	 */
	public function onLoad($param)
	{
		parent::onLoad($param);
		$time1 = $this->Time1;
		$time1->Value = time();

		$number2 = $this->Number2;
		$number2->Value = 46412.416;

		$this->dataBind();
	}

	/**
	 * Get the localized current culture name.
	 * @return string localized curreny culture name.
	 */
	public function getCurrentCulture()
	{
		$culture = $this->getApplication()->getGlobalization()->getCulture();
		$cultureInfo = new CultureInfo($culture);
		return $cultureInfo->getNativeName();
	}
}

?>