summaryrefslogtreecommitdiff
path: root/demos/quickstart/protected/pages/Advanced/Samples/I18N/Home.php
blob: 6966a4cd8073b7d9290eaf35796c25877f087238 (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
<?php

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

	/**
	 * Initialize the page with some arbituary data.
	 * @param TEventParameter event parameter.
	 */
	protected 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();
	}
}

?>