Rev 186 | Rev 193 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 186 | Rev 192 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | <?php
|
1 | <?php
|
2 | 2 | ||
3 | class IndexView extends \PointedEars\PHPX\View |
3 | class IndexView extends \PointedEars\PHPX\View |
4 | {
|
4 | {
|
5 | /**
|
5 | /**
|
- | 6 | * @var \Zend\I18n\Translator\Translator
|
|
- | 7 | */
|
|
- | 8 | private $_translator; |
|
- | 9 | ||
- | 10 | /**
|
|
- | 11 | * @var string
|
|
- | 12 | */
|
|
- | 13 | private $_textDomain; |
|
- | 14 | ||
- | 15 | /**
|
|
- | 16 | * @var string
|
|
- | 17 | */
|
|
- | 18 | private $_language; |
|
- | 19 | ||
- | 20 | /**
|
|
6 | * Creates a new index view
|
21 | * Creates a new index view
|
7 | *
|
22 | *
|
8 | * @see View::__construct()
|
23 | * @see View::__construct()
|
9 | */
|
24 | */
|
10 | public function __construct ($template) |
25 | public function __construct ($template) |
11 | {
|
26 | {
|
12 | parent::__construct('application/layouts/index/index.phtml'); |
27 | parent::__construct('application/layouts/index/index.phtml'); |
- | 28 | ||
- | 29 | require_once 'Zend/Loader/StandardAutoloader.php'; |
|
- | 30 | $loader = new Zend\Loader\StandardAutoloader(array('autoregister_zf' => true)); |
|
- | 31 | $loader->register(); |
|
- | 32 | ||
- | 33 | $translator = $this->_translator = new Zend\I18n\Translator\Translator(); |
|
- | 34 | // $translator->setCache(new Zend\Cache\Storage\*Adapter());
|
|
- | 35 | $type = 'gettext'; |
|
- | 36 | $base_dir = $_SERVER['DOCUMENT_ROOT'] . '/i18n/LocaleData'; |
|
- | 37 | $pattern = '%s/LC_MESSAGES/%1$s.pointedears.mo'; |
|
- | 38 | $text_domain = $this->_textDomain = 'de.pointedears'; |
|
- | 39 | $translator->addTranslationFilePattern($type, $base_dir, $pattern, $text_domain); |
|
- | 40 | }
|
|
- | 41 | ||
- | 42 | /**
|
|
- | 43 | * @param string $value
|
|
- | 44 | * @return IndexView
|
|
- | 45 | */
|
|
- | 46 | public function setLanguage ($value) |
|
- | 47 | {
|
|
- | 48 | $this->_language = $value; |
|
- | 49 | return $this; |
|
- | 50 | }
|
|
- | 51 | ||
- | 52 | /**
|
|
- | 53 | * Returns the translation of the parameter, if any,
|
|
- | 54 | * using Zend Framework 2.1 Translate
|
|
- | 55 | *
|
|
- | 56 | * @param string $s
|
|
- | 57 | * @return string
|
|
- | 58 | */
|
|
- | 59 | function _ ($s) |
|
- | 60 | {
|
|
- | 61 | return $this->_translator->translate($s, $this->_textDomain, $this->_language); |
|
13 | }
|
62 | }
|
14 | }
|
63 | }
|
15 | 64 |