Skip to content

Commit e2029f1

Browse files
committed
Merge pull request php-debugbar#131 from Anahkiasen/localization
Add LocalizationCollector
2 parents 14464b3 + b3b5aae commit e2029f1

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?php
2+
/*
3+
* This file is part of the DebugBar package.
4+
*
5+
* (c) 2013 Maxime Bouroumeau-Fuseau
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
10+
11+
namespace DebugBar\DataCollector;
12+
13+
use Exception;
14+
15+
/**
16+
* Collects info about the current localization state
17+
*/
18+
class LocalizationCollector extends DataCollector implements Renderable
19+
{
20+
/**
21+
* Get the current locale
22+
*
23+
* @return string
24+
*/
25+
public function getLocale()
26+
{
27+
return setlocale(LC_ALL, 0);
28+
}
29+
30+
/**
31+
* Get the current translations domain
32+
*
33+
* @return string
34+
*/
35+
public function getDomain()
36+
{
37+
return textdomain();
38+
}
39+
40+
public function collect()
41+
{
42+
return array(
43+
'locale' => $this->getLocale(),
44+
'domain' => $this->getDomain(),
45+
);
46+
}
47+
48+
public function getName()
49+
{
50+
return 'localization';
51+
}
52+
53+
public function getWidgets()
54+
{
55+
return array(
56+
'domain' => array(
57+
'icon' => 'bookmark',
58+
'map' => 'localization.domain',
59+
),
60+
'locale' => array(
61+
'icon' => 'flag',
62+
'map' => 'localization.locale',
63+
)
64+
);
65+
}
66+
}

0 commit comments

Comments
 (0)