-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModule.php
More file actions
executable file
·50 lines (41 loc) · 1.11 KB
/
Copy pathModule.php
File metadata and controls
executable file
·50 lines (41 loc) · 1.11 KB
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
46
47
48
49
50
<?php
namespace Translation;
use Zend\Mvc\MvcEvent;
use Zend\Session\Container as SessionContainer;
class Module
{
public function onBootstrap( MvcEvent $e )
{
$sm = $e->getApplication()->getServiceManager();
$session = new SessionContainer( 'preferences' );
if ( isset( $_GET['ln'] ) && $ln = $_GET['ln'] ) {
$session->locale = $ln;
} elseif ( !$session->locale ) {
$session->locale = \Locale::acceptFromHttp( $_SERVER['HTTP_ACCEPT_LANGUAGE'] );
}
if( $session->locale == 'ru' ){
$session->locale = 'ru_RU';
}elseif($session->locale == 'en'){
$session->locale = 'en_EN';
}
\Locale::setDefault( $session->locale );
$translator = $sm->get( 'translator' );
$translator->setLocale( $session->locale )
// ->setFallbackLocale( 'en_EN' )
->factory( $sm->get( 'config' )['translator'] );
}
public function getConfig()
{
return include __DIR__ . '/config/module.config.php';
}
public function getAutoloaderConfig()
{
return array(
'Zend\Loader\StandardAutoloader' => array(
'namespaces' => array(
__NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
),
),
);
}
}